Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

psycopg by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group