Subject | Re: [Firebird-Java] Re: How to call Stored procedure? |
---|---|
Author | Andrew Guts |
Post date | 2002-12-16T09:50:14Z |
Roman Rokytskyy wrote:
written as 'executable'. The SP body does not contain "SUSPEND"
operator. That is why "select " syntax will not return any results in
such manner:
message, something like this: "SQL Error code -104. Token unknown -
line 1, char 1 { "
After I had replaced operator to "execute procedure AddRec(?, ?)" it
worked, but still no output parameter.
Adding third parameter and registerOutputParameter here causes exception
"Not implemented yet".
Thank you for your answer.
Andrew
>>Please give me a working example that calls an 'exec type' storedOk. It will work, but will not return output parameter, because SP was
>>procedure like this:
>>
>>create procedure AddRec(cdate timestamp, name varchar(80)) returns
>>
>>
>(id
>
>
>>integer) as
>>begin
>> id = GEN_ID(G_Tab1ID, 1);
>> insert into Tab1(ID, Name, CDate) values (:ID, :Name, :CDate);
>>end
>>
>>
>
>PreparedStatement stmt = connection.prepareStatement(
> "SELECT id FROM AddRec(?, ?)");
>
written as 'executable'. The SP body does not contain "SUSPEND"
operator. That is why "select " syntax will not return any results in
such manner:
>int myId = rs.getInt(1)I've tried it before asking my question. I've seen only an error
>
>another example would be:
>
>CallableStatement stmt = connection.prepareCall(
> "{call AddRec(?, ?)}");
>
>stmt.setTimestamp(1, new Timestamp(myTime));
>stmt.setString(2, myName);
>
>stmt.execute();
>
>int myId = stmt.getInt(1);
>
message, something like this: "SQL Error code -104. Token unknown -
line 1, char 1 { "
After I had replaced operator to "execute procedure AddRec(?, ?)" it
worked, but still no output parameter.
Adding third parameter and registerOutputParameter here causes exception
"Not implemented yet".
>So should I rewrite the SP as selectable? Any other ideas?
>But I do not like this example, because call statement is not 100%
>correct. It should be "{call AddRec(?, ?, ?)}" and we should call
>stmt.registerOurParameter(3, Types.INTEGER) after preparing a call.
>However, Firebird API makes it hard to support JDBC specification in
>this case.
>
>Best regards,
>Roman Rokytskyy
>
>
>
Thank you for your answer.
Andrew