** 如何在ABAP里面通过Native SQL实现Oracle的函数创建与调用、存储过程的创建与调用、游标 **
REPORT z_barry_test NO STANDARD PAGE HEADING .
DATA: str1(128),str2(128),str3(128).
***创建函数
EXEC SQL.
create or replace function fun_barrytest (p1_in varchar2,p2_in varchar2)
return varchar2
is
p3_out varchar2(64);
begin
p3_out := p1_in||p2_in ;
return(p3_out);
end fun_barrytest;
ENDEXEC.
***调用函数
str2 = '123' .str3 = 'abc'.
EXEC SQL.
select fun_barrytest(:str2,:str3) from dual into :str1
ENDEXEC.
WRITE :str1 .
***游标的使用
str1 = 'AA'.
DATA: connid TYPE spfli-connid,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto.
EXEC SQL.
OPEN dbcur FOR
SELECT connid, cityfrom, cityto
FROM spfli
WHERE carrid = :str1
ENDEXEC.
DO.
EXEC SQL.
FETCH NEXT dbcur INTO :connid, :cityfrom, :cityto
ENDEXEC.
IF sy-subrc <> 0.
EXIT.
ELSE.
WRITE: / connid,cityfrom,cityto .
ENDIF.
ENDDO.
EXEC SQL.
CLOSE dbcur
ENDEXEC.
阅读(5150) | 评论(1) | 转发(0) |