unload query???
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Migration, Import/Export & Data Conversion
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!!
Hi!
Someone asked a similar question a couple of weeks ago.
The answer was that "unload" is not really a SQL command, but
it is processed internally by dbaccess and 4gl. Search this newsgroup
for more info. Also a utility program was suggested.
HTH
Michael
Kalveer S Heer wrote:
> 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!!
>
>
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.
Unload is not suported by ESQL-C, you will have to take the long way, open a
file pointer, select into a variable, write to file pointer for each record
and close it. Sorry
Kalveer S Heer wrote in message <38D64704.A321E29D@cs.bham.ac.uk>...
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!!