[Fwd: plpgsql and booleans?]

Started by Christopher Kings-Lynneabout 22 years ago3 messageshackers
Jump to latest
#1Christopher Kings-Lynne
chriskl@familyhealth.com.au

Hi guys,

When writing a PL/pgSQL trigger function how do you handle the case :

EXECUTE ''UPDATE test_table SET test_col '' ||
quote_literal(NEW.test_col2) || '';'';

where test_col and test_col2 are boolean fields?

The case above gives :
ERROR: function quote_literal(boolean) does not exist

And without the quote_literal() gives :
ERROR: operator does not exist: text || boolean

Is there supposed to be a quote_literal() for booleans?

Chris

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christopher Kings-Lynne (#1)
Re: [Fwd: plpgsql and booleans?]

Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:

When writing a PL/pgSQL trigger function how do you handle the case :

EXECUTE ''UPDATE test_table SET test_col '' ||
quote_literal(NEW.test_col2) || '';'';

Seems it'd be easier without EXECUTE:

UPDATE test_table SET test_col = NEW.test_col2;

regards, tom lane

#3Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Tom Lane (#2)
Re: [Fwd: plpgsql and booleans?]

EXECUTE ''UPDATE test_table SET test_col '' ||
quote_literal(NEW.test_col2) || '';'';

Seems it'd be easier without EXECUTE:

UPDATE test_table SET test_col = NEW.test_col2;

Actually, yes you're right - we don't need EXECUTE in our case.
However, it still doesn't answer the question of how you use
quote_literal on a boolean value?

Chris