>>>>> "Hengky" == Hengky Lie <hengkyliwandouw@xxxxxxxxx> writes: Hengky> Hi, Hengky> I want to create a function to update my table (flag='9') and Hengky> insert new record (flag='0') with the rfidnumber specified in a Hengky> parameter. rfidnumber is stored as text/varchar? if it's something else, change the suggestions below accordingly. Hengky> This parameter may have several value seperated by space (ie. Hengky> 11 22 33 44) update ... and rfidnumber = any (string_to_array(znumber,' ')) Or, do the split just once: DECLARE z_ids text[] := string_to_array(znumber, ' '); BEGIN update ... where flag='0' and rfidnumber =any (z_ids); insert into ... select localtimestamp, '0', id from unnest(z_ids) as u(id); -- Andrew (irc:RhodiumToad)