Subject | Re: [IB-Java] CallableStatement returning same number |
---|---|
Author | Kenneth |
Post date | 2002-02-04T06:56:45Z |
Btw, forgot to mention that con is some Connection wrapper class
which performs PreparedStatement and CallableStatement pooling...
(hence the function call getPreparedStatement and getCallableStatement)
Regards
Kenneth
""Kenneth"" <kenneth@...> wrote in message
news:a3ksvq$mk7$1@......
which performs PreparedStatement and CallableStatement pooling...
(hence the function call getPreparedStatement and getCallableStatement)
Regards
Kenneth
""Kenneth"" <kenneth@...> wrote in message
news:a3ksvq$mk7$1@......
> Hithe
>
> I have a simple stored procedure that returns the PK ID of an inserted
> record.
> I've tried using CallableStatement, the code works, but seems that only
> first generator value is returned repeatedly.
>
> Is this the expected result?
>
> //------------------------------------------------
> SET TERM ^ ;
> CREATE PROCEDURE SP_TMPOBJ_INSERT
> RETURNS (OBJID NUMERIC(18,0))
> AS
> BEGIN
> OBJID = GEN_ID(GEN_TMPOBJ,1);
> INSERT INTO TMP_OBJECTS (ID) VALUES (:OBJID);
> SUSPEND;
> END^
> COMMIT WORK ^
> SET TERM ;^
>
> //------------------------------------------------
> This code doesn't work (I get only the first PK ID, repeatedly)
>
> for (int i=0; i<100; i++) {
> //DOESN'T SEEM TO WORK CallableStatement cs =
> con.getCallableStatement("{CALL SP_TMPOBJ_INSERT()}");
> CallableStatement cs = con.getCallableStatement("EXECUTE PROCEDURE
> SP_TMPOBJ_INSERT;");
> //cs.registerOutParameter(1, Types.NUMERIC); //UNSUPPORTED?
> cs.execute();
> long lID = cs.getLong(1);
> System.out.println(lID);
> }
>
> //------------------------------------------------
> This code works (I get an incrementing PK ID).
>
> for (int i=0; i<100; i++) {
> PreparedStatement cs = con.prepareStatement("SELECT * FROM
> SP_TMPOBJ_INSERT;");
> ResultSet rs = cs.executeQuery();
> rs.next();
> long lID = rs.getLong(1);
> System.out.println(lID);
> }
>
>
>
>
>
>
>
> To unsubscribe from this group, send an email to:
> IB-Java-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>