Re: SQL Script

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Kevin Willems <kdwillems(at)hotmail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL Script
Date: 2001-04-01 10:47:06
Message-ID: Pine.LNX.4.30.0104011246120.1308-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Kevin Willems writes:

> 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?

"" means 'empty string', which often indicates end of input.

>
> 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're missing LANGUAGE '...' here.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/

From pgsql-general-owner(at)postgresql(dot)org Sun Apr 1 06:44:32 2001

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 Konstantinos Agouros 2001-04-01 10:50:51 7.0.X-> 7.1 dump/restore required?
Previous Message Peter Eisentraut 2001-04-01 10:42:42 Re: Need PostgreSQL startup scripts