![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
The id column is the primary key. The val column is a unique column that stores the value of a record. What I want to do is, that if I try to insert a value already present in the table, I want to increment the cnt column for that record by one insted of getting an error. |
#3
| |||
| |||
|
|
I have been looking around in the documentation for the solution to my problem, but I have found nothing. I have a table lik this: test=# \d foo; Table "public.foo" Column | Type | Modifiers -------+------------------------+------------------------------------ id | integer | not null default | | nextval('foo_id_seq'::regclass) val | character varying(255) | not null cnt | integer | default 1 Indexes: "foo_pkey" PRIMARY KEY, btree (id) "foo_val_key" UNIQUE, btree (val) The id column is the primary key. The val column is a unique column that stores the value of a record. What I want to do is, that if I try to insert a value already present in the table, I want to increment the cnt column for that record by one insted of getting an error. Does anybody know how to do this? |
![]() |
| Thread Tools | |
| Display Modes | |
| |