系统平台:
Linux x86-64 Red Hat Enterprise Linux 7
版本:
4.5
Oracle的函数迁移到瀚高数据库,应用程序调用瀚高数据库的函数时,提示“com.highgo.jdbc.util.PSQLException:错误: 字段 "sql" 不存在”的错误。
经调查,在Oracle中使用了sql%rowcount,获取更新或者删除语句的修改行数。
该语法在瀚高数据库中不兼容,需要单独修改。
在瀚高数据库中使用get diagnostics rowcnt := row_count;语句替代sql%rowcount,同样也是获取更新或者删除语句的修改行数。
示例如下:
Oracle:
|
create table t1(id numeric,sname varchar(10),primary key(id));
create or replace function testfnc return number
as
n number;
begin
insert into t1 values(1,'zhao');
n:=sql%rowcount;
commit;
dbms_output.put_line(n);
return 0;
end; |
测试结果:
执行函数后,输出行数是1


检索t1表的数据,插入了1条记录

瀚高:
|
create table t1(id numeric,sname varchar(10),primary key(id));
create or replace function testfnc() returns numeric
language plpgsql
as
$body$
declare
n numeric;
begin
insert into t1 values(1,'zhao');
--n:=sql%rowcount;
get diagnostics n := row_count;
raise notice '%',n;
return 0;
end;
$body$ |
测试结果:
执行函数后,输出行数是1

检索t1表的数据,插入了1条记录

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69994931/viewspace-2864585/
,如需转载,请注明出处,否则将追究法律责任。