SQL update with PL/sql function -
i have update 1 column in table ( requirement use function). have created simple function customer1 table. how can update table using function . there ways ?
create or replace function fn_easy (name_in in customer1.last_name%type) return customer1.first_name%type name_tab customer1.first_name%type; begin select first_name name_tab customer1 last_name = name_in; return name_tab; end fn_easy; update customer1 set first_name = fn_easy(customer1.last_name);
i understand need loop argument in function. 1 idea have through cursor. don't think optimal use cursor task when have 200 records.
your function ok, have ensure select inside returns 1 value, otherwise exception. if want select values array, use bulk collect into
. update column value using function, column value type must compatible function return type.
Comments
Post a Comment