Implement multiple statements inside queries

Description

Lucee supports multiple statements in SQL queries:

queryExecute( " INSERT INTO myTable(...) VALUES (...); INSERT INTO myOtherTable(...) VALUES (...) " );

Activity

Show:

Michael Born @ Ortus August 8, 2024 at 2:00 PM
Edited

Are you saying you made updates, or this is already done? I left this ticket open because I’m not comfortable with the current implementation. With that said, it should work in many/most cases, but is not “BoxLang Quality” hence the need to rewrite.

Luis Majano August 8, 2024 at 12:56 AM

This should be done

John Wilson August 7, 2024 at 3:01 PM
Edited

We do a lot of this. It’s not unusual to have 3-5 statements in a single queryExecute().
-- transaction begin
-- copy existing records from original to history table
-- truncate original table
-- insert from temp table to original.
-- transaction commit

Luis Majano June 17, 2024 at 3:24 PM

Look into Statement

  • addBatch()

  • executeBatch()

Michael Born @ Ortus June 7, 2024 at 11:06 AM

I just realized we need to tweak this a bit. We’re currently returning the first query result, even if it’s empty… but we need to return the first result that has a non-empty ResultSet.

Here’s the (anonymized) query I found in some client code:

DECLARE @Inserted_ID_Table TABLE (FOO int NOT NULL); INSERT INTO MyTable (...) OUTPUT INSERTED.FOO INTO @Inserted_ID_Table VALUES ( ... ); SELECT FOO FROM @Inserted_ID_Table
Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Priority

Sentry

Created May 22, 2024 at 2:44 PM
Updated November 1, 2024 at 9:22 PM
Resolved June 5, 2024 at 9:31 PM

Flag notifications