[ERROR] syntax error at end of input

Started by Marcelo de Moraes Serpaover 18 years ago3 messagesgeneral
Jump to latest
#1Marcelo de Moraes Serpa
celoserpa@gmail.com

Hello list,

I'm trying to execute the following sentences in a pl/pgsql function.
aNomeProcAudita and pTabAudit are both variables.

DROP FUNCTION IF EXISTS aNomeProcAudita;
DROP TRIGGER IF EXISTS 'Audita_' || pTabAudit || '_trigger';

When I try to create this function without these two sentences, everything
goes ok, however, when I've got these two sql senteces, I get the following
error:

ERROR: syntax error at end of input

Is there anything wrong with the code?

Thanks in advance,

Marcelo.

#2A. Kretschmer
andreas.kretschmer@schollglas.com
In reply to: Marcelo de Moraes Serpa (#1)
Re: [ERROR] syntax error at end of input

am Mon, dem 27.08.2007, um 9:40:45 -0300 mailte Marcelo de Moraes Serpa folgendes:

Hello list,

I'm trying to execute the following sentences in a pl/pgsql function.
aNomeProcAudita and pTabAudit are both variables.

DROP FUNCTION IF EXISTS aNomeProcAudita;

Which version? DROP object IF EXISTS is a new feature since 8.2. Do you
have 8.2?

DROP TRIGGER IF EXISTS 'Audita_' || pTabAudit || '_trigger';

I guess you need to rewrite this to use EXECUTE for dynamic querys like
this.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marcelo de Moraes Serpa (#1)
Re: [ERROR] syntax error at end of input

"Marcelo de Moraes Serpa" <celoserpa@gmail.com> writes:

DROP FUNCTION IF EXISTS aNomeProcAudita;
DROP TRIGGER IF EXISTS 'Audita_' || pTabAudit || '_trigger';

Neither of those match the documented syntax for the commands: you have
left off required information. Also, as Andreas noted, if you want to
construct a name dynamically then you have to use EXECUTE. The second
one should go something like

EXECUTE 'DROP TRIGGER IF EXISTS Audita_' || pTabAudit || '_trigger ON ' || tableName;

regards, tom lane