473,245 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

deleting a mysql record in active result

Hello,

I'm doing a select in wich I retrieve some values.

If the value is in an array, I must delete the record.

As I'm doing a "mysql_fetch_object", may I delete this record inside the
loop ?

when doing a mysql_query, do I have a "local" copy or just a link to the
mysql query result. In the first case I may delete the record as I get an
"image" of the query result, in the second case I shouldn't as the query
result will be changed by the deletion of any record.

Bob

Apr 12 '06 #1
5 1384
Bob Bedford wrote:
Hello,

I'm doing a select in wich I retrieve some values.

If the value is in an array, I must delete the record.

As I'm doing a "mysql_fetch_object", may I delete this record inside the
loop ?

when doing a mysql_query, do I have a "local" copy or just a link to the
mysql query result. In the first case I may delete the record as I get an
"image" of the query result, in the second case I shouldn't as the query
result will be changed by the deletion of any record.

Bob


Bob,

I'm not sure whether you can do it safely or not - I've never tried.

What I do is something I learned many, many moons ago when I was working on a
mainframe database (DB2). When I want to delete a row, I will save it's id in
an array. Then after I'm done with the result set, I go back and build a delete
command to get rid of all of them at one time. Or, you could issue several
delete commands to get rid of them individually.

It solves any potential problems which might result, especially if you change
databases (not likely - but who knows?).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 12 '06 #2
I always thought this was ok. It seems simple enough to test, but I
think reasoning can sort this out.

User A and B make same query at same time.

Query is 'select * from big_table limit 10';

Results are printed out for user A but user B deletes in of the 10 A
recieved whilst being called.

If the delete counts A no longer has 10 records, unless the sql is run
again. But then other changes could have happened, and the process
could repeat indefinately.

I'd say it would be as safe as houses. The only danger is you use the
same query resource and lose the loop, which is not a db issue but a
programming one.

Apr 13 '06 #3
fletch wrote:
I always thought this was ok. It seems simple enough to test, but I
think reasoning can sort this out.

User A and B make same query at same time.

Query is 'select * from big_table limit 10';

Results are printed out for user A but user B deletes in of the 10 A
recieved whilst being called.

If the delete counts A no longer has 10 records, unless the sql is run
again. But then other changes could have happened, and the process
could repeat indefinately.

I'd say it would be as safe as houses. The only danger is you use the
same query resource and lose the loop, which is not a db issue but a
programming one.


Fletch,

A completely different scenario. If A is holding locks on the rows, B will not
be able to delete them. However, as owner of the locks, A would still be able
to delete the rows.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 13 '06 #4
Hmmn. I'd not really thought of that. How to distinguish a from b
though? not db login, as user a and b are effectively the same program
run by a web server.

Apr 13 '06 #5
fletch wrote:
Hmmn. I'd not really thought of that. How to distinguish a from b
though? not db login, as user a and b are effectively the same program
run by a web server.


They'll be using different connections.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rob | last post by:
Thanks for the Help on the other problems...all resolved. One last (hopefullly) problem I can't seem to get around for this program...why isn't this deleting the row i want? It does nothing. Now...
3
by: Nathan Bloom | last post by:
Hi, I have a data entry form (access 2000) that also allows the user to add, update, and delete records from the form. The Delete action is carried out in an event procedure and has the...
46
by: DP | last post by:
hi, i've got a form, with a subform in it. i've got a delete button in the subform. the code i;ve got is; Private Sub cmdDeleteRecord_Click() msg = "Are you sure you want to delete this...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
1
by: webandwe | last post by:
Hi The code below I took from a postgre file and convert it with a program to a mysql. Once i tried to import it to mysql it gave me an error and when i past in a php file to upload it trough a...
0
Coldfire
by: Coldfire | last post by:
Since i cannot show the differences in a two-column like table. I am first putting MS SQL Server 2005 and then MySQL 5.x. MS SQL Server 2005 Brief Overview - SQL Server is a full-fledged...
6
by: keeps21 | last post by:
I'm having a bit of trouble creating a page to delete a story from the content table in my database. I have checked my DELETE query directly in phpmyadmin and it is working fine. I am echoing...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.