I'm using C Programming and am trying to write out a fixed length text file.
The text file will be the result from a SELECT query against DB2 database tables.
-----------------------------------------
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT bp73.adds_id, bp73.priority, bp70.last_name, bp70.first_name
FROM nysa.bp73t_req_by bp73
JOIN nysa.bp70t_member bp70
ON bp73.mbr_id = bp70.mbr_id
WHERE bp70.budget_yr = :bp70.budget_yr;
----------------------------------------
The data needs to start and end in certain positions so it can be read by a macro in an access database.
What is the best method to use for my case?
So far I have used fprintf but I don't think I can control which positions I can place the data.
Here's my code:
----------------------------------------------------
fprintf(output,"%li,%s,%s,%s\n,",
bp73.adds_id, bp73.priority, bp70.last_name,
bp70.first_name);
-----------------------------------------------------
Could I use fwrite or is there another alternative?
I tried fwrite but I think I got the syntax incorrect.
I'm looping thru the cursor and am trying to print out each record to the text file.
Here's what I tried:
------------------------------------------------------
fwrite(&C1,sizeof(C1),1,output);
(where C1 is my cursor)
----------------------------------------------------
Thanks in Advance.
John
The text file will be the result from a SELECT query against DB2 database tables.
-----------------------------------------
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT bp73.adds_id, bp73.priority, bp70.last_name, bp70.first_name
FROM nysa.bp73t_req_by bp73
JOIN nysa.bp70t_member bp70
ON bp73.mbr_id = bp70.mbr_id
WHERE bp70.budget_yr = :bp70.budget_yr;
----------------------------------------
The data needs to start and end in certain positions so it can be read by a macro in an access database.
What is the best method to use for my case?
So far I have used fprintf but I don't think I can control which positions I can place the data.
Here's my code:
----------------------------------------------------
fprintf(output,"%li,%s,%s,%s\n,",
bp73.adds_id, bp73.priority, bp70.last_name,
bp70.first_name);
-----------------------------------------------------
Could I use fwrite or is there another alternative?
I tried fwrite but I think I got the syntax incorrect.
I'm looping thru the cursor and am trying to print out each record to the text file.
Here's what I tried:
------------------------------------------------------
fwrite(&C1,sizeof(C1),1,output);
(where C1 is my cursor)
----------------------------------------------------
Thanks in Advance.
John