ITPub博客

首页 > Linux操作系统 > Linux操作系统 > name_in 和 copy 函数的用途

name_in 和 copy 函数的用途

原创 Linux操作系统 作者:kawontony 时间:2013-02-22 09:12:51 0 删除 编辑

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博客 ” ,链接:https://blog.itpub.net/24627116/viewspace-754485/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-17

  • 博文量
    183
  • 访问量
    433677