SHARE
TWEET

Untitled

a guest Nov 14th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SET TERM ^ ;
  2.  
  3. CREATE OR ALTER procedure sp_insupd (
  4.     iaction varchar(3),
  5.     iusuario varchar(20),
  6.     iip varchar(15),
  7.     imodulo varchar(30),
  8.     ifieldsvalues varchar(2000),
  9.     iwhere varchar(1000),
  10.     idesclogs varchar(200))
  11. returns (
  12.     oid integer)
  13. as
  14. declare variable vdesc varchar(10000);
  15. begin
  16.   if (iaction = 'ins') then
  17.   begin
  18.     vdesc = idesclogs;
  19.  
  20.     /*** o erro está na linha abaixo ***/
  21.     execute statement 'insert into '||:imodulo||' '||:ifieldsvalues||' returning ID into '||:oid||';';
  22.   end else
  23.   if (iaction = 'upd') then
  24.   begin
  25.     execute statement 'select '||:idesclogs||' from '||:imodulo||' where '||:iwhere into :vdesc;
  26.  
  27.     execute statement 'execute procedure SP_CREATE_AUDIT('''||:imodulo||''');';
  28.  
  29.     execute statement 'update '||:imodulo||' set '||:ifieldsvalues||' where '||:iwhere||';';
  30.   end
  31.  
  32.   insert into LOGS(USUARIO, IP, MODULO, TIPO, DESCRICAO) values (
  33.   :iusuario, :iip, :imodulo, (case :iaction when 'ins' then 1 when 'upd' then 2 end), :vdesc);
  34. end^
  35.  
  36. SET TERM ; ^
  37.    
  38. ...
  39. execute statement 'insert into '||:imodulo||' '||:ifieldsvalues||';';
  40. ...
RAW Paste Data
Top