SELECT INTO returns incorrect values

From: Bill Todd <pg(at)dbginc(dot)com>
To: PgSQL General <pgsql-general(at)postgresql(dot)org>
Subject: SELECT INTO returns incorrect values
Date: 2008-08-30 02:46:28
Message-ID: 48B8B484.1030808@dbginc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The following SELECT INTO returns incorrect values in the variables
CATEGORY_NAME and PARENT_ID. If I copy the SELECT statement to pgAdmin,
delete the INTO clause and run the query it returns the correct values.
I am new to PostgreSQL and I must have something syntactically wrong in
the SELECT but I can't see what it is. Any suggestions?

DECLARE
PARENT_ID BIGINT;
CATEGORY_NAME VARCHAR(40);
BEGIN
SELECT CATEGORY, PARENT_CATEGORY_ID
INTO CATEGORY_NAME, PARENT_ID
FROM NOTE.CATEGORY
WHERE CATEGORY_ID = 477;
RAISE NOTICE 'CURR CAT, NAME, PARENT ID: % % ', CATEGORY_NAME,
PARENT_ID;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE

Thanks,

Bill

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-08-30 02:58:34 Re: Indexing problem with OFFSET LIMIT
Previous Message Merlin Moncure 2008-08-30 02:11:12 Re: Indexing problem with OFFSET LIMIT