Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL and indicator variables

532 views
Skip to first unread message

Thad Rizzi

unread,
Mar 16, 2001, 3:58:41 PM3/16/01
to
I am writing an RPGLE program and using embedded SQL to build a cursor and
then fetch from it. When I fetch I get the SQL message SQLSTATE 22002
Indicator variable required. In my job log it looks like this...

Message . . . . : Indicator variable required.
Cause . . . . . : A FETCH, an embedded SELECT, a CALL or a SET or VALUES
INTO statement has resulted in a null value, but an indicator variable
was
not specified for host variable PRECISION. The relative position of the
host variable in the INTO clause or parameter list is 6. If the host
variable name is *N, an SQLDA was specified.
Recovery . . . : Specify an indicator variable, and precompile the
program
again.

So it looks like the null value in PRECISION is killing me. I would specify
an indicator variable if only I knew what one was. Any ideas.

Thanks,

Thad Rizzi


Thomas Kine

unread,
Mar 16, 2001, 4:56:30 PM3/16/01
to
Indicator variables are 1 byte binary fields used to indicate to you whether
a null-capable field has a value or a null in it. I don't have an RPG
example handy, but here's some COBOL code. You'll get the idea.

Define the variable and the null indicator (1 byte binary).
05 Activity-Dt Picture X(8).
05 Activity-Dt-Ind Picture S9(4) Binary.

Fetch from the cursor. The null indicator variables are not separated from
the varaible itself by a comma...SQL knows how to load these.

Exec SQL
Fetch Next
From Time_Data
Into
:Activity-Dt : Activity-Dt-Ind,
:Cnty-Staff-Num :Cnty-Staff-Num-Ind,
:Cnty-Case-Num :Cnty-Case-Num-Ind,
:App-Num :App-Num-Ind,
:Family-Mbr-Num :Family-Mbr-Num-Ind,
:Duration :Duration-Ind,
:Contact-Loc-Cd :Contact-Loc-Cd-Ind,
:Svc-Cd :Svc-Cd-Ind,
:HCPCS-Cd :HCPCS-Cd-Ind,
:Tr-Activity-Id :Tr-Activity-Id-Ind,
:Num-Pers-Rec-Svc :Num-Pers-Rec-Svc-Ind,
:Time-Record-Id :Time-Record-Id-Ind,
:Staff-Id :Staff-Id-Ind,
:WG-Id :WG-Id-Ind,
:Purpose :Purpose-Ind,
:Person-Id :Person-Id-Ind,
:Contact-Event-Id :Contact-Event-Id-Ind,
:SISI1000FL-Duration,
:Contact-Method-Cd :Contact-Method-Cd-Ind
End-Exec

Make sure you have a zero in the null indicator variable before using it.
If Cnty-Staff-Num-Ind = 0
Move Cnty-Staff-Num to TS-Worker
End-if
--
Thomas Kine
www.RighteousSoftware.com


"Thad Rizzi" <tha...@earthlink.net> wrote in message
news:58vs6.1923$Im6.2...@newsread1.prod.itd.earthlink.net...

Karl Hanson

unread,
Mar 16, 2001, 5:23:02 PM3/16/01
to

See the manual SQL Programming with Host Languages:
http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/db2/rzajpmst02.htm

Specifically see the chapter on Coding SQL Statements in ILE RPG for
AS/400 Applications.. there is an example of using indicator variables:
http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/db2/rzajpmst138.htm#Header_158

--

Karl Hanson

Thad Rizzi

unread,
Mar 19, 2001, 12:38:59 PM3/19/01
to
Thanks for the help. Worked great.


0 new messages