Informix 4gl Input Cursor
Posted in 2004
Topics: High Availability & Replication, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi
As a novice, I have the following code:-
DATABASE comwise
DEFINE l_diet_rec RECORD
pat INT,
ref int,
cons char(30)
END RECORD,
strsql char(100),
ct_line RECORD like clinical_textlines.*
DEFINE ctid int
DEFINE cons char(30)
MAIN
DEFINE ct RECORD
ct_id int
END RECORD
DECLARE diet_curs CURSOR FOR
SELECT * from diet_cons
let strsql = "SELECT ct_ctid FROM clinical_texthdr WHERE ct_type =
'RF' and ct_pg = 'ND' and ct_id = ?"
PREPARE head_prep from strsql
DECLARE head_curs CURSOR FOR head_prep
FOREACH diet_curs INTO l_diet_rec.*
OPEN head_curs USING l_diet_rec.pat
FETCH head_curs INTO ct.*
let ctid = ct.ct_id
let cons = l_diet_rec.cons
DECLARE ct_curs CURSOR
FOR INSERT INTO clinical_textlines VALUES (ctid,1, cons)
open ct_curs
PUT ct_curs
CLOSE ct_curs
CLOSE head_curs
END FOREACH
END MAIN
However, my INSERT Cursor is not taking any values into the variable
cons
It is adding the necessary lines in the table - with values ctid and
1, but it leaves cons empty
I know there are values in cons because if I put a DISPLAY statement
in the query, the values are shown on screen.
Any ideas why I am not getting complete values in the data entry?
Thanks
Gary
On Fri, 05 Nov 2004 11:24:08 -0500, Gary Cobden wrote:
Try this version:
DATABASE comwise
DEFINE l_diet_rec RECORD
pat INT,
ref int,
cons char(30)
END RECORD,
strsql char(100),
strins char(1024),
ct_line RECORD like clinical_textlines.*
DEFINE ctid int
DEFINE cons char(30)
MAIN
DEFINE ct RECORD
ct_id int
END RECORD
DECLARE diet_curs CURSOR FOR
SELECT * from diet_cons
let strsql = "SELECT ct_ctid FROM clinical_texthdr WHERE ct_type = 'RF' and
ct_pg = 'ND' and ct_id = ?"
PREPARE head_prep from strsql
DECLARE head_curs CURSOR FOR head_prep
FOREACH diet_curs INTO l_diet_rec.*
OPEN head_curs USING l_diet_rec.pat
FETCH head_curs INTO ct.*
let ctid = ct.ct_id
let cons = l_diet_rec.cons
let strins = INSERT INTO clinical_textlines VALUES (?,1,?)
PREPARE ct_stmt FROM strins
DECLARE ct_curs CURSOR FOR ct_stmt
PUT ct_curs USING ctid, cons
CLOSE ct_curs
CLOSE head_curs
END FOREACH
END MAIN
Art S. Kagel
>
> However, my INSERT Cursor is not taking any values into the variable cons It
> is adding the necessary lines in the table - with values ctid and 1, but it
> leaves cons empty
>
> I know there are values in cons because if I put a DISPLAY statement in the
> query, the values are shown on screen.
>
> Any ideas why I am not getting complete values in the data entry?
>
> Thanks
>
> Gary
On Fri, 05 Nov 2004 11:55:49 -0500, Art S. Kagel wrote:
OOps, forgot the quotes around the string assigned to strins in the let
statement below and a line got broken in a bad spot by my mailer.
Corrected here:
Art S. Kagel
> On Fri, 05 Nov 2004 11:24:08 -0500, Gary Cobden wrote:
Try this version:
>
DATABASE comwise
DEFINE l_diet_rec RECORD
pat INT,
ref int,
cons char(30)
END RECORD,
strsql char(100),
strins char(1024),
ct_line RECORD like clinical_textlines.*
DEFINE ctid int
DEFINE cons char(30)
MAIN
DEFINE ct RECORD
ct_id int
END RECORD
DECLARE diet_curs CURSOR FOR
SELECT * from diet_cons
let strsql = "SELECT ct_ctid FROM clinical_texthdr WHERE ct_type = 'RF' and
ct_pg = 'ND' and ct_id = ?"
PREPARE head_prep from strsql
DECLARE head_curs CURSOR FOR head_prep
FOREACH diet_curs INTO l_diet_rec.*
OPEN head_curs USING l_diet_rec.pat
FETCH head_curs INTO ct.*
let ctid = ct.ct_id
let cons = l_diet_rec.cons
let strins = "INSERT INTO clinical_textlines VALUES (?,1,?)"
PREPARE ct_stmt FROM strins
DECLARE ct_curs CURSOR FOR ct_stmt
PUT ct_curs USING ctid, cons
CLOSE ct_curs
CLOSE head_curs
END FOREACH
END MAIN
>
> Art S. Kagel
>
>
>> However, my INSERT Cursor is not taking any values into the variable cons
>> It is adding the necessary lines in the table - with values ctid and 1, but
>> it leaves cons empty
>>
>> I know there are values in cons because if I put a DISPLAY statement in the
>> query, the values are shown on screen.
>>
>> Any ideas why I am not getting complete values in the data entry?
>>
>> Thanks
>>
>> Gary