Skip to main content
November 18, 2013
Answered

BEGIN in SQL in AIR?

  • November 18, 2013
  • 1 reply
  • 734 views

HI

I understand how to use the BEGIN and COMMIT listeners etc.

I was wondering if you can use BEGIN TRANSACTION and COMMIT around a bunch of SQL processes in a single string?

eg

"BEGIN TRANSACTION

CREATE INDEX IF NOT EXISTS idx1 ON table1 (Artist COLLATE NOCASE, Title COLLATE NOCASE);

CREATE INDEX IF NOT EXISTS idx2 ON table1 (Id, Date);

CREATE INDEX IF NOT EXISTS idx3 ON table1 (Time, Reason COLLATE NOCASE);

END TRANSACTION"

or do they all have to be separate statements, each with a listener?

I ask as I'm getting a "BEGIN is not allowed in SQL" error.

Cheers

This topic has been closed for replies.
Correct answer A_Sad_Sam

I don't think that's the correct way of using SQL transactions with AS3, try using the transaction methods of the SQLConnection class. Check out this link: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnection.html#begin(). It's very easy you just add sqlcon.begin() before you execute any statements, and use sqlcon.commit() after.

Hope I've been helpful

1 reply

A_Sad_SamCorrect answer
Inspiring
November 18, 2013

I don't think that's the correct way of using SQL transactions with AS3, try using the transaction methods of the SQLConnection class. Check out this link: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnection.html#begin(). It's very easy you just add sqlcon.begin() before you execute any statements, and use sqlcon.commit() after.

Hope I've been helpful

November 19, 2013

Thanks Sam!

Inspiring
November 19, 2013

You're welcome