Solved

Name_In and COPY built in

Posted on 2004-10-05
2
4,388 Views
Last Modified: 2013-12-12
I am still unable to understand what is the purpose of above buit ins. what are the problems if I am not using them.

Please give some example as teacher.

Thanks

0
Comment
Question by:hyynes
2 Comments
 
LVL 22

Accepted Solution

by:
Helena Marková earned 25 total points
ID: 12225727
I think that the purpose of these built-ins is well described in the on-line help: "About indirectly referencing parameters".

You cannot use bind variable syntax to refer directly to a parameter in a trigger, user-named routine, menu command, or stored procedure that is not declared in the same module as the parameter itself.

I have found on Metalink a nice example of using NAME_IN:

Example
-------
To capture the rowid of the record in the current block,concatenate '.ROWID' column to :SYSTEM.CURRENT_BLOCK,a system variable which stores the name of the block
that the cursor is in.

Apply the NAME_IN built-in to return the value of the concatenated variable:

NAME_IN(:SYSTEM.CURRENT_BLOCK || '.ROWID');

Create the following sample code:

DECLARE

v_rowid VARCHAR2(30);

/* v_rowid ROWID; */

BEGIN

v_rowid := NAME_IN(:SYSTEM.CURRENT_BLOCK || '.ROWID');

END;
----- end of example from Metalink

Of course you can write also
 v_rowid := :blockname.ROWID;
but if you want to create a function and call it anywhere then it is necessary to use NAME_IN:

FUNCTION MY_FUNC RETURN VARCHAR2 IS
  v_rowid VARCHAR2(30);
BEGIN
  v_rowid := NAME_IN(:SYSTEM.CURRENT_BLOCK || '.ROWID');
  RETURN v_rowid;
END  MY_FUNC;

I hope this will be a little help for you.
0
 
LVL 8

Assisted Solution

by:sapnam
sapnam earned 25 total points
ID: 12227746
This is how we use NAME_IN.  We have several forms in which we have a header block and we have a detail block.  The detail block has debit and credit amounts.  The header block also has an amount.  We have to display total debit and total credit for the document during entry (before commit).  The names of the header and detail blocks change from one form to another.  So we have written a program unit TOTAL to which we pass the names of the header and detail block and use the NAME_IN built in to get the amounts and display the total.
as under

Procedure total (detail char,master char,dtl_flag char,dtl_val char,hdr_val char) IS
  tmp_sum1 NUMBER(13,2);
  tmp_sum2 NUMBER(13,2);
BEGIN
  tmp_sum1 := NVL(TO_NUMBER(NAME_IN(hdr_val)),0);  -- 99 level amount
  tmp_sum2 := 0;
  GO_BLOCK(detail);
  FIRST_RECORD;
  LOOP
     IF NAME_IN(DTL_FLAG) = 'C' THEN
        tmp_sum1 := tmp_sum1+NVL(TO_NUMBER(NAME_IN(dtl_val)),0);
     ELSIF
        NAME_IN(dtl_flag) = 'D' THEN
        tmp_sum2 := tmp_sum2+NVL(TO_NUMBER(NAME_IN(dtl_val)),0);
     ELSIF
        NAME_IN(dtl_flag) IS NULL THEN
        NULL;
     END IF;
     IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
        EXIT;
     ELSE
     NEXT_RECORD;
     END IF;
  END LOOP;
  :b2.crd_amt := tmp_sum1;          -- Shows credit total on screen
  :b2.dbt_amt := tmp_sum2;          -- Shows debit total on screen
END;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Last record chosen in Oracle Query 3 54
export Oracle diagram from Oracle DB including VIEWS 8 105
Queries 15 34
sort a spool into file output in oracle 1 22
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now