Search Postgresql Archives

Re: Function Question

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

 



Jake Stride <jake@xxxxxxxxxxxx> writes:
> I am trying to create a function that gets fired when a new row is
> inserted. I can get the following function built but my problem is
> that the sequence that is created is called "NEW.key" rather than the
> value that is being inserted (it should be a UUID).

Instead of this:

> 			CREATE SEQUENCE \"NEW.key\";

you need to do something like this:

			EXECUTE 'CREATE SEQUENCE ' || quote_ident(NEW.key);

The reason is that utility statements don't accept parameters natively,
so you have to construct the command as a string and then EXECUTE it.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[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 Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux