[GENERAL] declare variable in udf

2012-11-21 Thread Peter Kroon
Hello, How do I declare a variable after BEGIN? I want to declare it in the if statement. DROP FUNCTION IF EXISTS tmp_test(integer); CREATE FUNCTION tmp_test( p_id integer ) RETURNS text AS $$ DECLARE the_return_value text; BEGIN DROP TABLE IF EXISTS temp_test_table; CREATE TEMP TABLE

Re: [GENERAL] declare variable in udf

2012-11-21 Thread Raymond O'Donnell
On 21/11/2012 11:42, Peter Kroon wrote: Hello, How do I declare a variable after BEGIN? I want to declare it in the if statement. DROP FUNCTION IF EXISTS tmp_test(integer); CREATE FUNCTION tmp_test( p_id integer ) RETURNS text AS $$ DECLARE the_return_value text; BEGIN DROP TABLE

Re: [GENERAL] declare variable in udf

2012-11-21 Thread Peter Kroon
So, multiple DECLARE sections are not allowed? 2012/11/21 Raymond O'Donnell r...@iol.ie On 21/11/2012 11:42, Peter Kroon wrote: Hello, How do I declare a variable after BEGIN? I want to declare it in the if statement. DROP FUNCTION IF EXISTS tmp_test(integer); CREATE FUNCTION

Re: [GENERAL] declare variable in udf

2012-11-21 Thread Pavel Stehule
2012/11/21 Peter Kroon plakr...@gmail.com: So, multiple DECLARE sections are not allowed? it is not allowed in plpgsql resp. DECLARE is related to block - if you use nested block, then you can use nested DECLAREs Regards Pavel Stehule 2012/11/21 Raymond O'Donnell r...@iol.ie On

Re: [GENERAL] declare variable in udf

2012-11-21 Thread Raymond O'Donnell
On 21/11/2012 12:01, Peter Kroon wrote: So, multiple DECLARE sections are not allowed? Actually, I just had a quick look here - http://www.postgresql.org/docs/9.2/static/plpgsql-structure.html - and it seems that you can have multiple declare - begin - end blocks. Try it and see! Ray. --