Thread: Q: ecpg and UPDATE/DELETE ... RETURNING ... for multiple returned rows

Q: ecpg and UPDATE/DELETE ... RETURNING ... for multiple returned rows

From
"Enke, Dr., Michael"
Date:

Hello experts,

I try to do an update together with a RETURNING clause but without success (postgresql 9.1 on CentOS 6.2),

the returned data can be multiple rows (not only one row expected like in src/interfaces/ecpg/test/sql/insupd.pgc):

 

1:

EXEC SQL DECLARE cur CURSOR FOR UPDATE t set a=0 where a=3 RETURNING b;

This fails (ecpg fails) with: ERROR: syntax error at or near "t”

 

2:

char *stmt = “UPDATE t set a=0 where a=3 RETURNING b”

EXEC SQL PREPARE stmt1 FROM :stmt;

EXEC SQL DECLARE cur CURSOR FOR stmt1;

This fails (sql fails in the server) with: syntax error at or near "UPDATE" at character 24

 

What is the proper way to do that in pgc or is this not possible?

 

Kind regards,

Michael

WINCOR NIXDORF International GmbH
Sitz der Gesellschaft: Paderborn
Registergericht Paderborn HRB 3507
Geschäftsführer: Eckard Heidloff (Vorsitzender), Dr. Jürgen Wunram
Vorsitzender des Aufsichtsrats: Karl-Heinz Stiller
Steuernummer: 339/5884/0020 - Ust-ID Nr.: DE812927716 - WEEE-Reg.-Nr. DE44477193

Diese E-Mail enthält vertrauliche Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail.
Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.

This e-mail may contain confidential information.
If you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail.
Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.