Update or remove value Vertica -


i have next sql structure table:

id |  account_id  | app_id |  setting  |  value  

example data:

  1 | 8fb38bac-6896-49e8-ac92-4cf6300ccd6f | 1      | recipients | taras@gmail.com   2 | 8fb38bac-6896-49e8-ac92-4cf6300ccd6f | 1      | day        | monday   3 | 8fb38bac-6896-49e8-ac92-4cf6300ccd6f | 1      | count      | 1234 

and need update data if send new value or remove if don't exist in request db.

if sending (recipients, day, count) new value update existing data, if send (recipients, day) update data , remove count.

i try use next code:

 update settings  set setting='count', value='1'  account_id='8fb38bac-6896-49e8-ac92-4cf6300ccd6f' , app_id='1'; 

but script update field in table. how fix it?

from input , looks lots of values in table have same value account_id , app_id , hence when running script, updating values.

if want update rows count in settings, -

update settings  set value='1'  account_id='8fb38bac-6896-49e8-ac92-4cf6300ccd6f' , app_id='1' , setting='count' , (value not null , value <> ''); 

to remove row

delete settings account_id='8fb38bac-6896-49e8-ac92-4cf6300ccd6f' , app_id='1' , setting='count' , (value null or value = ''); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -