Re: What is wrong?
- From: Jonathan Ball <jonball@xxxxxxxxxxxxxx>
- Date: Wed, 23 Jan 2008 19:38:09 -0800
Saml wrote:
It's been a long day, so take this with a grain of salt...
Don't you want to use parameter markers on the cursor?
C/EXEC SQL
C+ DECLARE CTLWO CURSOR FOR
C+ select cjshid
C+ from edcjlf02
C+ where cjonbr = ? -- <<<<<------------
c+ fetch first row only
C/END-EXEC
I think you cannot use a parameter marker in a statically declared cursor like that. Parameter markers are used in dynamically constructed cursor definitions that you then PREPARE into a SQL variable; the SQL variable is then referenced in the DECLARE statement:
/free
rpg_var = 'select col_a from table_1 where col_b = ?';
/end-free
c/exec sql
c+ prepare sql_var from :rpg_var
c/end-exec
c/exec sql
c+ declare my_cursor for sql_var
c/end-exec
c/exec sql
c+ open my_cursor using :wo#
c/end-exec
Of course, if you are only reading on row, you probably don't need a cursor at all.
Exactly right:
C/EXEC SQL
C+ select cjshid
C+ into :ctl#
C+ from edcjlf02
C+ where cjonbr = :wo#
c+ fetch first row only
C/END-EXEC
<qgenesist@xxxxxxxxxxx> wrote in message news:bc9140d2-b9d9-4eed-9770-72c38177125d@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.This program locks and doesnt debug at begin of proc. what I am trying
to do is send in a workorder 112272 and retrieve the controlling work
order (lets call it 112100) and return that number. As you might be
able to tell, my procedure making skills are non-existant, I will
eventually do this and some other procs and make a service program.
call rtvctl# '112272'
H*NOMAIN
H DEBUG
H DFTACTGRP(*NO) ACTGRP(*CALLER)
H OPTION(*SRCSTMT:*NODEBUGIO)
D DS_EDCJPF E DS EXTNAME(edcjpf)
/copy proto,rtvctl#
here it is:
D*RTVCTL# PR 6S 0 EXTPROC ('RTVCTL#')
D RTVCTL# PR 6S 0
D WO# 6S 0
CONST
P RTVCTL# B
D PI 6S 0
D WO# 6S 0 const
D CTL# S 6S 0
C/EXEC SQL
C+ Set Option commit= *none
C/END-EXEC
C/EXEC SQL
C+ Set Option closqlcsr= *endmod
C/END-EXEC
c #main tag
c exsr $dclcsr
c exsr $opncsr
c exsr $rtvctl
C dump
c exsr $rtvstt
c exsr $clscsr
C #end TAG
c eval *inlr = *on
C #rtx TAG
c return ctl#
c $dclcsr begsr
********************************************************
* Declare Cursor with Selection Criteria
********************************************************
C/EXEC SQL
C+ DECLARE CTLWO CURSOR FOR
C+ select cjshid
C+ from edcjlf02
C+ where cjonbr = :wo#
c+ fetch first row only
C/END-EXEC
c #dclcsr tag
c endsr
********************************************************
* Open Cursor
********************************************************
c $opncsr begsr
C/EXEC SQL
C+ OPEN CTLWO USING :wo#
C/END-EXEC
c #opncsr tag
c endsr
*********************************
* Retrieve Controlling Workorder
*********************************
c $rtvctl begsr
C/EXEC SQL
C+ FETCH CTLWO INTO :ctl#
C/END-EXEC
c #rtvctl# tag
c endsr
*********************************
* Retrieve SQL State
*************************************
c $rtvstt begsr
c #rtvstt tag
c endsr
*************************************
* Close Cursor
*************************************
c $clscsr begsr
C/EXEC SQL
C+ CLOSE CTLWO
C/END-EXEC
c #clscsr tag
c endsr
P RTVCTL# E
- References:
- What is wrong?
- From: qgenesist
- Re: What is wrong?
- From: Saml
- What is wrong?
- Prev by Date: Re: What is wrong?
- Next by Date: Re: What is wrong?
- Previous by thread: Re: What is wrong?
- Next by thread: Re: What is wrong?
- Index(es):
Relevant Pages
|