FORGOT TO REMOVE ; AFTER FROM cc_lkup
Attention to details is lacking.
I am returning all rows in the table
My code is storing all records of the table into the array of structs. I can re post code if you would like. It is working great right now but I still have a lot more to do. Thanks for your feedback.
-Carl
Any advice changing this to CURSOR?
I used the first set of code below to place all the records from table cc_lkup into my array of structs. Now I want to accomplish the same thing but use a cursor. I tried the second set of code below but get a syntax error 'y'. Any suggestions? Thanks.
Code:
EXEC SQL SELECT cc, cc_sn, cc_desc, cc_grp
INTO :cc_lkup2[y].cc, :cc_lkup2[y].cc_sn, :cc_lkup2[y].cc_desc, :cc_lkup2[y].cc_grp
FROM cc_lkup
WHERE cc_grp != ''
ORDER BY cc;
EXEC SQL BEGIN;
++y;
EXEC SQL END;*/
Code:
EXEC SQL DECLARE c1 CURSOR for
SELECT cc, cc_sn, cc_desc, cc_grp
FROM cc_lkup
WHERE cc_grp != ''
ORDER BY cc;
EXEC SQL OPEN c1;
EXEC SQL FETCH c1
INTO :cc_lkup2[y].cc, :cc_lkup2[y].cc_sn, :cc_lkup2[y].cc_desc, :cc_lkup2[y].cc_grp
y = y + 1;
EXEC SQL CLOSE c1;
Thanks for pointing that out - Still a problem
That helped. Thanks. It now compiles with no errors but there are no results in my array. I think I may need a loop or something inside the fetch command. This stuff is over my head but I gotta figure it out. Think of anything let me know. Thanks again.
-Carl
Here is the for loop I use to print the results without the formating
Code:
for( x = 1; x < row_count; x++ ) /* set x =1 due to first record cc_lkup2[0] = NULL*/
{
printf("%-12d %-10s %-40s %s\n", cc_lkup2[x].cc, cc_lkup2[x].cc_sn, cc_lkup2[x].cc_desc, cc_lkup2[x].cc_grp);
}
I am using begin... end to loop thru first set of code and it works... I probably have to figure out a way to loop thru the cursor in a similar manner..
Thanks,
Carl