By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE TABLE
ERROR: null value in column "foo_id" violates not-null constraint DETAIL: Failing row contains (1, testing, null).
INSERT 0 4
| id | type |
|---|---|
| 1 | red |
| 2 | purple |
| 3 | blue |
SELECT 3
| id | description | foo_id |
|---|---|---|
| 2 | testing | 3 |
| 3 | new row2 | 2 |
| 4 | new row1 | 2 |
| 5 | another row | 1 |
SELECT 4
CREATE TYPE
CREATE FUNCTION
| f_insert_foobar |
|---|
| null |
SELECT 1
| id | type |
|---|---|
| 1 | red |
| 2 | purple |
| 3 | blue |
| 4 | green |
SELECT 4
| id | description | foo_id |
|---|---|---|
| 2 | testing | 3 |
| 4 | new row1 | 2 |
| 5 | another row | 1 |
| 3 | new row2 | 4 |
| 10 | with,comma | 4 |
SELECT 5