Previous Thread
Next Thread
Print Thread
Getting duplicate count after INSERT statement #31379 07 Aug 19 08:38 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline OP
Member
OP Offline
Member
S
Joined: Jun 2001
Posts: 713
Using ASQL against a MySql database, I provide multiple sets of values in each INSERT statement. I am using the IGNORE clause to automatically drop duplicates. For example, if the combination of policy_id and endorsement_id is defined as UNIQUE:

mysql> INSERT IGNORE INTO production_tbl (policy_id,endorsement_id)
-> VALUES
-> ('14EA034E','00'),('14EA034E','00'),('14EA034E','00'),('14EA034E','01'),('14EA034E','02'),('14EA034E','03');

When invoked from the command line, MySQL returns a message like:

Query OK, 4 rows affected (0.01 sec)
Records: 6 Duplicates: 2 Warnings: 0

However, I am invoking these INSERTs from a program. I'd like to capture the number of Warnings and/or Duplicates resulting from each INSERT. Is there a way to do that with the standard SQL: functions?

-----

BTW: What happened to the "?" post icon?

Last edited by Steven Shatz; 07 Aug 19 08:43 PM.
Re: Getting duplicate count after INSERT statement [Re: Steven Shatz] #31391 08 Aug 19 02:47 PM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,794
At least in theory, the way to do this in ASQL is to use the SQLOP_GET_INFO call with the SQLINFO_QUERY flag after executing the query.

As for the "?" icon, I'm going to pass that on to the driving force behind this forum upgrade and see if he has any ideas.

Re: Getting duplicate count after INSERT statement [Re: Steven Shatz] #31418 13 Aug 19 09:29 PM
Joined: Jun 2001
Posts: 713
S
Steven Shatz Offline OP
Member
OP Offline
Member
S
Joined: Jun 2001
Posts: 713
Thanks, Jack. That worked!

Re: Getting duplicate count after INSERT statement [Re: Steven Shatz] #31419 14 Aug 19 12:08 AM
Joined: Jun 2001
Posts: 11,794
J
Jack McGregor Offline
Member
Offline
Member
J
Joined: Jun 2001
Posts: 11,794
It's tempting to say "I knew it would" (but I didn't).


Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3