ESQL/C

Problem: How do I Run an "UNLOAD" Command from ESQL/C?

ESQL/C does not support the UNLOAD command. How can I duplicate this functionality in ESQL/C?

Answer: Use an ESQL/C Program to Unload Data

Write an ESQL/C program along the lines of this one:

strcpy (select_string, "SELECT field1, field2, ...FROM tablename WHERE ....")
$PREPARE my_statement from select_string;
$DECLARE my_cursor CURSOR for my_statement;

while ()
{
$FETCH my_cursor INTO variable1, variable2....;
if  ( sqlca.sqlcode != 0 )
       {
$CLOSE my_cursor;
$FREE my_cursor;
break;
       }

frprintf (stdout, "%s|%s|%s....\n", variable1, variable2....);
 }

Of course, you have to specify the select statement and declare and arrange the variables correctly, but this can allow you to achieve ...

Get Informix DBA Survival Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.