Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute stored procedures with output parameter #51

Closed
DavDavid opened this issue Jun 29, 2016 · 18 comments
Closed

Execute stored procedures with output parameter #51

DavDavid opened this issue Jun 29, 2016 · 18 comments

Comments

@DavDavid
Copy link

DavDavid commented Jun 29, 2016

Is it possible execute a stored procedure that has output parameters? I have tried:

String result = new JdbcSession(datasource)
  .sql("call procedure('paramIn', 'paramOut')")
  .update(new SingleOutcome<>(String.class)
;

but doesn't work. It returns a java.sql.SQLException: ORA-06577.


@dmarkov
Copy link

dmarkov commented Jul 4, 2016

@yegor256 please do something about it, see par.21

@yegor256
Copy link
Member

yegor256 commented Jul 7, 2016

@DavDavid we don't support that now. we should create an instance of CallableStatement and then do this:

stmt.registerOutParameter(1, Types.VARCHAR);

We don't do this now. I don't know how exactly to extend our library to support that... Let's think

@yegor256 yegor256 added the bug label Jul 7, 2016
@yegor256
Copy link
Member

yegor256 commented Jul 7, 2016

@DavDavid maybe you have a suggestion?

@dmarkov
Copy link

dmarkov commented Aug 8, 2016

@amihaiemil please help, the task is yours

@amihaiemil
Copy link
Member

amihaiemil commented Aug 12, 2016

@DavDavid Can you try to see if this works?

String result = new JdbcSession(datasource)
  .sql("call procedure('paramIn', ?)")
  .prepare(
      new Preparation() {
          @Override
          public void prepare(PreparedStatement stmt) throws SQLException {
              CallableStatement cstmt = (CallableStatement) stmt;
              cstmt.registerOutParameter(1, Types.VARCHAR);                 
          }
      }
  )
  .update(new SingleOutcome<>(String.class);

@DavDavid
Copy link
Author

It gives me a ClassCastException in CallableStatement line:
java.lang.ClassCastException: oracle.jdbc.driver.OraclePreparedStatementWrapper cannot be cast to java.sql.CallableStatement
at com.simula.Simulation$1.prepare(Simulation.java:167)
at com.jcabi.jdbc.JdbcSession.configure(JdbcSession.java:440)
at com.jcabi.jdbc.JdbcSession.run(JdbcSession.java:377)
at com.jcabi.jdbc.JdbcSession.update_aroundBody14(JdbcSession.java:304)
at com.jcabi.jdbc.JdbcSession$AjcClosure15.run(JdbcSession.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:212)
at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1)
at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:140)
at com.jcabi.jdbc.JdbcSession.update(JdbcSession.java:304)
at com.simula.Simulation.main(Simulation.java:161)

@amihaiemil
Copy link
Member

@DavDavid right, i'm going to make an implementation for this requirement, this weekend :D

@amihaiemil
Copy link
Member

@dmarkov I created PR #53 for this issue.

@amihaiemil
Copy link
Member

@DavDavid I created a PR for this. It will take a couple of days until it is reviewed and merged. Please don't switch off notifications from this issue, as you will have to close it in the end (that's how we work here). Many thanks!

@dmarkov
Copy link

dmarkov commented Aug 15, 2016

@dmarkov I created PR #53 for this issue.

@amihaiemil thanks for that

@amihaiemil
Copy link
Member

@dmarkov I need more time

@dmarkov
Copy link

dmarkov commented Aug 22, 2016

@dmarkov I need more time

@amihaiemil yes, take your time, thanks for letting me know

@amihaiemil
Copy link
Member

@DavDavid the pr was finally merged. See details on how to use the new functionality in its description.

Can you close this ticket?

@amihaiemil amihaiemil removed their assignment Nov 22, 2016
@DavDavid
Copy link
Author

Ok, thanks very much

@dmarkov
Copy link

dmarkov commented Nov 23, 2016

@DavDavid the code made here contains a puzzle 51-55acd5db/#56, which will be resolved soon

@dmarkov
Copy link

dmarkov commented Nov 23, 2016

@amihaiemil thanks, I just added 30 mins to your account, payment AP-2R818475C7709490E, 2547 hours and 5 mins spent. +30 added to your rating, at the moment it is: +1039

@dmarkov
Copy link

dmarkov commented Jan 31, 2017

@DavDavid the last puzzle 51-55acd5db/#56 originated from here solved

@0pdd
Copy link

0pdd commented Jul 6, 2022

@DavDavid the puzzle #unknown is still not solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants