Linked Questions

5 votes
1 answer
23k views

I'm trying to do a MERGE in PostgreSQL 9.5 and I get the following error: ERROR: syntax error at or near "MERGE" LINE 1: MERGE INTO TP_ESTADO_EQUIPOS AS EQ ^ ********** Error ********** ...
Levi Arista's user avatar
5 votes
1 answer
11k views

I have many rows of data to be inserted into a table. Table already has data in it. When I do a bulk insert like this, INSERT INTO permission(username, permission) values(('john','ticket_view'), ('...
Velu narasimman's user avatar
1 vote
1 answer
10k views

Possible Duplicate: Insert, on duplicate update (postgresql) Cannot SELECT from UPDATE RETURNING clause in postgres Help to understand me syntax error. I try to make such implementation of ...
potapuff's user avatar
  • 2,050
0 votes
1 answer
5k views

I am trying to batch insert or update rows to a database in one postgres statement depending on whether the ID already exists in the table or not. I will be updating/inserting 100 or more rows at the ...
Adrian's user avatar
  • 85
1 vote
1 answer
8k views

I've implemented simple update/insert query like this: -- NOTE: :time is replaced in real code, ids are placed statically for example purposes -- set status_id=1 to existing rows, update others ...
Dalibor Filus's user avatar
2 votes
2 answers
5k views

I would really like to write a query like this: INSERT INTO test_table (id, dt, amt) VALUES(4, current_timestamp, 15) ON CONFLICT (id) DO UPDATE SET dt = VALUES(dt) amt = VALUES(amt) The ...
user3685285's user avatar
  • 6,726
0 votes
3 answers
3k views

Could someone explain the if exist command that is used in SQL? for example: if exist(select * from waiter){ update waiter set (...) where waiter_id='somevalue' } else{ insert into waiter ...
user3192435's user avatar
2 votes
1 answer
3k views

I am new to postgres and i'm am having to populate a database using it. I cant submit my actual code for reference but my program is in java and i'm trying to do something along these lines. IF ...
Jeremy's user avatar
  • 975
1 vote
1 answer
3k views

Possible Duplicate: Insert, on duplicate update (postgresql) Is this possible on PostgreSQL: insert record, if the record doesn't exists else update existing record Supposedly that the record ...
Mike Montesines's user avatar
3 votes
1 answer
3k views

In my postgresql DB, I have a table "my_table" with primary key on columns (a, b). I wrote the query below for inserts into this table which ensures that the primary key constraint is never violated. ...
Vijay Kansal's user avatar
0 votes
1 answer
3k views

I have a table tab with columns: userid, usercode, value I'm writing a plpgsql function that update/insert the table. In case userid & usercode exists I need to update value In case they don't I ...
quack's user avatar
  • 383
2 votes
2 answers
982 views

I asked this last night, and got information on merging (which is unavailable in postgresql). I'm willing to try the workaround suggested But I'm just trying to understand why it can't be done with ...
1252748's user avatar
  • 15.5k
0 votes
0 answers
2k views

I want to create a merge query so that I can insert the new incoming record and update the record if there is any change in record. I created a query as: MERGE into sales AS TARGET USING sales1 AS ...
dharmesh mehta's user avatar
0 votes
1 answer
1k views

Is there an "update if not exists insert" function in Redshift, like replace in MySQL? If not, what should I do instead?
user3600910's user avatar
  • 3,159
-1 votes
1 answer
479 views

Im converting my php app to work with postgresql instead of mysql. Before I had this function using PDO: $stmt = $db->prepare("INSERT INTO $table(id,name,info) VALUES(:id,:name,:info) ON ...
Tomas Jacobsen's user avatar

15 30 50 per page
1
2 3 4 5
9