[英]How to migrate an Oracle PL/SQL procedure to PostgreSQL
我需要将Oracle存储过程(PL / SQL)迁移到PostgreSQL(pl / pgsql)。 我不知道该怎么做。
Procedure Check_File ( strLine in varchar2 , lngRecord in number ) is
type tab_str is table of varchar2(500) index by binary_integer;
tabline tab_str;
intp1 integer;
intp2 integer;
intsize integer;
begin
-- Split line into table
intp1 := 1 ;
intp2 := instr ( strline , ';' , intp1 ) ;
intsize := 0;
while intp2 != 0 loop
intsize := intsize + 1 ;
tabline(intsize) := trim(substr ( strLine , intp1 , intp2-intp1 ));
intp1 := intp2 + 1 ;
intp2 := instr ( strline , ';' , intp1 ) ;
end loop;
intsize := intsize + 1 ;
tabline(intsize) := trim(substr ( strLine , intp1 ));
if intsize <> 23 then
utl_file.put_line ( olog , 'Block - Record ' || lngRecord || ' - Incorrect number of fields') ;
raise oExcept;
end if;
end;
这就是我所做的:
CREATE OR REPLACE FUNCTION Check_File ( strLine in text , lngRecord in bigint ) RETURNS VOID AS $body$
DECLARE
intp1 integer;
intp2 integer;
intsize integer;
-- CREATE TYPE tab_str AS (tab2 text[]);
tabline tab_str;
BEGIN
-- Split line into table
intp1 := 1 ;
intp2 := instr ( strline , ';' , intp1 ) ;
intsize := 0;
while intp2 != 0 loop
intsize := intsize + 1 ;
tabline(intsize) := trim(substring(strLine from intp1 for intp2-intp1 ));
intp1 := intp2 + 1 ;
intp2 := instr ( strline , ';' , intp1 ) ;
end loop;
intsize := intsize + 1 ;
tabline(intsize) := trim(substring(strLine from intp1 ));
if intsize <> 23 then
utl_file.put_line ( olog , 'Block - Record ' || lngRecord || ' - Incorrect number of fields') ;
raise oExcept;
end if;
END;
$body$
LANGUAGE PLPGSQL;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.