I have problems with inserting records into DB by the C program that
uses ECPG interface. I am using 7.1.2 in Mandrake 8.0.
Sometimes it abnormally terminates with segmentation violation and sometimes
it produces the following SQL error message:
------
SQL: error [-400] 'ERROR: parser: parse error at or near "^Y"' in line 768.
------
The source code (.pcg) near this line looks like:
------ exec sql INSERT INTO rdr_meas ( name, loc, ts, devstat, meastat, relative,
level, ullage, levelrate, volume ) VALUES ( :name, :loc, :ts, :devstat, :meastat, :relative, :level,
:ullage, :rate, :volume ) ;
-------
and it is translated to .c as:
{ ECPGdo(__LINE__, NULL, "insert into rdr_meas ( name , loc , ts , devstat , meastat , relative , level , ullage
,levelrate , volume ) values (
? , ? , ? , ? , ? , ? , ? , ? , ? , ? )", ECPGt_char,(name),9L,1L,9*sizeof(char), ECPGt_NO_INDICATOR, NULL
,0L, 0L, 0L, ECPGt_char,(loc),9L,1L,9*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(ts),32L,1L,32*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_unsigned_int,&(devstat),1L,1L,sizeof(unsignedint), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_unsigned_int,&(meastat),1L,1L,sizeof(unsignedint), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_float,&(relative),1L,1L,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_float,&(level),1L,1L,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_float,&(ullage),1L,1L,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_float,&(rate),1L,1L,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_float,&(volume),1L,1L,sizeof(float), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
#line 768 "dbi.pgc"
---------------
The rdr_meas table was created as:
CREATE TABLE "rdr_meas" ( "seq" integer DEFAULT nextval('rdr_meas_serial_seq'::text) NOT NULL, "name"
character(8)NOT NULL, "loc" character(8) NOT NULL, "ts" timestamp with time zone NOT NULL, "devstat"
integerNOT NULL, "meastat" integer NOT NULL, "relative" real, "level" real, "ullage" real,
"levelrate" real, "volume" real, Constraint "rdr_meas_pkey" Primary Key ("seq")
);
----------------
Sql declare section is:
---------------- exec sql begin declare section; unsigned int seq; /* sequential */ char name[9];
/* radar unique name */ char loc[9]; /* radar location */ char ts[32]; /*
timestamp*/ unsigned int devstat; /* device status */ unsigned int meastat; /* measurement status */
floatrelative; /* relative volume */ float level; /* fluid level */ float ullage;
/* fluid ullage */ float rate; /* level change rate */ float volume; /*
volume*/ exec sql end declare section;
-----------------
name, loc and ts during the program execution is always filled with zero
terminated string.
AND FINAL QUESTION
What is the problem with insertion of long records and why ECPG reports
parsing error near not exisiting "^Y" string?
Regards
Edward Pilipczuk