Re: declare variable in udf
От | Peter Kroon |
---|---|
Тема | Re: declare variable in udf |
Дата | |
Msg-id | CAOh+DOn1fVWK5F4k1pGOo8y4BKjr3BBEQy1OMDATT+Ls05QCkw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: declare variable in udf (Raymond O'Donnell <rod@iol.ie>) |
Ответы |
Re: declare variable in udf
Re: declare variable in udf |
Список | pgsql-general |
So, multiple DECLARE sections are not allowed?
2012/11/21 Raymond O'Donnell <rod@iol.ie>
I don't think that is possible - you have to declare all your variablesOn 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 IF EXISTS temp_test_table;
> CREATE TEMP TABLE temp_test_table(
> some_value text
> );
> INSERT INTO temp_test_table
> SELECT data FROM table WHERE id=p_id;
> SELECT INTO the_return_value some_value FROM temp_test_table;
>
> IF 1=1 THEN
> --how do I declare a variable here? it this possible?
> RAISE NOTICE 'this is a notice';
> END IF;
>
> RETURN the_return_value;
>
> END;
> $$ language plpgsql
in the DECLARE section.
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie
В списке pgsql-general по дате отправления: