× 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.



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:

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>
wrote:

I thought originally that it might be because the COBOL version was
seeing
blanks at the back end of the URL.

Unless the pre-comp is doing something special it will not see you
"fake"
URL-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
should
work 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
field
for the URL and it works just fine. The fixed length field (including
trailing spaces) is placed in the SQLnnn varcher variable. No trimming,
no
adding a null character to terminate the string, just straight
assignment.
That indicates to me that the COBOL should be able to use a simple
character variable. But studying the pre-compiler output would be
helpful
in seeing what is going on under the covers.

In your working version you did trim the URL. Does it work if you omit
the
trim? It doesn't seem to matter in RPG but the COBOL pre-comp may be
subtly
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:

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-
service-using-sql-get/


I tried the RPG-example from the article and it works fine when using
host
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
article,
i.e. with the host variable, then it doesn't work:

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
it
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
COBOL
too.

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)
(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.


--
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 thread ...

Follow-Ups:
Replies:

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.