× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Note to self: It helps if you actually run JDBC_NextRow(rs) before jdbc_getcol.

From: Smith, Mike
Sent: Wednesday, September 5, 2018 11:32 AM
To: RPG programming on the IBM i / System i (rpg400-l@xxxxxxxxxxxx) <rpg400-l@xxxxxxxxxxxx>
Subject: embedded sql to retrieve next Object ID from Sql Server

I'm trying to use embedded sql to retrieve the Next Object Id from a table on Sql Server.
In SQL Server ive tested the following

DECLARE @myval integer
EXEC dbo.next_rowid 'GISOWNER', 'CPERTREADINGS', @myval OUTPUT
SELECT @myval ;

In my rpg pgm

D Q s 1 inz('''')
stmt = JDBC_PrepStmt(conn:
'declare @id as integer Exec dbo.next_rowid ' +
Q + 'GISOwner' + Q + ', ' + Q + 'CPERTREADINGS' + Q +
', ' + '@id OUTPUT; Select @ID;' );
rs = JDBC_ExecPrepQry(stmt);
objectid = (jdbc_getCol(rs: 1));

I don't get any exceptions after the JDBC_ExecPrepQry statement, but when I run the jdbc_getCol statement I get

'No current row in the ResultSet'

Does anyone know what I'm doing wrong on this?

Thanks

Mike
NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.