I am not sure, it has been so long since I have messed with 400s, but is the pointer given an initial value before calling the program? something like:

Dcl Y-Ptr * init(*null) or based(*null)

not sure of the syntax any more, before it is called so that the sytem knows it is a pointer?

From: C400-L <c400-l-bounces@xxxxxxxxxxxx> on behalf of Jevgeni Astanovski <jevgeniast@xxxxxxxxx>
Sent: Friday, December 16, 2016 2:55 AM
To: Bare Metal Programming IBM i (AS/400 and iSeries)
Subject: [C400-L] Misunderstanding with JDBCR4

Hi, collegues
Having a challenge of accessing external database from my ILE/C
program, looked at Scott Klement JDBCR4.
As I do not write RPG, had to spend some time porting library header
from RPG to C. Not a big job.
Generally works fine.
However when I tried to see how JDBC_GetCol returns NullInd in case
field is empty, ran into a problem.

JDBC_GetCol is prototyped so:

VAR32767 JDBC_GETCOL(RESHANDLE *, int, char *) ;
VAR32767 and RESHANDLE are my defined types and they work fine.

I call this function in my program:

char NullInd ;
VAR32767 Field ;

Field = JDBC_GETCOL(&rs, 48, &NullInd) ;

It returns field value fine, however NullInd is always unchanged -
field is empty or not.
Run in debugger mode to see what Scott's program does.
His function looks so:

P JDBC_GetCol B export
D JDBC_GetCol PI 32767A varying
D rs like(ResultSet)
D col 10I 0 value
D nullInd 1N options(*nopass:*omit)
D result s 32767A varying
D str s like(jstring)
D null s 1N inz(*OFF)



str = getColString(rs: col);
if (str = *NULL);
result = '';
null = *ON;
result = r(str);
null = *ON;
result = '';
if (%parms >= 3 and %addr(nullInd)<>*NULL);
nullInd = Null;

return result;


Sorry for the formatting...

What my debugging show is that Null variable has a proper value, but
is never assigned to nullInd.
I added NumParms variable and assigned value of %parms to it.
From that I saw that NumParms is -1, however all 3 parameters are passed.

Had a look at the manual for %parms.
It says the following:
"The value returned by %PARMS will be -1 if the system can determine
that the operational
descriptor was not passed, but in some cases when the system cannot detect this,
the value returned by %PARMS may be an incorrect value that is zero or greater."

Is there anything I can do about it?

Any advise will be highly appreciated...

This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
C400-L Info Page -<>
The topic of the list is C, C++, and MI Programming on and for the IBM i (AS/400 and iSeries). This includes programming on other platforms in C/C++ when it RELATES ...

or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at -- C400-L mailing list archive<> C400-L mailing list archive

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-2022 by 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.