In PostgreSql procedure, I need to create a list of integers to use in a delete statement, as in the example:
DELETE FROM appointment_virtual WHERE appointment_id IN (list_delete);
I need help with:
How do I declare a list type variable?
I found the following form, but I was unsure if it serves the purpose of the DELETE statement:
list_delete integer ARRAY;
How do I add items to this list variable?
I found the following way:
list_delete = array_append (_delete, _appointment_id);
How to zero the contents of this list variable?
Is the syntax below correct?
list_delete = [];
Thanks any help!
[]is not correct. Use eitherARRAY[]or'{}'.WHEREclause: it's eitherappointment_id = ANY(list_delete)orappointment_id IN unnest(list_delete).INcannot be used with arrays. Useappointment_id = ANY(list_delete)instead.