Passing field name in function as parameter

Hi
I want to pass the fields name as in parameter in function and then return the value of that field.
thanks
pramod patel

CREATE OR REPLACE FUNCTION demo
(i_in IN number)
RETURN NUMBER
IS
BEGIN
RETURN i_in*2;
END demo;
Hope that helps ... also, remember you can't use precision and scale (in the case of NUMBER), or length (in the case of VARCHAR2) for the parameters but you can ANCHOR (%TYPE or %ROWTYPE)
Good luck!

Similar Messages

  • It is possible to get giving parameter field name in function module

    i have one question like below .
    at main report .
    call funciton Fm1
      exporting
         var1 = W_A
         var2 = W_B
    at function module i want to get  giving  parameter field name, in here  value was  "W_A" and "W_B"  .
    plz give me some hints or any advise .

    Only a hint:
    If you have a fm with an unspecified parameter like
    FUNCTION ZTESTBABLFM.
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(INPUT)
    type-pools: sydes.
    data: fieldinfo type SYDES_DESC.
      describe field input into fieldinfo.
    ENDFUNCTION.
    you can get some information from DESCRIBE FIELD  either using INTO as above or with other options as LENGTH, TYPE ...

  • Passing field name into Cursor

    I would like to pass the name of a field for the WHERE clause, into a cursor. In my application I need to change the field name for the where clause. I get an "Invalid Number" error when I try the following:
    cursor l_sel2Cur (c_group varchar2)
    is
    select email from test_grp_tbl6 where c_group = 1;
    select column_name
    into l_colName
    from listserv_grp_lk
    where lg_id = v_listserv_grp;
    open l_sel2Cur(l_colName);
    I hope this is enough explanation. I have seen examples where the value for the where clause is passed in, but not where the field name itself is passed in. Is this possible?
    Thanks in advance,
    John

    See the following example:
    SQL> create or replace procedure print_enames(in_col in varchar, in_val in varchar2) is
      2  c sys_refcursor;
      3  v_name emp.ename%type;
      4  begin
      5    open c for 'select ename from emp where '||in_col||'='''||in_val||'''';
      6    loop
      7     fetch c into v_name;
      8     exit when c%notfound;
      9     dbms_output.put_line('ename='||v_name);
    10    end loop;
    11  end;
    12  /
    Procedure created.
    SQL> select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> set serverout on
    SQL> exec print_enames('mgr','7839')
    ename=JONES
    ename=BLAKE
    ename=CLARK
    PL/SQL procedure successfully completed.
    SQL> exec print_enames('sal','1250')
    ename=WARD
    ename=MARTIN
    PL/SQL procedure successfully completed.
    SQL> exec print_enames('deptno','30')
    ename=ALLEN
    ename=WARD
    ename=MARTIN
    ename=BLAKE
    ename=TURNER
    ename=JAMES
    PL/SQL procedure successfully completed.

  • How to pass column name at run time in function.

    how to pass column name at run time in function as parameter.
    thank in advance
    pramod patel

    Hello,
    Using dynamic sql you can pass column name to function. well I am not getting what you really want to do ? Please write in more detail. By the way I am providing one example here. see it uses dynamic sql.
    Create or replace function fun_updtest (p_columnname_varchar2 in varchar2,
    p_value_number in number)
    return number is
    v_stmt varchar2(500);
    begin
    v_stmt := 'update emp
    set '||p_columnname_varchar2||' = '||to_char(p_value_number)||'
              where empno = 7369';
    execute immediate v_stmt;
    return 0;
    commit;
    end;
    call to this function can be like this..
    declare
    v_number               number;
    begin
    v_number := fun_updtest('SAL',5000);
    end;
    Adinath Kamode

  • How to find the names of Function Module used in the program

    Hi all,
    can you people help me with this issue.I want to the names of all the Function Module used in the program  along with their parameters into an internal table.It will be helpful for your suggestions.
    Kind Regards,
    Edited by: Prasenjit Sengupta on Nov 20, 2008 7:39 AM

    Take structure of internal table as
    TYPES : BEGIN OF TY_FM,
            FUNCNAME TYPE RS38L_FNAM,  "Name of Function Module
            PARAMETER TYPE RS38L_PAR_, "Parameter name
            PARAMTYPE TYPE RS38L_KIND, " Parameter type
            R3STATE TYPE R3STATE,      "ABAP: Program Status (Active, Saved, Transported...)
            STRUCTURE TYPE RS38L_TYP,  "Associated Type of an Interface Parameter
            DEFAULTVAL TYPE RS38L_DEFO,"Default value for import parameter
            REFERENCE TYPE RS38L_REFE, "Call by reference
            OPTIONAL TYPE RS38L_OPTI,  "Optional parameters
            TYPE TYPE RS38L_TYPE,      "Reference Structure is an ABAP/4 Type
            END OF TY_FM.
    DATA : IT_FM TYPE TABLE OF TY_FM WITH HEADER LINE.

  • Pass table name as a parameter to function

    Is there a way to pass table name as a parameter to functions? Then update the table in the function.
    Thanks a lot.
    Jiaxin

    Hi, Harm,
    Thank you very much for your suggestion and example. But to get my program work, i need to realise code like follows:
    CREATE OR REPLACE FUNCTION delstu_func(stuno char) RETURN NUMBER AS
    BEGIN
    EXECUTE IMMEDIATE 'DELETE FROM student s' ||
    'WHERE' || 's.student_number' || '=' || stuno;
    LOOP
    DBMS_OUTPUT.PUT_LINE('record deleted');
    END LOOP;
    END;
    SELECT delstu_func('s11') FROM STUDENT;
    The intention is to check if such a function can perform operations such as update, delete and insert on occurence of certain values. When executing the above statement, the system returns an error message:
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ORA-06512: at "SCMJD1.DELSTU_FUNC", line 3
    Could you tell me where is wrong?
    Jiaxin

  • Can I add special character "$" in the function module parameter name??

    Hi Friends
    Can I add special character "$" in the function module parameter name??
    awaiting for your reply,
    Regards
    Praveen

    >
    prashanth kishan wrote:
    > Thomas,
    > ... What if Praveen passes the $ parameter in that unknown FM and suddenly theres smoke coming from the rear of the CPU? Who's answerable to that??
    >
    > pk
    Blame Canada!

  • The 'argumentname' argument passed to the 'Methodename 'function is not of type 'Dto name'

    Hi, there!
    Sr for that question, because it should be pretty easy to answer, but i'm totally new to coldfusion
    and googled for about an hour now. I have a orm DTO.cfc:
    <cfcomponent entityname="testDTO" persistent="true" table="test"  schema="informix" output="false">
        <!---- properties ----> 
    </cfcomponent>
    and have a service Methode in test.cfc
        <!---- Add test---->
        <cffunction name="createTest" returntype="testDTO" access="remote">
            <cfargument name="item" type="testDTO" required="true" />
            <!---- Auto-generated method
              Insert a new record in test---->
            <cfset entitysave(item) />
            <!---- return created item ---->
            <cfreturn item/>
        </cffunction>
    i try to call via the the <cfInvoke>-Tag
    <cfset lieferant = entityNew('test')>
    <cfinvoke
        component="#request.componentbase#.test"
        method="createTest"
        item="#test#"
        returnvariable="test">
    but the error
    'The ITEM argument passed to the createLieferant function is not of type testDTO.'
    appears on function call. I just can't find a way to tell cf that lieferant is of type testDTO.
    When i type the methodes parameter to struct the methode call works well.
    Thanks for your help in advance!
    Florian

    I'm assuming your extract there isn't quite right:
    <cfset lieferant = entityNew('test')>
    <cfinvoke
        component="#request.componentbase#.test"
        method="createTest"
        item="#test#"
        returnvariable="test">
    You're doing item="#test#", surely this should be item="#lieferant#"?
    In which case, you've done  <cfset lieferant = entityNew('test')>, which is of type "test", not "testDTO"?
    If you're still having trouble, remove the item="" attribute from CFINVOKE and use CFINVOKEARGUMENTs instead.

  • Passing TABLE NAME as parameter is possible or not?

    I want develop a small/simple report like this
    TABLE NAME :
    WHERE :
    ORDER BY :
    QUERY ROWS
    In the above model i want to pass all the three (TABLE NAME,WHERE and ORDER BY) as a parameter.
    My doubt, is that possible to pass TABLE NAME as a parameter? If so!
    When i enter any TABLE NAME it has to fetch me out the records of that table (Based on WHERE condition and ORDER BY).
    Is that possible to do?
    Need some help!
    Edited by: Muthukumar Seshadri on Aug 10, 2012 6:19 PM

    Yes, it is possible with lexical parameters. Look in the help for examples:
    SELECT Clause
    SELECT &P_ENAME NAME, &P_EMPNO ENO, &P_JOB ROLE  FROM EMP
    P_ENAME, P_EMPNO, and P_JOB can be used to change the columns selected at runtime.  For example, you could enter DEPTNO as the value for P_EMPNO on the Runtime Parameter Form. 
    Note that in this case, you should use aliases for your columns.  Otherwise, if you change the columns selected at runtime, the column names in the SELECT list will not match the Report Builder columns and the report will not run.
    FROM Clause
    SELECT ORDID, TOTAL FROM &ATABLE
    ATABLE can be used to change the table from which columns are selected at runtime.  For example, you could enter ORD for ATABLE at runtime. 
    If you dynamically change the table name in this way, you may also want to use lexical references for the SELECT clause (look at the previous example) in case the column names differ between tables.
    WHERE Clause
    SELECT ORDID, TOTAL FROM ORD WHERE &CUST
    ORDER BY Clause
    SELECT ORDID, SHIPDATE, ORDERDATE, TOTAL  FROM ORD ORDER BY &SORT You have to be really careful with this approach. Dynamic SQL may cause serious performance problems.
    Edited by: InoL on Aug 10, 2012 10:06 AM

  • Pass column-name as a parameter to reports

    Hello,
    the code below calls a report. But now I want to sort the rows in the report. For example I have a text-item in my form-modul. If I type a column-name and press the button then the rows should be sorted in the report. Is it possible tp pass column-names as parameter to reports?
    DECLARE
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    rep_status VARCHAR2(20);
    BEGIN
    repid := find_report_object('STATIONSTOPOLOGIE');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,CACHE);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'html');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_oracle-dev');
    -- SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no pdeptno='||:dept.deptno);
    v_rep := RUN_REPORT_OBJECT(repid);
    rep_status := REPORT_OBJECT_STATUS(v_rep);
    WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
    LOOP
    rep_status := report_object_status(v_rep);
    END LOOP;
    IF rep_status = 'FINISHED' THEN
    WEB.SHOW_DOCUMENT('http://oracle-dev:8888/reports/rwservlet/getjobid'||
    substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=rep_oracle-dev','_blank');
    ELSE
    message('Error when running report');
    END IF;
    END;

    Hi,
    the work has been done in reports. You can use a lexical parameter in reports to add a condition for sorting to the query like:
    select .. from .. where ... &p_order.
    Then add another parameter to the report (for example p_param). Fill p_param via your interface in forms (SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER, ....) with the column name. Then build a report trigger like:
    if :p_param is null
    then
    :p_order:= null;
    else
    :p_order:= 'order by '||:p_param;
    end if;
    But have a look, that p_param can only get correct values.
    Rainer

  • Pass table name as parameter in prepared Statement

    Can I pass table name as parameter in prepared Statement
    for example
    select * from ? where name =?
    when i use setString method for passing parameters this method append single colon before and after of this parameter but table name should be send with out colon as SQL Spec.
    I have another way to make sql query in programing but i have a case where i have limitation of that thing so please tell me is it possible with prepared Statment SetXXx methods or not ?
    Thanks
    Haroon Idrees.

    haroonob wrote:
    I know ? is use for data only my question is this way to pass table name as parameterI assume you mean "how can I do it?" As I have already answered "is this the way?" with no.
    Well, I would say (ugly as it is) String concatenation, or stored procedures.

  • Passing form field name to the subject line of the task assign email

    Hello Everyone,
    I am trying to create a process that need to pass one of the field data from a form to the task email assign but could not make it work right as expected. I think I miss something but could not figure it out myself. If any one has done this before, please share your knowledge.
    Thanks in advance,
    Han Dao

    Hi Jasmin,
    I thought it simple thing to do by passing the xPath to the subject line but for some reasons, it does not work instead it show the whole xpath on the subject line. Here is my xpath:
    {$/process_data/FormData/object/data/xdp/datasets/data/FSFIELDS_/Form1936/EmpInfoSub/UserM gr$}
    where Form1936 is the pageName, EmpInfoSub is sub-form, and UserMgr is field name on the form.
    Thanks,
    Han Dao

  • Pass multiple values as single input parameter into pipelined function

    Hi all,
    My need is to pass multiple values as single input parameter into pipelined function.
    For example - "2" and "3" are values of input parameter "t":
    with data as (
    select 1 as t from dual union all
    select 2 as t from dual union all
    select 3 as t from dual union all
    select 4 as t from dual union all
    select 5 as t from dual
    select * from data where t in (2,3)Is it possible at all?

    Not exactly sure, but usually 'multiple values'+'pipelined function' = some IN-LIST related approach?
    See:
    SQL> create table data as
      2  select 1 as t from dual union all
      3  select 2 as t from dual union all
      4  select 3 as t from dual union all
      5  select 4 as t from dual union all
      6  select 5 as t from dual;
    Table created.
    SQL> --
    SQL> CREATE OR REPLACE FUNCTION in_list (p_in_list  IN  VARCHAR2)
      2  RETURN sys.odcivarchar2list PIPELINED
      3  AS
      4    l_text  VARCHAR2(32767) := p_in_list || ',';
      5    l_idx   NUMBER;
      6  BEGIN
      7    LOOP
      8      l_idx := INSTR(l_text, ',');
      9      EXIT WHEN NVL(l_idx, 0) = 0;
    10      PIPE ROW (TRIM(SUBSTR(l_text, 1, l_idx - 1)));
    11      l_text := SUBSTR(l_text, l_idx + 1);
    12    END LOOP;
    13 
    14    RETURN;
    15  END;
    16  /
    Function created.
    SQL> --
    SQL> select *
      2  from   data
      3  where  t in ( select *
      4                from   table(in_list('1,2'))
      5              );
             T
             1
             2
    2 rows selected.http://www.oracle-base.com/articles/misc/dynamic-in-lists.php
    or
    http://tkyte.blogspot.nl/2006/06/varying-in-lists.html

  • Write a query for which has its field name as input parameter

    Hi All,
    I need to write a query for SSRS report. StartDate, EndDate and ChangedField are the input parameters.
    Let's consider that we are taking employee details. The table contains lot of fields like emp name,add1,add2,city,state,country,designation,rank etc. We have almost 30 fields are there. These field name are coming as input parameter "ChangedField"
    . I need to show the records which belong to the start date and end date also data change for the field which is given in the input parameter "ChangedField".  That meand If I give ChangedField="city", we need to check for data which
    has been updated with new City name in the given time period.
    Please suggest.
    Regards,
    Julie

    Hi Julie,
    Per my understanding that you have many fields in the table to be displayed in the report, some of the fields will always show and others should be hide and show based on the selection of the parameters which include the columns names, right?
    By default, we can't display columns dynamically in the report automatically without insert this column in the report before. So, in your scenario, I will suggest you to add all the columns in the reports first and then add show/hide expression on
    the column visibility based on the selection of the parameter "ChangedField", when some of the fields selectted they will be display, otherwise they will be hidden. For the fields which you want to be always displayed will not need to add the expression
    in the column visibility.
    Details steps about how to acheive this, please referencet to the  article below:
    Displaying Dynamic Columns in SSRS Report
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • Adding a CM: Invalid length parameter passed to the RIGHT function. (CINF)

    We started seeing this error message a week ago when attempting to add a Credit Memo.  We only see this error message when entering Credit Memos and not any other finacial documents.  I've done some preliminary research and haven't really come up with anything to point to the issue.  Prior to reporting this to my support partner, I wanted to see if anybody here has seen this before or give me some ideas to look into the source of the issue.
    Full error message: Microsoft SQL Native Client SQL Server Invalid length parameter passed to the RIGHT function. (CINF)

    Checking the list of form ID's at [http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/892] shows the A/R Credit Memo as 179 and the A/P Credit Memo as 181.  This also corresponds with what I see when viewing the system information on the form.

Maybe you are looking for

  • Change Request demanded while creating a Sales Order

    Dear All, I am creating a Sales Order. The solution is using user exits to communicate between SD and TEM. Whenever we create a Sales Order its corresponding sales order and line item is updated in TEM table HRVPAD25. While saving the Sales Order, it

  • Using ITunes Store with Windows Vista

    I seem to be having a problem with downloading my songs. I keep receiving an error message (err. 3259) and I have already paid for my downloads. Now what?

  • Resize in iPhoto? or not?

    forget what I may do with it at some future date. Will iPhoto resize or not? If so how? I keep running into advice re: using some other program to do so. simply highlight a pic, get info, resize it intact from 2560x1920 to 640x480 I have attempted va

  • DNS : simple internal network, no router. Doesn't work

    Ok. Here is the deal. I've read many articles (including the excellent one from the famous MrHoffman) but I'm stuck. No documentation really deals with my situation. I have a MacMini with 10.6 Server for a local network. I don't want an internet conn

  • HOW TO VIEW PAGES SIDE BY SIDE IN UPDATED PAGES APP

    How to view pages side by side in updated pages app in Mavericks.