Re: SQL Script

From: "Eric G(dot) Miller" <egm2(at)jps(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL Script
Date: 2001-04-01 05:48:42
Message-ID: 20010331214842.A678@calico.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 30, 2001 at 06:50:15PM +0000, Kevin Willems wrote:
> I have written the following function but when I try to run it, I get Error:
> ERROR: parser: parse error at or near "". As you can see, there is no
> instance of "" in my function. Does anyone have any idea why this is
> happening?
>
> CREATE FUNCTION dropifexists(text)
> RETURNS text
> AS 'DECLARE
> numcount integer;
> nameoftable text;
> BEGIN
> nameoftable := lower($1);
> SELECT INTO numcount count(tablename)
> FROM pg_tables
> WHERE tablename = nameoftable;
>
> if numcount = 1
> then DROP TABLE nameoftable;
> end if;
> RETURN nameoftable;
> END;'

You forgot to add " LANGUAGE 'plpgsql'; " at the end (no dbl quotes).

--
Eric G. Miller <egm2(at)jps(dot)net>

In response to

  • SQL Script at 2001-03-30 18:50:15 from Kevin Willems

Browse pgsql-general by date

  From Date Subject
Next Message Eric G. Miller 2001-04-01 05:56:50 Re: SELECT MAX question
Previous Message Justin Clift 2001-04-01 05:27:39 Re: where does the -i go?