-608 error when trying to insert a TEXT value
Posted in 2012
An ESQL/C program inserting a TEXT value from memory (loc_t locator with LOCMEMORY, loc_buffer, loc_size) kept failing with SQL error -608. Jonathan Leffler posted a small self-contained test case that worked for him, notably declaring the locator fully zero-initialised (loc_t text_lob = {0}) and also setting loc_bufsize to avoid a -451 error; John Miller likewise asked whether the whole structure had been zeroed. The poster found his headers exposed only ifx_loc_t, which produced an "illegal use of record/structure" warning, and he got it working by including locator and adding 'typedef ifx_loc_t loc_t;'.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: General Discussion
Here is the schema of the table that I'm trying to insert into: Column name Type Nulls bctc_no serial no txt text yes ctc_no integer yes Code is below: #define BLOB_SIZE 32000 char szBlobText[BLOB_SIZE + 1]; text_lob.loc_loctype = LOCMEMORY; text_lob.loc_buffer = szBlobText; text_lob.loc_size = BLOB_SIZE; //text_lob.loc_type = SQLTEXT; EXEC SQL insert into ctc_blob (txt,ctc_no) values (:text_lob,:iCtcNo);
On Thu, Jul 19, 2012 at 7:46 AM, JOHN CALLICOTTE <john.callicotte@ottawa.edu
> wrote:
> Here is the schema of the table that I'm trying to insert into:
>
> Column name Type Nulls
>
> bctc_no serial no
> txt text yes
> ctc_no integer yes
>
> Code is below:
>
> #define BLOB_SIZE 32000
>
> char szBlobText[BLOB_SIZE + 1];
>
> text_lob.loc_loctype = LOCMEMORY;
> text_lob.loc_buffer = szBlobText;
> text_lob.loc_size = BLOB_SIZE;
> //text_lob.loc_type = SQLTEXT;
> EXEC SQL insert into ctc_blob (txt,ctc_no) values (:text_lob,:iCtcNo);
>
Here is a SSCCE (http://sscce.org/) based on the information above. It
works for me -- does it work for you? (Tested on Mac OS X 10.7.4 with IDS
11.70.FC2 -- I must upgrade!)
#include "locator.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
$ char *dbase = "stores";
$ loc_t text_lob = { 0 };
$ int4 iCtcNo = 37;
$ whenever error stop; /* Brutal but effective */
if (argc == 2)
dbase = argv[1];
$ connect to :dbase;
$ CREATE TEMP TABLE ctc_blob (
bctc_no serial not null,
txt text in table,
ctc_no integer not null
);
#define BLOB_SIZE 32000
char szBlobText[BLOB_SIZE + 1];
memset(szBlobText, 'A', sizeof(szBlobText));
szBlobText[sizeof(szBlobText)-1] = '\\\\0'; /* Not strictly necessary */
text_lob.loc_loctype = LOCMEMORY;
text_lob.loc_buffer = szBlobText;
text_lob.loc_size = BLOB_SIZE;
text_lob.loc_bufsize = BLOB_SIZE; /* Extra (to avoid -451 error) */
//text_lob.loc_type = SQLTEXT;
EXEC SQL insert into ctc_blob (txt,ctc_no) values (:text_lob,:iCtcNo);
printf("Insert OK (sqlca.sqlcode = %d)\\
", (int)sqlca.sqlcode);
}
You can use your normal DB if you change the table name systematically.
You can make the table permanent and then use other tools (DB-Access etc)
to verify that what was inserted was what you expected (a seriously boring
epic story about the character 'A').
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2011.0612 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
--f46d04016b1f712f1d04c5302696
I had to make two changes: 1) EXEC SQL include locator; and 2) ifx_loc_t instead of loc_t I used the following command to compile and link: /opt/informix/bin/esql -o fake -I/opt/informix/incl -I/opt/informix/incl/esqlc fake.ec It compiled, and linked, and I got this: Program stopped by WHENEVER STOP sqlca: sqlcode:-608 sqlerrm: '' sqlerrp: '' sqlerrd: sqlerrd(1)=1 (2)=0 (3)=0 (4)=0 (5)=51 (6)=0 sqlwarn.sqlwarn0: .sqlwarn1: .sqlwarn2: .sqlwarn3: .sqlwarn4: .sqlwarn5: .sqlwarn6: .sqlwarn7:
Also, when I compile using ifx_loc_t I get the warning: esqlc: "fake.ec", line 11: Warning -33014: Illegal use of record/structure 'ifx_loc_t'.
I finally got it to work by adding: typedef ifx_loc_t loc_t; Thanks for everyone's help!
Did you initialize the entire text_lib structure to 0? John F. Miller III STSM, Embedability Architect miller3@us.ibm.com 503-578-5645 IBM Informix Dynamic Server (IDS) ids-bounces@iiug.org wrote on 07/19/2012 07:46:34 AM: > From: "JOHN CALLICOTTE" <john.callicotte@ottawa.edu> > To: ids@iiug.org > Date: 07/19/2012 07:50 AM > Subject: -608 error when trying to insert a TEXT value [27698] > Sent by: ids-bounces@iiug.org > > Here is the schema of the table that I'm trying to insert into: > > Column name Type Nulls > > bctc_no serial no > txt text yes > ctc_no integer yes > > Code is below: > > #define BLOB_SIZE 32000 > > char szBlobText[BLOB_SIZE + 1]; > > text_lob.loc_loctype = LOCMEMORY; > text_lob.loc_buffer = szBlobText; > text_lob.loc_size = BLOB_SIZE; > //text_lob.loc_type = SQLTEXT; > EXEC SQL insert into ctc_blob (txt,ctc_no) values (:text_lob,:iCtcNo); > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. >
On Thu, Jul 19, 2012 at 7:46 AM, JOHN CALLICOTTE <john.callicotte@ottawa.edu
> wrote:
> Here is the schema of the table that I'm trying to insert into:
>
> Column name Type Nulls
>
> bctc_no serial no
> txt text yes
> ctc_no integer yes
>
> Code is below:
>
> #define BLOB_SIZE 32000
>
> char szBlobText[BLOB_SIZE + 1];
>
> text_lob.loc_loctype = LOCMEMORY;
> text_lob.loc_buffer = szBlobText;
> text_lob.loc_size = BLOB_SIZE;
> //text_lob.loc_type = SQLTEXT;
> EXEC SQL insert into ctc_blob (txt,ctc_no) values (:text_lob,:iCtcNo);
>
Here is a SSCCE (http://sscce.org/) based on the information above. It
works for me -- does it work for you? (Tested on Mac OS X 10.7.4 with IDS
11.70.FC2 -- I must upgrade!)
#include "locator.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
$ char *dbase = "stores";
$ loc_t text_lob = { 0 };
$ int4 iCtcNo = 37;
$ whenever error stop; /* Brutal but effective */
if (argc == 2)
dbase = argv[1];
$ connect to :dbase;
$ CREATE TEMP TABLE ctc_blob (
bctc_no serial not null,
txt text in table,
ctc_no integer not null
);
#define BLOB_SIZE 32000
char szBlobText[BLOB_SIZE + 1];
memset(szBlobText, 'A', sizeof(szBlobText));
szBlobText[sizeof(szBlobText)-1] = '\\\\0'; /* Not strictly necessary */
text_lob.loc_loctype = LOCMEMORY;
text_lob.loc_buffer = szBlobText;
text_lob.loc_size = BLOB_SIZE;
text_lob.loc_bufsize = BLOB_SIZE; /* Extra (to avoid -451 error) */
//text_lob.loc_type = SQLTEXT;
EXEC SQL insert into ctc_blob (txt,ctc_no) values (:text_lob,:iCtcNo);
printf("Insert OK (sqlca.sqlcode = %d)\\
", (int)sqlca.sqlcode);
}
You can use your normal DB if you change the table name systematically.
You can make the table permanent and then use other tools (DB-Access etc)
to verify that what was inserted was what you expected (a seriously boring
epic story about the character 'A').
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2011.0612 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
--e89a8f22c34f473cf904c5336fd7