Solved

Name_In and COPY built in

Posted on 2004-10-05
2
4,654 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create table from select - oracle 6 54
Oracle - SQL Parse String 5 47
Distinct values from all columns in a table?? PL SQL 4 51
Select and Insert Query running slow 4 48
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

820 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