How to do a Select for update?

This is the place to post technical queries about SQL Yoga

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, trevordevore

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 853
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

How to do a Select for update?

Post by trevordevore » Fri Oct 11, 2013 2:31 pm

[This post is an archive from the old SQL Yoga forums]

Hi,

I need update a records but previously I must block to avoid any modification until I finish some validations.

I have a table with product serials, I want select some of them to compare and do a validations and then update the previously selected records. If not, someone can pick up some of the serials that I'm working while I'm doing the same.

I know that I can do this with a Select for update?



How can manage this with SQL Yoga?



Salut,

Josep
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 853
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: How to do a Select for update?

Post by trevordevore » Fri Oct 11, 2013 2:31 pm

SQL Yoga doesn't have any special support built in for this type of scenario. What you could do is just create your SQL Query object, grab the full query using the "query" property and then append "FOR UPDATE" to the end. You could then execute the query using a call like dbconn_retrieveQueryAsArray.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 853
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: How to do a Select for update?

Post by trevordevore » Fri Oct 11, 2013 2:31 pm

But when release the records of the table? after perform a update? calling a commit after the update?
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 853
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: How to do a Select for update?

Post by trevordevore » Fri Oct 11, 2013 2:31 pm

I haven't done this before so I would recommend looking at the docs for the db you are using. You are just executing SQL statements at this point so just use dbconn_executeSQL to execute whatever the database requires to unlock the records.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

Post Reply

Return to “SQL Yoga”