multi.update

/ Database / multi.update

Update Multi Query

Example:

[multi.update]
    start transaction;

      select @object_id:="[template.get object_id /]" from dual;
			select @coll_id:="[template.get coll_id /]" from dual;
      [loop.@meta template.meta]
        select @cnt:=count(1) from [template.get meta_table /] where object_id=@object_id and coll_id=@coll_id and meta_key="[aw2.get @meta.item.meta_key/]";
        insert into [template.get meta_table /](object_id,coll_id,coll_type,meta_key,meta_value,updated_by)
        select @object_id,@coll_id,"[aw2.get @meta.item.coll_type/]","[aw2.get @meta.item.meta_key/]","[aw2.get @meta.item.meta_value m.esc_sql=yes /]","[template.email /]" from dual where @cnt=0;
        update [template.get meta_table /] 
        set coll_type="[aw2.get @meta.item.coll_type/]",meta_value="[aw2.get @meta.item.meta_value m.esc_sql=yes /]",updated_by="[template.email /]",stamp=current_timestamp 
        where object_id=@object_id and coll_id=@coll_id and meta_key="[aw2.get @meta.item.meta_key/]" and @cnt=1;  
      [/loop.@meta]
      
    commit;
  [/multi.update]

 

Categories
Most Popular

Leave a Reply

Your email address will not be published.