Re: unload query???
Posted in 2000
Or just call dbaccess from your program:
sprintf(str,"dbaccess %s > &s 2>&1 << !\\n"
"unload to '%s' "
"select * from %s;\\n!",
db_name,
log_file,
unload_file,
tab_name);
system(str);
On 20 Mar 2000, at 16:50, mars1972@my-deja.com wrote:
> I wish it was something simple. Unfortunately, (and this question has
> come up before) you can't call unload from ESQL/C code. unload is not a
> standard SQL call. The only way to do this in a C program is:
>
> 1) If the program is static and doesn't need to be dynamic, you can
> create a structure copy of the table and fetch records into it and
> fprintf those records into the file.
>
> 2) If it does need to be dynamic, take a look at exec sql set
> descriptor. You can use this to figure out the table structure at
> runtime and use this information to print the records out. It will give
> you the data type and length of each column in order.
>
> Personally, I think you'd want to use option 2. Take a look at Informix
> ESQL/C programmers manual.
>
> > alright
> >
> > i've got this function:
> >
> > /* global */
> >
> > #define TABLE_ERROR (-206)
> > #define DUMP_PATH "/home/students/csse96/ksh/public_html/dumps/"
> >
> > EXEC SQL begin declare section;
> > char table_name[25];
> > char file_name[15];
> > EXEC SQL end declare section;
> >
> > static void dump_data()
> > {
> > EXEC SQL begin declare section;
> > char path[200];
> > EXEC SQL end declare section;
> >
> > /* file_name = test_dump */
> > /* table_name = staff_login */
> >
> > sprintf(path,"%s%s", DUMP_PATH, file_name);
> > trim(path);
> >
> > EXEC SQL unload to :path
> > select * from :table_name;> >
> > if (SQLCODE != TABLE_ERROR)
> > {
> > CHECK_SQL("dumping to file");
> > record_log("dump ok\\n");
> >
> > printf("<p>Dump successful</p>\\n");
> > printf("<p>Feel free to carry on browsing</p>\\n");
> > }
> > else
> > {
> > printf("<p>The specified table isn't in the
> > database</p><p>Go back and choose another</p>\\n");
> > record_log("Wrong table!\\n");
> > }
> >
> > }
> >
> > I get this error:
> >
> > esql -o backup.cgi -static backup.ec cgihtml.a
> > esqlc: "backup.ec", line 234: Error -33051: Syntax error on identifier
> > or symbol ':'.
> > 1 error(s) found
> > Exit 1
> >
> > the error is on the highlighted line.
> > i dunno whats goin on?
> > i've done finderr...but it doesn't help?
> > this is the only way i can think of doin a unload..... !
> > dbaccess is a bit gay round here!
> >
> > any ideas.... i know its something simple but i can't find it!
> >
> > cheers.
> >
> > from:
> >
> > A worried university student, who needs this to work
> >
> > for his final yr project demonstration!!
>
> --
> # unrm /
> ksh: unrm: not found
> # man cpio
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>