SQL If THEN

From: Filipe Brandão <fgbrandao(at)emepc-portugal(dot)org>
To: psycopg(at)postgresql(dot)org
Subject: SQL If THEN
Date: 2012-07-11 12:12:08
Message-ID: CABH8U5mXXLOWFgFgv1-xq90LY-SJgrK5VHoWCDykrEbrBYG8Ng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi all.

I was wondering if somenone can help me.
I needed to do a cursor.execute of a function writen in sql.
The function is:
cursor.execute("""BEGIN
IF (TG_OP = 'UPDATE') THEN
select NEW.test;
RETURN NEW;
END IF;
END;)""")

I always get an error message saying ProgrammingError: syntax error at or
near "IF"
is there a way to execute this function inside a python script?

Thanks!

Responses

Browse psycopg by date

  From Date Subject
Next Message Adrian Klaver 2012-07-11 13:29:06 Re: SQL If THEN
Previous Message Oswaldo 2012-07-04 09:11:11 Re: insert into with a dictionary, or generally with a variable number of columns