SQL If THEN - Mailing list psycopg

From Filipe Brandão
Subject SQL If THEN
Date
Msg-id CABH8U5mXXLOWFgFgv1-xq90LY-SJgrK5VHoWCDykrEbrBYG8Ng@mail.gmail.com
Whole thread Raw
Responses Re: SQL If THEN  (Adrian Klaver <adrian.klaver@gmail.com>)
Re: SQL If THEN  (Adrian Klaver <adrian.klaver@gmail.com>)
List 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!


psycopg by date:

Previous
From: Oswaldo
Date:
Subject: Re: insert into with a dictionary, or generally with a variable number of columns
Next
From: Adrian Klaver
Date:
Subject: Re: SQL If THEN