[GENERAL] unique constraint with several null values

2016-07-20 Thread Mark Lybarger
I have a relation such as create table order_item ( id uuid not null primary key, order_id number not null, item_code text, make text, model text, reason text, size text, expiration_date timestamp ); where the combination of the columns order_id, item_code, make, model, reason, size must be unique

[GENERAL] foreign key with where clause

2016-08-18 Thread Mark Lybarger
I have two tables that i want to link with a FK where the child table record is "active". some googling shows that i could use a function and a check constraint on the function, but that only works for inserts, not updates on table b. create table a (int id, text name); create table b (int id, bo

[GENERAL] update records to have occurance number

2016-10-25 Thread Mark Lybarger
I want to update a table to have the value of the occurrence number. For instance, I have the below table. I want to update the number column to increment the count of last name occurrences, so that it looks like this: first last 1 second last 2 third last 3 first other 1 next other 2 Here's my

[GENERAL] multiple sql results to shell

2017-10-23 Thread Mark Lybarger
I have this bash/sql script which outputs some curl commands. the backticks causes it to get interpreted by the shell. This works fine if there is one result, but when there are many rows returned, it looks like one shell command. any help on getting multiple rows returned to be executed by the