Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: [OT] SQL "on duplicate key" custom action

by erix (Prior)
on Oct 21, 2019 at 09:43 UTC ( [id://11107753]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    drop   table if exists testtable;
    create table           testtable (pk int primary key, foo text, bar te
    +xt);
    ...
    INSERT INTO testtable (pk, foo, bar) VALUES (1, 'Hello', 'World') ON C
    +ONFLICT (pk,foo,bar) DO NOTHING;
    INSERT INTO testtable (pk, foo, bar) VALUES (1, 'Hello', 'World') ON C
    +ONFLICT (pk,foo,bar) DO NOTHING;
    INSERT INTO testtable (pk, foo, bar) VALUES (1, 'Hello', 'Quz'  ) ON C
    +ONFLICT (pk,foo,bar) DO NOTHING;
    
  2. or download this
    drop   table if exists testtable;
    DROP TABLE
    ...
    INSERT INTO testtable (pk, foo, bar) VALUES (1, 'Hello', 'Quz'  ) ON C
    +ONFLICT (pk,foo,bar) DO NOTHING;
    ERROR:  duplicate key value violates unique constraint "testtable_pkey
    +"
    DETAIL:  Key (pk)=(1) already exists.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107753]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found