dbTalk Databases Forums  

FOUND variable and execute

comp.databases.postgresql comp.databases.postgresql


Discuss FOUND variable and execute in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
news
 
Posts: n/a

Default FOUND variable and execute - 02-17-2010 , 03:51 AM






Hi,here:
http://www.postgresql.org/docs/8.3/s...tatements.html
I can read that the FOUND variable it is set by any plain sql statement,
plus perform, fetch, move. Nothing it is said about execute.
Do I deduce that execute .. into does not set FOUND?

Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: FOUND variable and execute - 02-22-2010 , 05:25 AM






news wrote:
Quote:
http://www.postgresql.org/docs/8.3/s...tatements.html
I can read that the FOUND variable it is set by any plain sql statement, plus perform, fetch, move. Nothing it is said about
execute.
Do I deduce that execute .. into does not set FOUND?
Correct. Example:

test=> CREATE TABLE test_table (id integer);
CREATE TABLE
test=> INSERT INTO test_table VALUES (1), (2);
INSERT 0 2

test=> CREATE OR REPLACE FUNCTION test_found() RETURNS boolean LANGUAGE plpgsql AS
test-> $$BEGIN
test$> EXECUTE 'SELECT * FROM test_table';
test$> RETURN FOUND;
test$> END;$$;
CREATE FUNCTION

test=> SELECT test_found();
test_found
------------
f
(1 row)


Use
GET DIAGNOSTICS integer_var = ROW_COUNT;
instead, see
http://www.postgresql.org/docs/curre...TS-DIAGNOSTICS

Yours,
Laurenz Albe

Reply With Quote
  #3  
Old   
Mladen Gogala
 
Posts: n/a

Default Re: FOUND variable and execute - 02-22-2010 , 12:58 PM



On Mon, 22 Feb 2010 12:25:37 +0100, Laurenz Albe wrote:

Quote:
news wrote:
http://www.postgresql.org/docs/8.3/s...tatements.html I can
read that the FOUND variable it is set by any plain sql statement, plus
perform, fetch, move. Nothing it is said about execute.
Do I deduce that execute .. into does not set FOUND?

Correct. Example:

test=> CREATE TABLE test_table (id integer); CREATE TABLE
test=> INSERT INTO test_table VALUES (1), (2); INSERT 0 2

test=> CREATE OR REPLACE FUNCTION test_found() RETURNS boolean LANGUAGE
plpgsql AS test-> $$BEGIN
test$> EXECUTE 'SELECT * FROM test_table'; test$> RETURN FOUND;
test$> END;$$;
CREATE FUNCTION

test=> SELECT test_found();
test_found
------------
f
(1 row)


Use
GET DIAGNOSTICS integer_var = ROW_COUNT;
instead, see
http://www.postgresql.org/docs/current/static/plpgsql-
statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

Yours,
Laurenz Albe
My understanding is that FOUND is set only after "SELECT INTO".

http://www.faqs.org/docs/ppbook/x19832.htm
http://tinyurl.com/ybqs9bv

I am not sure where does the idea of using "FOUND" after "execute" comes
from?

--
http://mgogala.byethost5.com

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.