|
On Feb 15, 2018, at 7:32 AM, Roman Miklos <rmiklos.work@xxxxxxxxx> wrote:
Hi Jon,
Thank you for the advice to debug the program.
I debugged the program, inspected the variables generated by
SQL-precompiler and then found out that it was only my failure: I have done
an mistake creating the URL-string.
I corrected the error and now the approach with host variable works like a
charm.
Best Regards
Roman
On Tue, Feb 13, 2018 at 3:04 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:
Time for a call to IBM Roman - it should work.--
But check your PTF levels first.
Did you look at the generated code and compare with the RPG version?
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Feb 13, 2018, at 6:58 AM, Roman Miklos <rmiklos.work@xxxxxxxxx>wrote:
wrote:
I declared
01 HEX-NULL PIC X VALUE X'00'.
and added it at the end of URL as follows:
* create WebService URL string
STRING
QUOTE
FUNCTION TRIM(URL-BASE-STRING)
HEX-NULL
QUOTE
DELIMITED BY SIZE
INTO URL-STRING
END-STRING
But unfortunatelly it did not help.
On Mon, Feb 12, 2018 at 7:00 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx>
seeing
I thought originally that it might be because the COBOL version was
"fake"blanks at the back end of the URL.
Unless the pre-comp is doing something special it will not see you
shouldURL-STRING variable as a VarChar (no such thing in COBOL) and will treat
the whole thing as one big character variable. There's no way that
fieldwork as the length will be at the front of the string.
Just for fun I tried changing the RPG version to use a fixed length
nofor the URL and it works just fine. The fixed length field (including
trailing spaces) is placed in the SQLnnn varcher variable. No trimming,
assignment.adding a null character to terminate the string, just straight
helpfulThat indicates to me that the COBOL should be able to use a simple
character variable. But studying the pre-compiler output would be
thein seeing what is going on under the covers.
In your working version you did trim the URL. Does it work if you omit
subtlytrim? It doesn't seem to matter in RPG but the COBOL pre-comp may be
article,different.
If it does _not_ work without the trim then can you use Reference
Modification on the host variable to limit its length as trim would?
Only other possibility I can think of is that adding a hex x'00' at the
end of the valid part of the URL might work - depends on what the
underlying Java functions are expecting.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Feb 12, 2018, at 11:23 AM, Roman Miklos <rmiklos.work@xxxxxxxxx>wrote:
service-using-sql-get/
Hello,
I'm using SQL-function HttpGetClob to call a webservice as described in
this article:
https://www.itjungle.com/2017/09/18/guru-consuming-rest-web-
host
I tried the RPG-example from the article and it works fine when using
variable for the URL (i.e. :WebServiceUrl)
But it doesn't work in COBOL.
When I try in COBOL this, then it works:
DECLARE-CURSOR-FOR-SELECT.
* Compose SQL SELECT-Statement for calling WS
STRING
'SELECT '
'SYSTOOLS.HTTPGETCLOB('
FUNCTION TRIM(URL-STRING)
", '') "
'FROM SYSIBM.SYSDUMMY1'
DELIMITED BY SIZE
INTO SQLSOURCE
END-STRING
* Declare SQL-Statement SELECTWS
EXEC SQL
DECLARE SELECTWS STATEMENT
END-EXEC
* Declare Cursor for SQL-Statement
EXEC SQL
DECLARE CLOOPWS CURSOR FOR SELECTWS
END-EXEC
* Prepare SQL-Statement from the string SQLSOURCE
EXEC SQL
PREPARE SELECTWS FROM :SQLSOURCE
END-EXEC
.
The webservice call is succesfull and I get the resulting JSON.
But when I try to do it as in the RPG-example from the mentioned
COBOLi.e. with the host variable, then it doesn't work:it
DECLARE-CURSOR-FOR-SELECT.
* Declare Cursor for SQL-Statement
EXEC SQL
DECLARE CLOOPWS CURSOR FOR
SELECT
SYSTOOLS.HTTPGETCLOB(:URL-STRING, '')
FROM SYSIBM.SYSDUMMY1
END-EXEC
Opening the cursor is succesfull, I get:
SQLSTATE = '00000'
SQLCODE = 000000000
but the execution of fetch fails:
EXEC SQL
FETCH NEXT FROM CLOOPWS INTO :SQL-RS:SQL-NULLIND
END-EXEC
I get the error:
SQLSTATE = '38000'
SQLCODE = -000004302
Declaration of my Host variable is:
01 URL-STRING PIC X(256).
I tried to declare the host variable as VARCHAR too, i.e. like this but
didn't help:
01 URL-STRING.
49 URL-STRING-LEN PIC S9(4) COMP-4.
49 URL-STRING-CONTENT PIC X(255).
IMO, when it works with the host variable in RPG, it should work in
(COBOL400-L) mailing list--too.(COBOL400-L) mailing list
Could you please say me what I'm doing wrong with the host variable ?
Or how should I declare the host variable, so it would work?
Kindly Regards
Roman
--
This is the COBOL Programming on the IBM i (AS/400 and iSeries)
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/cobol400-l.
--
This is the COBOL Programming on the IBM i (AS/400 and iSeries)
(COBOL400-L) mailing list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/cobol400-l.
This is the COBOL Programming on the IBM i (AS/400 and iSeries)
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/cobol400-l.
--
This is the COBOL Programming on the IBM i (AS/400 and iSeries)
(COBOL400-L) mailing list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/cobol400-l.
This is the COBOL Programming on the IBM i (AS/400 and iSeries) (COBOL400-L) mailing list
To post a message email: COBOL400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/cobol400-l.
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.