Questions tagged [rows-affected]

The number of rows affected by executing a SQL Query

The number of rows affected by executing a SQL Query.

The @@ROWCOUNT variable will return the number of rows affected by the last executed query in SQL Server

65 questions
3
votes
3 answers

Delphi - TADOQuery.RowsAffected always -1 with UPDATE SQL statement

I'm executing a SQL UPDATE statement using a TADOQuery component and want to inspect the number of rows that were updated. The UPDATE statement is executing fine and the rows are modified accordingly but the .RowsAffected property always returns…
Jonathan Wareham
  • 3,357
  • 7
  • 46
  • 82
2
votes
5 answers

How to test if a MySQL query was successful in modifying database table data?

I have the following simple php code snippet, which will, when called, delete a relevant article from a database. The result is passed to a javascript function, which will update the page via AJAX. I would like to return the string false if the…
Joshxtothe4
  • 4,061
  • 10
  • 53
  • 83
2
votes
1 answer

How to return number rows affected on multiple inserts with Mysqli Php?

I have a function which inserts multiple rows using the MySqli library with prepared statements. The inserts works great, the problem is the build in $stmt->affected_rows method always returns the number of affected rows as 1. Now to move around…
Hmerman6006
  • 1,622
  • 1
  • 20
  • 45
2
votes
3 answers

MySQL get all affected rows for multiple statements in one query

MySQL/PHP: For a query with multiple statements, which deletes rows in four different tables, I want to know the combined number of affected rows. The PHP manual says I'll only get the result from the last 'operation', which suggests it will only…
Wytze
  • 7,844
  • 8
  • 49
  • 62
2
votes
2 answers

$mysqli->affected_rows returns 0 multi_query

I have simple code. This query works fine. It works directly through sql and from php too (changed $mysqli->query to $mysqli->multi_query to make it work from php) but it $mysqli->affected_rows return 0. There are actually inserted rows and when I…
M.G.
  • 129
  • 7
2
votes
1 answer

Netbeans Xdebug: mysqli_affected_rows returns "-1" when it should be "1"

I'm puzzled why the following code successfully adds a new row to my database table while mysqli_affected_rows($dbc) returns "-1", thus an error, in signup.php: dbc.inc.php : DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', ''); DEFINE ('DB_HOST',…
Pingui
  • 1,312
  • 4
  • 15
  • 28
2
votes
2 answers

mySQLi_affected_rows check not working, or is it...?

(Sorry, I don't really know what I am doing.) I have this Unity game in an iframe on Facebook calling a php file in the same directory, and that much is working. What I want it to do is update the player record if it is there and make one if it…
blerg
  • 159
  • 3
  • 10
2
votes
1 answer

What is Oracle equivalent of mysql_affected_rows?

In Mysql, If we insert,delete or update data then by using mysql_affected_rows(), we will get No. of rows affected & same we can use in PHP to store it in a variable. So What is Oracle equivalent of mysql_affected_rows? How can we get No. of rows…
Prat
  • 519
  • 5
  • 16
  • 33
2
votes
2 answers

Get result occur from update statement inside stored procedures

I want to check the existance of specific record in db table, if it's exist then update if not I want to add new record I am using stored procedures to do so, First I make update stetement and want to check if it occurs and return 0 then there's no…
palAlaa
  • 9,500
  • 33
  • 107
  • 166
1
vote
2 answers

sql stored procedure not working(no rows affected)

trying to get this stored procedure to work. ALTER PROCEDURE [team1].[add_testimonial] -- Add the parameters for the stored procedure here @currentTestimonialDate char(10),@currentTestimonialContent varchar(512),@currentTestimonialOriginator…
1
vote
1 answer

Codeigniter: mysql transaction and affected_rows

I need to do multiple insert/update so i came up with transaction to roll back if anything goes wrong. Besides, my application should update the record if already exists, and insert if not. So first of all i try to update a record using a unique id,…
Luciano
  • 1,455
  • 8
  • 22
  • 52
1
vote
1 answer

Updating Columns that previously held a value of NULL with a Value doesn't trigger Affected Rows?

I am updating Columns in Rows in a Table. Previously these Columns were set to NULL. After an UPDATE the columns now have data in them. But 'affected_rows' remains 0? Any ideas why? $query = $conn->prepare("UPDATE table …
Cranberry
  • 11
  • 4
1
vote
1 answer

Count number of affected rows over several queries passed to MySql in java code

I would count the number of rows affected by the query provided as a prepared statement in java passed to a MySql engine. Given the following sample queries passed to a prepared statement, I need to be able to count the total number of rows affected…
Vahid133
  • 13
  • 4
1
vote
0 answers

Count the affected rows on insert

I'm trying to get the affected rows on insert. I've seen some solution on how to do it but I don't know how to apply it on my code. I'm using spring boot and I haven't mastered it yet. This is my sample…
trumanblack1025
  • 471
  • 2
  • 8
  • 19
1
vote
0 answers

mysqli_affected_rows not counting correctly when

At first, I have got the following: $sql="SELECT sum(importe_subproyecto) as importe_total FROM presupuestos_pmt WHERE oferta_numero = '$oferta_numero'"; $result = mysqli_query($con,$sql); while ($row = mysqli_fetch_assoc($result)) { …
alberzyzz
  • 277
  • 2
  • 15