EXECUTE query INTO problem

From: Tk421 <vrobador(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: EXECUTE query INTO problem
Date: 2008-11-25 20:58:18
Message-ID: 492C66EA.4050008@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I've got a problem with a function: It receives two parameters, the
first, the table name, and the second, a where condition. The function
looks like this:

DECLARE
cod bigint;
query TEXT;

BEGIN
query = 'SELECT codigo FROM ' || $1 || ' WHERE ' || $2;

EXECUTE query INTO cod;
·
·
·
END;

I've alwais get the same error, in the EXECUTE sentence: it says:
Error at or near NULL at character X

I've also tried declaring cod as row, but the error is the same.

Anybody can help me?

Thank you very much

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Kretschmer 2008-11-25 21:16:59 Re: EXECUTE query INTO problem
Previous Message John Lister 2008-11-25 16:54:28 Re: Full text search ordering question