to beckhambobo(beckham):
实际上我在数据库中需要调用一函数: Get_Value();
该函数不能通过select get_value() from dual 执行,
因为报错:
ORA-06571: 函数 GET_VALLUE 不能保证不更新数据库.
因为我不能更改原数据库函数。所以只能通过
declare
a boolean;
begin
a := Get_Value();
end;
执行该函数,我怎样才能取得该返回值那?
pl/sql过程不能返回值,若要取值,用函数返回
create function get_value
return number
as
begin
return 1;
end;
with adoconnection1 do
begin
adoquery.close;
adoquery.sql.clear;
adoquery.sql.add('create function get_value ');
adoquery.sql.add(return number as ');
adoquery.sql.add('begin ');
adoquery.sql.add(return 1;');
adoquery.sql.add('end;');
adoquery.execsql;
adoquery.sql.clear;
adoquery.sql.add('select get_value rs from dual');
adoquery.open;
.....
呵呵,如果在DELPHI中写的话,我认为不需要这样写的吧,你声明变量可以在DELPHI中声明呀,需要的时候再代入到你的SQL语句中去呀
var
a : integer;
begin
adoquery1.close;
adoquery1.sql.add('select * from table1 where fielda = :P_a');
adoquery1.parameters.parambyname('p_a').value := a;
adoquery1.open;
{...}
{如果需要循环取记录或是什么的话,你也可以在DELPHI中定义变量,在数据库中再代入}
end;