Skip to main content
November 18, 2013
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
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

3 replies

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

Translate
November 19, 2013

Thanks Sam!

Translate
Inspiring
November 19, 2013

You're welcome

Translate