Unix Technical Forum

sqlstate 02000 while declaring cursor/freeing statement

This is a discussion on sqlstate 02000 while declaring cursor/freeing statement within the pgsql Admins forums, part of the PostgreSQL category; --> I'm new to the PostgreSQL community so please pardon what is probably a silly question ... I'm in the ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Admins

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 06:11 AM
andy rost
 
Posts: n/a
Default sqlstate 02000 while declaring cursor/freeing statement

I'm new to the PostgreSQL community so please pardon what is probably a
silly question ...

I'm in the process of porting Informix ESQL to PostgreSQL. I
occasionally get sqlcode = 100 and sqlstate = 02000 when declaring
cursors or freeing prepared statements. Is this normal? For example:

$declare loop1 cursor with hold for
select distinct ( tabname )
from meta ;

results in sqlca.sqlcode = 100 and sqlca.sqlstate = '02000'
--
--------------------------------------------------------------------------------
Andrew Rost
National Operational Hydrologic Remote Sensing Center (NOHRSC)
National Weather Service, NOAA
1735 Lake Dr. West, Chanhassen, MN 55317-8582
Voice: (952)361-6610 x 234
Fax: (952)361-6634
arost@nohrsc.nws.gov
http://www.nohrsc.nws.gov
--------------------------------------------------------------------------------



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 06:11 AM
Thomas F. O'Connell
 
Posts: n/a
Default Re: sqlstate 02000 while declaring cursor/freeing statement


On Aug 29, 2005, at 2:19 PM, andy rost wrote:

> I'm new to the PostgreSQL community so please pardon what is
> probably a silly question ...
>
> I'm in the process of porting Informix ESQL to PostgreSQL. I
> occasionally get sqlcode = 100 and sqlstate = 02000 when declaring
> cursors or freeing prepared statements. Is this normal? For example:
>
> $declare loop1 cursor with hold for
> select distinct ( tabname )
> from meta ;
>
> results in sqlca.sqlcode = 100 and sqlca.sqlstate = '02000'


Andy,

According to the docs, a positive value of sqlcode indicates a
harmless condition:

http://www.postgresql.org/docs/8.0/s...pg-errors.html

The sqlstate of 02000 looks like the NO DATA code:

http://www.postgresql.org/docs/8.0/s...-appendix.html

I don't see anything wrong with your cursor declaration, so this just
looks like it's indicating that no rows were returned.

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC

Strategic Open Source: Open Your i™

http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-469-5150
615-469-5151 (fax)
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 06:11 AM
Michael Fuhr
 
Posts: n/a
Default Re: sqlstate 02000 while declaring cursor/freeing statement

On Tue, Aug 30, 2005 at 09:01:36AM -0500, Thomas F. O'Connell wrote:
> On Aug 29, 2005, at 2:19 PM, andy rost wrote:
> >
> > $declare loop1 cursor with hold for
> > select distinct ( tabname )
> > from meta ;
> >
> >results in sqlca.sqlcode = 100 and sqlca.sqlstate = '02000'

>
> [snip]
>
> I don't see anything wrong with your cursor declaration, so this just
> looks like it's indicating that no rows were returned.


See my response to the same thread in pgsql-sql about what's
happening:

http://archives.postgresql.org/pgsql...8/msg00274.php

The ECPG code generator doesn't issue the DECLARE statement until
the cursor is opened, so checking sqlcode/sqlstate immediately after
DECLARE but before OPEN will get the error code values from a
previous command.

Here's an excerpt from the DECLARE documentation:

The PostgreSQL server does not implement an OPEN statement for
cursors; a cursor is considered to be open when it is declared.
However, ECPG, the embedded SQL preprocessor for PostgreSQL,
supports the standard SQL cursor conventions, including those
involving DECLARE and OPEN statements.

Since declaring a cursor in PostgreSQL also opens it, ECPG apparently
defers doing anything with the cursor until it finds the OPEN
statement (i.e., EXEC SQL DECLARE generates no code, and EXEC SQL
OPEN generates a DECLARE).

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 06:11 AM
andy rost
 
Posts: n/a
Default Re: sqlstate 02000 while declaring cursor/freeing statement

Just so that we can snip this thread, we've confirmed that free cursor
and free statement do not affect sqlca structure elements sqlcode and
sqlstate.

Michael Fuhr wrote:
> On Tue, Aug 30, 2005 at 09:01:36AM -0500, Thomas F. O'Connell wrote:
>
>>On Aug 29, 2005, at 2:19 PM, andy rost wrote:
>>
>>> $declare loop1 cursor with hold for
>>> select distinct ( tabname )
>>> from meta ;
>>>
>>>results in sqlca.sqlcode = 100 and sqlca.sqlstate = '02000'

>>
>>[snip]
>>
>>I don't see anything wrong with your cursor declaration, so this just
>>looks like it's indicating that no rows were returned.

>
>
> See my response to the same thread in pgsql-sql about what's
> happening:
>
> http://archives.postgresql.org/pgsql...8/msg00274.php
>
> The ECPG code generator doesn't issue the DECLARE statement until
> the cursor is opened, so checking sqlcode/sqlstate immediately after
> DECLARE but before OPEN will get the error code values from a
> previous command.
>
> Here's an excerpt from the DECLARE documentation:
>
> The PostgreSQL server does not implement an OPEN statement for
> cursors; a cursor is considered to be open when it is declared.
> However, ECPG, the embedded SQL preprocessor for PostgreSQL,
> supports the standard SQL cursor conventions, including those
> involving DECLARE and OPEN statements.
>
> Since declaring a cursor in PostgreSQL also opens it, ECPG apparently
> defers doing anything with the cursor until it finds the OPEN
> statement (i.e., EXEC SQL DECLARE generates no code, and EXEC SQL
> OPEN generates a DECLARE).
>


--
--------------------------------------------------------------------------------
Andrew Rost
National Operational Hydrologic Remote Sensing Center (NOHRSC)
National Weather Service, NOAA
1735 Lake Dr. West, Chanhassen, MN 55317-8582
Voice: (952)361-6610 x 234
Fax: (952)361-6634
arost@nohrsc.nws.gov
http://www.nohrsc.nws.gov
--------------------------------------------------------------------------------



---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:21 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com