name_in 和 copy 函数的用途

name_in和copy函数都是为了实现间接引用;如:

if :emp.ename:='tony' --direct referenc

fi name_in('emp.ename'):='tony' ---indirect reference

:emp.ename:='tony' --direct reference

copy('tony','emp.ename') --indirect reference

解释:Referencing items indirectly allows you to write more generic, reusable code. By using variables in place of actual item naMES, you can write a subprogram that can operate on any item whose name has been assigned to the indicated variable.

If you nest the NAME_IN function, Form. Builder evaluates the individual NAME_IN functions from the innermost one to the outermost one.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

library is not saved within form. but in different file, so there is no where to find :frm1.txt1

for example, if you have a procedure in library:

procedure p1( v_one varchar2)

-----name_in(v_one) to get the value inside v_one, that is :frm1.txt1, so:

copy('value', name_in(v_one)) ==> to copy value to the txt field txt1 in form. frm1.

you can't use:

copy('value', :frm1.txt1), nor you can:

copy('value', v_one).

另外: Name_In()可以用来间接引用一些系统函数。例: var t_form. varchar2(50):=Name_In(‘system.current_form’);

NAME_IN 实现宏定义的例子:

FUNCTION FUN_JF (PRE_BLOCK_NAME
IN VARCHAR) RETURN BOOLEAN IS
BEGIN
if name_in(pre_block_name'sj.dwjtc')>name_in(pre_block_name'yj.dwjtc') then
mesSage(' 测试!');
return false;
end if;
return true;
END;
-- PRE_BLOCK_NAME 是形参,实际调用时,通过Name_in()函数来实现变量宏替换成FORMS.ITEM。

COPY 实现宏定义的例子:

BEGIN

DELCATE
strItemName varchar2(20);
BEGIN
for I in 1 …6 loop
strItemName:=':b.l"to_char(i);
copy(null,strItemName); --strItemName 由变量宏替换成Forms 中Item。
end loop;
END;

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

转载于:http://blog.itpub.net/24627116/viewspace-754485/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值