Delete many records with several conditions

This is the place to post technical queries about SQL Yoga

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, trevordevore

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

Delete many records with several conditions

Post by trevordevore » Fri Oct 11, 2013 1:45 pm

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

Hi,

I trying to delete many records at same time and with more of one fields conditions.

For example all the records that the NUMBER is XX and ID_CUSTOMER is YY.

I have this, but no records are deleted...

Code: Select all

put sqlrecord_createObject("DOCUMENT") into theRecordA

sqlrecord_set theRecordA, "NUMBER",gNumDoc

sqlrecord_set theRecordA, "ID_CUSTOMER",gCustomerID

sqlrecord_delete theRecordA
What is wrong?

Salut,

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

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

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

Re: Delete many records with several conditions

Post by trevordevore » Fri Oct 11, 2013 1:48 pm

sqlrecord_delete only deletes records based on the value of the primary key defined for the table.

You want to use sqlquery_delete to perform a delete using arbitrary conditions.

Also, when troubleshooting it is a good idea to look at the query begin generated using the plugin. The query being generated can sometimes give you an idea of what SQL Yoga is doing behind the scenes.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “SQL Yoga”