-
Notifications
You must be signed in to change notification settings - Fork 18
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
Is there any example to show how to call stored procedures? #35
Comments
@Louis-7 You can call xmlservice like this: |
Hey @jimoibm, so I suppose to create a PGM called XMLTEST and use it to call the stored procedure? I tried this as well: I execute a query in my SP and open a cursor. Xmlservice always returns me error. The response looks like: ...
<error>
<sqlcode>466</sqlcode>
<sqlstate>0100C</sqlstate>
<errnoxml>1500001</errnoxml>
<xmlerrmsg>
<![CDATA[SQL fail]]>
</xmlerrmsg>
<xmlhint>
<![CDATA[0100C:466:1 result sets are available from procedure XXXX]]>
</xmlhint>
</error>
<error>
<sqlcode>466</sqlcode>
<sqlstate>0100C</sqlstate>
<errnoxml>1500001</errnoxml>
<xmlerrmsg>
<![CDATA[SQL fail]]>
</xmlerrmsg>
<xmlhint>
<![CDATA[0100C:466:1 result sets are available from procedure XXXX]]>
</xmlhint>
</error>
<jobinfo>
<jobipc></jobipc>
<jobipcskey>FFFFFFFF</jobipcskey>
<jobname>QSQSRVR</jobname>
<jobuser>QUSER</jobuser>
<jobnbr>742573</jobnbr>
<jobsts>*ACTIVE</jobsts>
<curuser>XXXX</curuser>
<ccsid>37</ccsid>
<dftccsid>37</dftccsid>
<paseccsid>0</paseccsid>
<langid>ENU</langid>
<cntryid>US</cntryid>
<sbsname>QSYSWRK</sbsname>
<sbslib>QSYS</sbslib>
<curlib></curlib>
<syslibl>QSYS QSYS2 QHLPSYS QUSRSYS</syslibl>
<usrlibl>TECHLIB QGPL QTEMP</usrlibl>
<jobcpffind>see log scan, not error list</jobcpffind>
</jobinfo>
... I think your solution and mine are both working, but how can I get the return value from a SP? Can I get the return value in PGM? |
@Louis-7 Yes and no. You need to create your own pgm but being called by xmlservice. Your web application talks with xmlservice in xml format. xmlservice calls your own pgm. |
I see, but there is no way to get return value from SP? |
@Louis-7 I am not sure I understand your question. xmlservice is just a broker that passes the dataIn and dataOut between your web app and your background program.. guess the return value you meant was output data? in and out data are both passed with address... they can be passed in/out... |
Yes, output data. It should be returned in the response body. For example, I send a db query request to xmlservice, it should return the query result to me. I'd like to get the stored procedure executed result in xmlservice output data. Maybe this question is not related to xmlservice itself but IBM i. |
Can you show me more details on what you did? |
Sure. This is my SP for the test, just do a simple query -> CREATE PROCEDURE MYLIB.SPTEST ( )
RESULT SETS 1
LANGUAGE SQL
SPECIFIC MYLIB.DBSPTEST
P1 : BEGIN
-- Declare cursor
DECLARE CURSOR1 CURSOR WITH RETURN TO CALLER
FOR
SELECT * FROM A_TABLE;
-- Cursor left open for client application
OPEN CURSOR1;
END P1 Here is what I sent to xmlservice (with POST method) ->
I expect this SP return the query result in xmlservice response body. But the actual result is it returns me the errors (I post the errors in the previous comment). The reason I said it may not the xmlservice problem is I call this SP on green screen (with 'strsql') and the result are same |
OK.. You are not using xmlservice to call your program but SQL to DB2. Yes the result should be in the xml body returned. Maybe you can try to verify your SQL statements outside xmlservice or check the joblog that has been indicated in the error body. If you figured out any error pointing to xmlservice, please let me know. |
I tried to call SP in Data Studio and I can get the query result. But on green screen - NO. I'm sure my SP can execute successfully. Yes, I guess I should check the joblog. Thanks. |
@jimoibm , I found another way to call the stored procedure on IBM i. I can execute the command on the green screen but it can't be executed with xmlservice. IBM i command: The xml I sent: <?xml version="1.0"?>
<xmlservice><cmd exec='rexx'>RUNSQL SQL('call myctl.mysp(''parm1'',''parm2'')')</cmd></xmlservice> Part of the return message. <joblog job='QSQSRVR' user='QUSER' nbr='869325'>
<![CDATA[Cause . . . . . : A delimiter is missing between two values or a delimiter
that is not valid was found. Recovery . . . : Change the character that
is not valid or if a delimiter is missing insert one. More information on
delimiters can be found in the Information Center.
CPD0020 Diagnostic 30 05/09/19 23:57:22.852066 QCANPARS QSYS 094F QC2SYS QSYS *STMT
From user . . . . . . . . . : ZZLIU
To module . . . . . . . . . : QC2SYS
To procedure . . . . . . . : system
Statement . . . . . . . . . : 13
Message . . . . : Character 'p' not valid following string ''' '.
Cause . . . . . : A delimiter is missing between two values or a delimiter
that is not valid was found. Recovery . . . : Change the character that
is not valid or if a delimiter is missing insert one. More information on
delimiters can be found in the Information Center.
CPD0020 Diagnostic 30 05/09/19 23:57:22.852074 QCANPARS QSYS 094F QC2SYS QSYS *STMT
From user . . . . . . . . . : ZZLIU
To module . . . . . . . . . : QC2SYS
To procedure . . . . . . . : system
Statement . . . . . . . . . : 13
Message . . . . : Character ''' not valid following string ') '.
Cause . . . . . : A delimiter is missing between two values or a delimiter
that is not valid was found. Recovery . . . : Change the character that
is not valid or if a delimiter is missing insert one. More information on
delimiters can be found in the Information Center.
CPF0001 Escape 30 05/09/19 23:57:22.852245 QCADRV2 QSYS 053F QCMDEXC QSYS 012F
From user . . . . . . . . . : ZZLIU
Message . . . . : Error found on *N command.
Cause . . . . . : The system detected errors in the command. Recovery . . .
: See the previously listed messages in the job log. Correct the errors
and then try the command again. *N instead of a command name means that the
name had not been determined before the error was found.]]>
</joblog> I'm very confused with these error messages, shouldn't I wrap the parameters with the single quotation marks? |
Looks like you are running SQL using a REXX command ? What are you expecting to come back from that ? I don't believe you will get any results back. |
Instead of calling a SP you should be able to call your program directly via SQL using the same call format and if it returns a resultset instead of parms you can consume your results just like an SQL query. Not perfect but I just had to do something similar with the Mono .Net data access. |
@richardschoen , I'd like to execute the stored procedure whether it returns the result or not. What I'm facing is I haven't found a way to execute my SP successfully on IBM i. I tried to call SP via SQL (my second reply in this issue #35 (comment)). As far as I know, you can't call SP directly by using SQL on IBM i. If it's possible could you share some example to show the xml you send to IBM i? |
This works for me on an RPG program that is NOT registered as a stored procedure that returns a resultset. Found out recently you don't need to register a SPROC with DB2 if it returns a resultset which my sample RPG does. The program call takes in 2 parameters. I think you may have to pass parms in text format, but that's a small price to pay to have the equivalent of a straight up program call instead of a stored procedure without registering with the database. Feel just like calling a SPROC though. I am using XMLSERVICE via HTTP calls from .Net.
|
Sample Minimal SQLRPGLE
|
Thank you @richardschoen , this is very helpful. I don't know it can call an RPG program in a tag before, let me have a try. |
Finally, I call the SP with "RUNSQL" command, the reason I got the error before is the IBM i user I used to send xmlservice do not have enough authority to update the data in DB. 😅 Call SP with PGM and then call PGM with xmlservice is my backup plan. |
Tried many times to call stored procedures on IBM i.
I can send SQL statements to XMLSERVICE and it's working perfectly. Does anyone have a working example to show what format of HTTP request should I send to IBM i ? (ctl, ipc, xmlin...)
The text was updated successfully, but these errors were encountered: