Search Postgresql Archives

procedure string constant is parsed at procedure create time.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi.
table "test" does not exist.

---1.this will work.
CREATE or replace PROCEDURE template_create() LANGUAGE SQL
AS $proc$ DROP TABLE if exists test cascade; CREATE TABLE test(id
int4range,valid_at tsrange,name text);$proc$;

----2.this will have errors.
CREATE or replace PROCEDURE template_create() LANGUAGE SQL AS $proc$
    DROP TABLE if exists test cascade;
    CREATE TABLE test(id int4range,valid_at tsrange,name text);
    INSERT INTO test VALUES (NULL, tsrange('2018-01-01',
'2019-01-01'), 'null key');
$proc$;

----3.language plpgsql works fine.
CREATE or replace PROCEDURE template_create()
LANGUAGE plpgsql AS $proc$
    begin
        DROP TABLE if exists test101 cascade;
        CREATE TABLE test101(id int4range,valid_at tsrange,name text);
        INSERT INTO test101 VALUES (NULL, tsrange('2018-01-01',
'2019-01-01'), 'null key');
    end
$proc$;

per manual: https://www.postgresql.org/docs/current/sql-createprocedure.html
"....This form only works for LANGUAGE SQL, the string constant form
works for all languages. This form is parsed at procedure definition
time, the string constant form is parsed at execution time...."

Why does the 2nd query fail? What am I missing?





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux