|
I'm assuming this is a Domino question -- if not, I hope someone can point me in the right direction. I'm having trouble getting a SQLRPGLE stored procedure to return results to a Domino agent when the stored procedure uses a prepared SQL statement.
I have set up a test where a Domino agent, using ADO, runs a stored procedure on the iSeries that returns a recordset. The agent then lists the rows that were returned. The following code in the stored procedure works fine:
/free
Exec SQL
DECLARE C1 CURSOR WITH RETURN FOR
SELECT CMPNAM FROM RCO ORDER BY CMPNAM DESC;
Exec SQL Open C1;
/end-free
but the following code causes an error in the agent saying there's a problem opening the recordset:
/free
SQLTXT = 'SELECT CMPNAM FROM RCO ORDER BY CMPNAM DESC';
Exec SQL
PREPARE sqlstmt FROM :SQLTXT;
Exec SQL
DECLARE C1 CURSOR WITH RETURN FOR sqlstmt;
Exec SQL Open C1;
/end-free
Interestingly (oddly?), both work fine if I call them directly in iSeries Navigator's Run SQL Scripts.
The relevant code in the agent is:
'' Create the command object
Set adoCmd = CreateObject("ADODB.Command")
Set adoCmd.ActiveConnection = ADOConnection
adoCmd.CommandType = adCmdStoredProc
cmdString ="MYLIB.MYTESTPROC"
adoCmd.CommandText = cmdString
'' Create the ADO record set
Set adoRS = adoCmd.Execute()
cnt = 0
'' Check if result set is open
If (adoRS.State = adStateOpen) Then
'' Check if result set contains any rows
If (Not adoRS.EOF) Then
While (Not adoRS.EOF)
cnt = cnt + 1
Print adoRS.Fields("CMPNAM").Value& |<br />|
adoRS.MoveNext
Wend '' (Not adoRS.EOF)
Print |<br /> |& CStr(cnt)& | rows found<br /> |
Else
'' No records in recordset
Print | No rows found!<br />|
End If '' (Not adoRS.EOF)<> "0")
Else
'' Recordset was not open
Print | There was a problem opening the recordset!<br />|
End If '' (adoRS.State = 1)
and the stored procedure is created with the following command:
create procedure MYLIB/MYTESTPROC
language rpgle
parameter style general
not deterministic
reads SQL data
result sets 1
external name 'MYLIB/MYSRVPGM(MYMOD)'
Does anyone have any idea what is going on?
Thanks very much in advance,
Mike Naughton
Senior Programmer/Analyst
Judd Wire, Inc.
124 Turnpike Road
Turners Falls, MA 01376
413-676-3144
Internal: x 444
mnaughton@xxxxxxxxxxxx
****************************************
NOTICE: This e-mail and any files transmitted with it are confidential and solely for the use of the intended recipient. If you are not the intended recipient or the person responsible for delivering to the intended recipient, be advised that any use is
strictly prohibited. If you have received this e-mail in error, please notify us immediately by replying to it and then delete it from your computer.
_______________________________________________
This is the Lotus Domino on the iSeries / AS400 (Domino400) mailing list
To post a message email: Domino400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/domino400
or email: Domino400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/domino400.
As an Amazon Associate we earn from qualifying purchases.
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.