Skip to content

Instantly share code, notes, and snippets.

@zguangyu
Created November 14, 2014 13:39
Show Gist options
  • Save zguangyu/c4fcd8318cd76c36cd88 to your computer and use it in GitHub Desktop.
Save zguangyu/c4fcd8318cd76c36cd88 to your computer and use it in GitHub Desktop.
ECPG Select Multiple lines into an array
#include <stdio.h>
int main()
{
int i;
EXEC SQL BEGIN DECLARE SECTION;
int db_tar_id[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO stars;
EXEC SQL SELECT tar_id INTO :db_tar_id FROM targets ORDER BY tar_id LIMIT 20;
for (i=0; i<20; i++)
printf("%d\n", db_tar_id[i]);
EXEC SQL COMMIT;
EXEC SQL DISCONNECT ALL;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment