Re: newbie pl/pgsql question on trigger function error

From: Mark Gibson <gibsonm(at)cromwell(dot)co(dot)uk>
To: Wei Wang <ww220(at)cam(dot)ac(dot)uk>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: newbie pl/pgsql question on trigger function error
Date: 2004-02-10 09:08:33
Message-ID: 40289F91.3030002@cromwell.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Wei Wang wrote:

>ERROR: syntax error at or near ";" at character 32
>CONTEXT: PL/pgSQL function "trigtest_test1" line 26 at execute statement
>
> --create a table with the name as NEW.tablename, and the first
>column
> --called arg1 and the type to be the value of NEW.arg1
> my_query := ''create table ''
> ||quote_ident(NEW.tablename)
> ||'' ( ''
> ||quote_ident(NEW.arg1)
> ||'', arg1 );'';
>
>

Look closely at the CREATE TABLE statement.

It's all higgledeepiggledee!

Try this:

my_query := ''create table '' || quote_ident(NEW.tablename)
|| '' ( arg1 '' || quote_ident(NEW.arg1) || '');'';

--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Muteki Fong 2004-02-10 09:23:25 pg_class relfilenode
Previous Message JM 2004-02-10 08:47:58 Re: fsync = true beneficial on ext3?