Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id D23A49FB647 for ; Thu, 25 Jan 2007 15:34:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 74741-04 for ; Thu, 25 Jan 2007 15:34:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from relay00.pair.com (relay00.pair.com [209.68.5.9]) by postgresql.org (Postfix) with SMTP id 4467D9F9C1D for ; Thu, 25 Jan 2007 15:34:51 -0400 (AST) Received: (qmail 55372 invoked from network); 25 Jan 2007 19:34:47 -0000 Received: from 67.125.72.226 (HELO D9GKB4C1) (67.125.72.226) by relay00.pair.com with SMTP; 25 Jan 2007 19:34:47 -0000 X-pair-Authenticated: 67.125.72.226 From: "Gary Greenberg" To: Subject: Error while creating stored procedure through ODBC connection Date: Thu, 25 Jan 2007 11:35:12 -0800 Message-ID: <00df01c740b7$f08af5a0$b80a3c0a@D9GKB4C1> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00E0_01C74074.E267B5A0" X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcdAt+5wEu8AR5g9RsCvMGGbAqfB8Q== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.181 tagged_above=0 required=5 tests=AWL, BAYES_20, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200701/67 X-Sequence-Number: 8606 This is a multi-part message in MIME format. ------=_NextPart_000_00E0_01C74074.E267B5A0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I am trying to generate a database by running DDL script through the ODBC connection. It went through almost to the end and then barfed on creating procedure. Here is a snippet from the generation log: *** Executing statement 311: CREATE FUNCTION mask_new_permission () RETURNS trigger AS $mask_new_permission$ begin new.PERMISSION_MASK := coalesce(select 2*max(PERMISSION_MASK) from permissions, 1) *** Execution of statement failed: ERROR: unterminated dollar-quoted string at or near "$mask_new_permission$ begin new.PERMISSION_MASK := coalesce(select 2*max(PERMISSION_MASK) from permissions, 1)"; Error while executing the query SQLSTATE = 42601 *** Executing statement 312: return new *** Execution of statement failed: ERROR: syntax error at or near "return"; Error while executing the query SQLSTATE = 42601 *** Executing statement 313: end *** Statement successfully executed. *** Executing statement 314: $mask_new_permission$ LANGUAGE plpgsql *** Execution of statement failed: ERROR: unterminated dollar-quoted string at or near "$mask_new_permission$ LANGUAGE plpgsql"; Error while executing the query SQLSTATE = 42601 *** Executing statement 315: create trigger permissions_bit before insert on permissions for each row execute procedure mask_new_permission() *** Execution of statement failed: ERROR: function mask_new_permission() does not exist; Error while executing the query SQLSTATE = 42883 When I am executing the same piece of code from psql prompt it is going through without complaining: ops2=> CREATE FUNCTION mask_new_permission () RETURNS trigger AS $mask_new_permission$ ops2$> begin ops2$> new.PERMISSION_MASK := coalesce(select 2*max(PERMISSION_MASK) from permissions, 1); ops2$> return new; ops2$> end; ops2$> $mask_new_permission$ LANGUAGE plpgsql; CREATE FUNCTION ops2=> ops2=> ops2=> create trigger permissions_bit before insert on permissions ops2-> for each row execute procedure mask_new_permission(); CREATE TRIGGER Can anyone explain it to me, please? Thx, Gary BTW, ODBC driver is PSQLODBC30A.dll ------=_NextPart_000_00E0_01C74074.E267B5A0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I am trying to generate a database by running DDL = script through the ODBC connection.

It went through almost to the end and then barfed on creating procedure.

Here is a snippet from the generation = log:

*** Executing statement = 311:

CREATE FUNCTION mask_new_permission () RETURNS = trigger AS $mask_new_permission$

    begin

        new.PERMISSION_MASK :=3D coalesce(select 2*max(PERMISSION_MASK) from = permissions, 1)

*** Execution of statement = failed:

ERROR: unterminated dollar-quoted string at or near "$mask_new_permission$

    begin

        new.PERMISSION_MASK :=3D coalesce(select 2*max(PERMISSION_MASK) from = permissions, 1)";

Error while executing the = query

SQLSTATE =3D 42601

 

*** Executing statement = 312:

return new

*** Execution of statement = failed:

ERROR: syntax error at or near = "return";

Error while executing the = query

SQLSTATE =3D 42601

 

*** Executing statement = 313:

end

*** Statement successfully = executed.

 

*** Executing statement = 314:

$mask_new_permission$ LANGUAGE = plpgsql

*** Execution of statement = failed:

ERROR: unterminated dollar-quoted string at or near "$mask_new_permission$ LANGUAGE = plpgsql";

Error while executing the = query

SQLSTATE =3D 42601

 

*** Executing statement = 315:

create trigger permissions_bit before insert on = permissions

for each row execute procedure = mask_new_permission()

*** Execution of statement = failed:

ERROR: function mask_new_permission() does not = exist;

Error while executing the = query

SQLSTATE =3D 42883

 

 

When I am executing the same piece of code from psql = prompt it is going through without complaining:

ops2=3D> CREATE FUNCTION mask_new_permission () = RETURNS trigger AS $mask_new_permission$

ops2$>     = begin

ops2$>       &nb= sp; new.PERMISSION_MASK :=3D coalesce(select 2*max(PERMISSION_MASK) from = permissions, 1);

ops2$>       &nb= sp; return new;

ops2$>     = end;

ops2$> $mask_new_permission$ LANGUAGE = plpgsql;

CREATE FUNCTION

ops2=3D>

ops2=3D>

ops2=3D> create trigger permissions_bit before = insert on permissions

ops2-> for each row execute procedure mask_new_permission();

CREATE TRIGGER

 

Can anyone explain it to me, = please?

Thx,

         =    Gary

BTW, ODBC driver is = PSQLODBC30A.dll

------=_NextPart_000_00E0_01C74074.E267B5A0--