[GENERAL] SQL Script

2001-03-31 Thread Kevin Willems

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;'




---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[GENERAL] Trouble with PL/pgSQL

2001-04-07 Thread Kevin Willems

I wrote the following test function:

CREATE FUNCTION tester(text)
RETURNS text
AS 'DECLARE
   str text;
BEGIN
   str := upper($1);
   RETURN str;
END;'
LANGUAGE'plpgsql'

This runs OK. However, when I go to use it as follows:

SELECT tester('sometext');

I get the error:

NOTICE: plpgsql: ERROR during compile of tester near line 1
"RROR: parse error at or near "

Does anyone know why this is happening? Any help would really be
appreciated.

- Kevin Willems



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html