Обсуждение: SQLCODE==-209

Поиск
Список
Период
Сортировка

SQLCODE==-209

От
John Summerfield
Дата:
I'm using 7.2devel from CVS, and as I've already reported, the documentation doesn't build.

Consequently I'm forced to rely on documentation for 7.1.2/3 which does not mention -209, at least in the ecpg
documentationI'm looking at, 

Nore does it appear in the DB2 documentation I'm using as second recourse.

The error text doesn't mean anything to me either:
Search name(/var/share/pgtest/testdata)
Error in statement 'check filename':
 sqlcaid(SQLCA   ) sqlabc(140) sqlcode(-209)  msg(NULL value without indicator in line 121.)
sqlerrp(NOT SET ) OID(%) NROWS(%)
sqlwarn() sqlext()

sql error NULL value without indicator in line 121.
pgtest@possum c$


Here is the relevant code:
        exec sql begin declare section;
        char *name = fileName;
        int  i_filesize;
        int  i_records = transactionRecords;
        exec sql end declare section;
        struct stat fileinfo;
        if (-1 == stat(name,&fileinfo))
        {
            fprintf(stderr, "Error checking file info for %s: %s\n",
                name, strerror(errno));
        }
        i_filesize=fileinfo.st_size;
        printf("name(%s), size(%d) records(%d)\n",name, i_filesize, i_records);
        exec sql insert into tsj0601_loaded_files
            (name, filesize, records)
            values (
                :name,
                :i_filesize,
                :i_records
                );


What I hope for is
a) An explanation as to what's wrong
b) Someone to ensure that it's documented, or correct the code if it should be some other number.

Re: SQLCODE==-209

От
Peter Eisentraut
Дата:
John Summerfield writes:

> I'm using 7.2devel from CVS, and as I've already reported, the documentation doesn't build.

http://www.ca.postgresql.org/devel-corner/docs/postgres/index.html

> Consequently I'm forced to rely on documentation for 7.1.2/3 which
> does not mention -209, at least in the ecpg documentation I'm looking
> at,

7.2 doesn't document it either...

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter

Re: SQLCODE==-209

От
Peter Eisentraut
Дата:
John Summerfield writes:

> I don't normally have web access.

You can download the built documentation from

ftp://ftp.de.postgresql.org/pub/dev/doc/

Copy the files man.tar.gz and postgres.tar.gz into the doc/ directory of
your source distribution and they will be installed automatically.

> I'd much prefer the build instructions include how to build the
> documentation.

cd doc/src/sgml
make postgres.html

Requires OpenJade 1.3, DocBook DTD 3.1, and DocBook DSSSL stylesheets 1.70
or so, plus the knowledge of how to set all of this up, which in turn can
be obtained from the documentation.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter

Re: SQLCODE==-209

От
John Summerfield
Дата:
Sorry all. There was a certain amount of nonsence in my previous posting on this topic.

The failing sql command is an fact a select into.

It fails when trying to retrieve a null value. The insert worked (I can retrieve the record
if I don't ask for the null field, so evidently the insert code is correct.

-209 is generated by ecpg.

I still don't know what "indicator" means though.

If I can reasonably be expected to understand the term, there still remains the bug that -209
is undocumented.

Re: SQLCODE==-209

От
John Summerfield
Дата:
On Thu, 13 Sep 2001, Peter Eisentraut wrote:


> John Summerfield writes:
>
> > I'm using 7.2devel from CVS, and as I've already reported, the documentation doesn't build.
>
> http://www.ca.postgresql.org/devel-corner/docs/postgres/index.html

I don't normally have web access. I'd much prefer the build instructions include how to build the documentation.

>
> > Consequently I'm forced to rely on documentation for 7.1.2/3 which
> > does not mention -209, at least in the ecpg documentation I'm looking
> > at,
>
> 7.2 doesn't document it either...
>
>

I've not had anyone explain what it means yet. I've resorted to examining source code (while it might be the utimate
documentation,it's not ideal). I've found several places it can arise, but I still have no idea what the error is. 


The key seems to be the meaning of the technical term "indicator."


On a related matter, (I know it's related because it comes from the code which fails with this error), I think the code
generatedby ecpg is wrong: 

        /* exec sql begin declare section */




#line 134 "yahoo.load.pgc"
   char * name  = fileName ;

#line 135 "yahoo.load.pgc"
   int  i_filesize   ;

#line 136 "yahoo.load.pgc"
   int  i_records  = transactionRecords ;
/* exec sql end declare section */
#line 137 "yahoo.load.pgc"

        struct stat fileinfo;
        if (-1 == stat(name,&fileinfo))
        {
            fprintf(stderr, "Error checking file info for %s: %s\n",
                name, strerror(errno));
        }
        i_filesize=fileinfo.st_size;
        printf("name(%s), size(%d) records(%d)\n",name, i_filesize, i_records);






{ ECPGdo(__LINE__, NULL, "insert into tsj0601_loaded_files ( name  , filesize  , records  ) values ( ? , ? , ? )",
    ECPGt_char,&(name),0L,1L,1*sizeof(char),  <---- whoops
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
    ECPGt_int,&(i_filesize),1L,1L,sizeof(int),
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
    ECPGt_int,&(i_records),1L,1L,sizeof(int),
    ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
#line 152 "yahoo.load.pgc"


I think this is not going to pick up the string *name. Either ecpg should reject this, or generate something like

        ECPGt_char,(name),0L,1L,1*strlen(name))

but then I'm not much of a C programmer.

I'm going to assume that my definition of name offends ecpg and gives rise to the error -209, and try to work round it
(Ihave another insert working). 

Re: SQLCODE==-209

От
Bruce Momjian
Дата:
I have added documentation for code 209.  Looks like there are other
undocumented ones.  Should we document them all?

> John Summerfield writes:
>
> > I'm using 7.2devel from CVS, and as I've already reported, the documentation doesn't build.
>
> http://www.ca.postgresql.org/devel-corner/docs/postgres/index.html
>
> > Consequently I'm forced to rely on documentation for 7.1.2/3 which
> > does not mention -209, at least in the ecpg documentation I'm looking
> > at,
>
> 7.2 doesn't document it either...
>
> --
> Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: doc/src/sgml/ecpg.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ecpg.sgml,v
retrieving revision 1.23
diff -c -r1.23 ecpg.sgml
*** doc/src/sgml/ecpg.sgml    2001/09/13 15:55:22    1.23
--- doc/src/sgml/ecpg.sgml    2001/10/11 20:04:49
***************
*** 332,337 ****
--- 332,347 ----
        </varlistentry>

        <varlistentry>
+        <term><computeroutput>-209, NULL value without indicator in line %d.</computeroutput></term>
+        <listitem>
+     <para>
+      <productname>Postgres</productname> returned <symbol>ECPG_MISSING_INDICATOR</symbol>
+      because a NULL was returned and no NULL indicator variable was supplied.
+     </para>
+        </listitem>
+       </varlistentry>
+
+       <varlistentry>
         <term><computeroutput>-220, No such connection %s in line %d.</computeroutput></term>
         <listitem>
      <para>

Re: SQLCODE==-209

От
Bruce Momjian
Дата:
> On Thu, 11 Oct 2001, Bruce Momjian wrote:
>
>
> >
> > I have added documentation for code 209.  Looks like there are other
> > undocumented ones.  Should we document them all?
>
> If you're asking me, I'm all in favour of documenting them;-)
>
> I'm not a fan of "Read the source," though I do it if I'm desperate.

I can easily document them all if it would help people.  Seems you can't
really test error codes in your app unless you know the codes.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: SQLCODE==-209

От
John Summerfield
Дата:
On Thu, 11 Oct 2001, Bruce Momjian wrote:


>
> I have added documentation for code 209.  Looks like there are other
> undocumented ones.  Should we document them all?

If you're asking me, I'm all in favour of documenting them;-)

I'm not a fan of "Read the source," though I do it if I'm desperate.