Skip to main content
Nov 18, 2013 3:03 PM UTC
Answered

BEGIN in SQL in AIR?

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 is closed to new replies. Start a new post to keep the conversation going.
A_Sad_SamCorrect answer
Inspiring
Nov 18, 2013 4:14 PM UTC

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

3 replies

A_Sad_SamCorrect answer
Inspiring
Nov 18, 2013 4:14 PM UTC

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

Translate
Nov 19, 2013 12:54 AM UTC

Thanks Sam!

Translate
Inspiring
Nov 19, 2013 8:37 AM UTC

You're welcome

Translate