Project

General

Profile

Using SQL RETURNING in Session.query or Session.execute

Added by Gavin Blakeman almost 2 years ago

I am trying to execute an SQL statement to:
INSERT INTO stockMovements (TransactionType_ID, Status_ID, ShortText, ExtendedText, PO_ID, Account_ID, TransactionDate) VALUES (1, 8, 'test', '', 0, '9f36fe0f1fa449fe964a853e3e559398', '20220501') RETURNING ID

This is done by using a Session.Query ie

session.querystd::int32_t(the statement above);

I have also tried

session.query(the statement above);

This gives a runtime error "Wt: fatal error: Error parsing SQL query: the SQL statement above

When I cut the statement from the terminal I am using and run it directly on the server through the mariadb command line, it executes correctly and returns the ID (primary key) of the just inserted value.

Is there a workaround to this?

System: Ubuntu 20.04
MariaDB 10.7.3
Compiler: GCC