Home » Developer & Programmer » Precompilers, OCI & OCCI » PRO C Dynamique select with multiple rows
PRO C Dynamique select with multiple rows [message #123921] Wed, 15 June 2005 10:02 Go to next message
gorgorbhey
Messages: 1
Registered: June 2005
Junior Member
hello

i ve a problem with PRO C (i m a novice)

i d like to do a select which may have multiple row
i read a file which give me a number
i put this number into a variable numof

...
while (fgets (bufe,sizeof(bufe), ptlec))
{
/* here i ve C code which egt the number in the line */

EXEC SQL DECLARE C1 CURSOR FOR
SELECT NUM_OF,
NUM_LIGN,
to_char(DAT_SORT_PREV,'DD-MON-YYYY'),
CODE_FINI_SPEC
FROM OF_LIGN
WHERE NUM_OF=:numof;

EXEC SQL EXECUTE C1 USING :numof;

EXEC SQL OPEN C1;

EXEC SQL WHENEVER NOT FOUND CONTINUE;

EXEC SQL FETCH C1 INTO :numof, :numligne, :dat_sort_prev, :code_fs;

while (sqlca.sqlcode != 1403)
{
fprintf(ptlog,"of : %s ligne : %d Date : %s FS : %s\n",
numof.arr, numligne, dat_sort_prev.arr, code_fs.arr);
EXEC SQL FETCH C1 INTO :numof, :numligne, :dat_sort_prev, :code_fs;
compteur++;
}

fprintf(ptlog,"il y a %d lignes selectionnees\n",compteur);

EXEC SQL CLOSE C1;

EXEC SQL WHENEVER SQLERROR CONTINUE;

EXEC SQL COMMIT WORK RELEASE;
}

it works ok for the first line
but for the second the fetch always send me the last row of the first select

how can i do that ?*

thanks
Re: PRO C Dynamique select with multiple rows [message #124078 is a reply to message #123921] Thu, 16 June 2005 05:51 Go to previous message
Michael Hartley
Messages: 110
Registered: December 2004
Location: West Yorkshire, United Ki...
Senior Member

Hi

the two lines
--cut
EXEC SQL EXECUTE C1 USING :numof;
EXEC SQL OPEN C1;
--cut

cause the sql statement to be executed twice. Try removing the open statement.

kind regards

Michael Hartley http://www.openfieldsolutions.co.uk
Previous Topic: Tool for converting pro*c into form6i or report
Next Topic: how to make .mk file for windows environment
Goto Forum:
  


Current Time: Wed May 18 01:50:31 CDT 2022