Re: SQL problem
Posted in 1997
map@mms-dresden.telekom.de wrote:
>
> I use the Informix Online Dynamic Server 7.1 via ESQL... I created as
> table with several fields, also some CHARs (size 32000). Now I want to
> use an SQL request to insert values in these fields, also the big CHAR
> one. But every time I tried this one with sizes greater than 255
> characters, the database reports a syntax error in my SQL request. How
> can I insert long Strings with SQL and with ODS 7.1?
>
> Matthias
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
I U are inserting quoted string into a column , the maximum length of
the string is 256 bytes.
But using ESQlC U can insert . U have to use C variable to insert the
data
Here is sample code That workd for me
Create table like this
DATABASE adhocdb;
CREATE TABLE ttt ( d char(1024));
This is ESQLC to insert
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
EXEC SQL INCLUDE sqltypes;
EXEC SQL BEGIN DECLARE SECTION;
char data[1024];
EXEC SQL END DECLARE SECTION;
main()
{
memset(data,'x',1000);
data[1000]='\\0';
printf("%s",data);
EXEC SQL CONNECT TO 'adhocdb';
if (SQLSTATE[0] != '0' ||
(SQLSTATE[1] != '0' && SQLSTATE[1] != '1'))
{
printf("connect to database is failed\\n");
exit(1);
}
EXEC SQL
insert into ttt values(:data); if (strcmp(SQLSTATE, "00000"))
printf("Error In Declare Cursor\\n");
}
IF U still not clear give me more details of Ur programm/quiery
Thanks
BALA PEDDI
BOSTON
bala.peddi@fmr.com