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

Similar Messages

  • How to pass column name as a   values from one page  to another

    hi
    i have created a report(pivot) from a table
    SQL> SELECT * FROM T;
    C1  C2          C3 D                SEQ
    A   AA           2                    1
    A   AB           3                    2
    A   AC           2                    3
    B   AB           5                    4
    B   AC           6                    5
    SQL> SELECT C1
      2  ,NVL(MAX(CASE WHEN C2='AA' THEN C3 END),'') AA
      3  ,NVL(MAX(CASE WHEN C2='AB' THEN C3 END),'') AB
      4  ,NVL(MAX(CASE WHEN C2='AC' THEN C3 END),'') AC
      5  ,SUM(C3) FROM T GROUP BY C1;
    C1          AA         AB         AC    SUM(C3)
    A            2          3          2          7
    B                       5          6         11
    SQL>
    my requirement in Apex is like this(reverse)
    eg-
    when i click on cell values '2' then,it should return
    C1  C2          C3 D                SEQ
    A   AA           2                    1
    {quote}how to pass column name as a  values from one page to another
    for example i have to pass 'c2' as a value to next page{quote}for report pivot you can reffer below link
    Report
    Amu

    thanks for your reply
    i 'm doing what exactly you mention here .
    my problem here is
    i have 15 columns
    i am executing a query based on the values of the column(column name)  in the target page
    1)here i am passing(all) the column values to the next page-but  i want to pass only one column values(column name)
    when i click on any cell of that  column
    OR
    2)i can pass all column name to target page -there(in the target page) i can filter out
    i think option 1 would good if you filter out the unwanted columns
    Regards
    Amul

  • How to get sequence name in run time.

    hi
    I have several sub sequence called in the main sequence in TestStand. Those sub sequences have different sequence names, which i wanted to display by string indicator on the Labview Operator Interface. Is there a simple way to show the current calling sub sequence name during run time(run main).
    thanks.
    Message Edited by Appledoll on 07-12-2007 10:12 AM

    Hi,
    The easiest way is to use the NameOf() function. In this case where you wish to get the name of the current sequence the syntax NameOf(RunState.Sequence) yields the name. I attach a very simple example also.
    Getting the Name of Any TestStand Property Programmatically in TestStand
    Hope this helps
    Pelle S
    District Sales Manager
    National Instruments Sweden
    Attachments:
    Get sequence name.vi ‏15 KB

  • How to pass column name in slect statement in query

    hi,
    i want to make a report where in query select statement using variable as a column name. but its not working plz guide me how can i do this.
    i have created a function which return column name through variable & that variable i want to to use in select statement
    select :m1 from table1;
    regards

    Hi,
    Create a user parameter (say P_field), and assign a valid field name as initial value (say NAME), And In the Query, write
    SELECT CODE, &P_field FN_FIELD FROM <table_name> WHERE <condition>And in the BEFORE PARAMETER FORM Trigger under the Report Triggers, write,
    function BeforePForm return boolean is
    begin
      :P_field := <your_function_call>;
      return (TRUE);
    end;And use that FN_FIELD field in the report.
    Hope this will clear your issue.
    Regards,
    Manu.

  • How to Use Table name at run time

    Hi All
    I have created a function that accepts a table name as a parameter and returns the maximam sequence number, but in my function body i can not write the parameter name as a table i.e.
    CREATE OR REPLACE FUNCTION MAX_ID(TAB_NAME Varchar)
    RETURN Number IS
    max_id Number;
    CURSOR curSalPoint IS
         SELECT MAX(EMP_NUMBER)
         FROM TAB_NAME ;
    BEGIN
    max_id:=0;
    OPEN curSalPoint ;
         FETCH curSalPoint INTO max_id;
         CLOSE curSalPoint;
    RETURN max_id
    END
    But it will give an error saying
    (1):PL/SQL: ORA-00942: table or view does not exist
    for "TAB_NAME"
    Any help would be appreciate ........

    Yes, as i contcatinated table name with the original statement, so you can also continate fields' names with your statment and execute immediate the statement.
    Sorry i forgot this statement in my function, to execute the statement you need to include following statement
    CREATE OR REPLACE FUNCTION MAX_ID(TAB_NAME Varchar)
    RETURN Number IS
    max_id Number;
    query varchar2(200);
    BEGIN
    max_id:=0;
    query:=null;
    query := query || 'select max(empno) into max_id from'|| tab_name;
    EXECUTE IMMEDIATE query;
    RETURN max_id;
    END;
    Message was edited by:
    Salman Qureshi

  • Reading from a file. How to ask the user for file name at run time????

    I have the code to read from a file but my problem is how to prompt the user for the file name at run time.
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.InputMismatchException;
    import java.util.Scanner;
    public class FileRead {
        public static void main(String args[]) {
            Scanner scan = null;
            File file = new File("Results.txt");
            String number;
            try {
                scan = new Scanner(file);
                while (scan.hasNext()){
                number = scan.next();
                System.out.println(number);}
            catch (FileNotFoundException ex1){
                System.out.println("No such file");
            catch (IllegalStateException ex2){
                System.out.println("Did you close the read by mistake");
            catch (InputMismatchException ex){
                System.out.println("File structure incorrect");
            finally{
                scan.close();}
    }Any hints would be greatly appreciated. Thank you in advance

    I have read through some of the tutorials that you have directed me too and they are very useful, thank you. however there are still a few things that i am not clear about. I am using net beans 5.0 I have placed a text file named Results.txt into the project at the root so the program can view it.
    When I use the code that you provided me with, does it matter where the file is, or will it look through everywhere on the hard drive to find a match?
    This code compiles but at run time it comes up with this error
    run-single:
    java.lang.NoClassDefFoundError: NamedFile
    Exception in thread "main"
    Java Result: 1
    BUILD SUCCESSFUL (total time: 3 seconds)
    import java.util.Scanner;
    import java.io.*;
    class NamedFileInput
      public static void main (String[] args) throws IOException
        int num, square;   
        // this Scanner is used to read what the user enters
        Scanner user = new Scanner( System.in );
        String  fileName;
        System.out.print("File Name: ");
        fileName = user.nextLine().trim();
        File file = new File( fileName );     // create a File object
        // this Scanner is used to read from the file
        Scanner scan = new Scanner( file );     
        while( scan.hasNextInt() )   // is there more data to process?
          num = scan.nextInt();
          square = num * num ;     
          System.out.println("The square of " + num + " is " + square);
    }his is the code that i used. It is the same as the code you posted for me (on chapter 23 I/O using Scanner and PrintStream) Sorry im just really stuck on this!!

  • Execute immediate with using clause to pass column name dynamically

    Hai,
    Is there any way using execute immeidate to pass the column name dynamically. I used to pass the column value as dynamic with the help of "Using clause" . But if i use to pass column name, it is giving numberic error at run time. Eg,. for testing has been given below.
    1. Column value as dynamic, which is working correctly.
    create or replace function testexeimm (acctnum char)
    return number as
    acctbal number;
    begin
    execute immediate 'select balance from acct_master where acct_no=:a' into acctbal using acctnum;
    return acctbal;
    end;
    2. Column name as dynamic which is not working
    create or replace function testexeimm (colnam char)
    return char as
    acctbal char;
    begin
    execute immediate 'select :a from ch_acct_mast where rownum=1' into acctbal using colnam;
    return acctbal;
    end;
    Any help in this regard will be highly appericated.
    Regards
    Sridhar

    So the variable has to be numeric too:
    create or replace function testexeimm (colnam char)
    return number as
    acctbal number;
    begin
    execute immediate 'select '|||colnam||' from ch_acct_mast where rownum=1' into acctbal;
    return acctbal;
    end;Max
    http://oracleitalia.wordpress.com

  • How to dynamically validate users at run time using connection pools ?

    Hi Folks
    We are facing a peculiar situation . We have established connection to our
    oracle 8i database using Oracle Thin driver using conenction pooling at the weblogic
    server . We set up connection pools at the console to set up connections to thge
    oracle 8i database. However the user name and password is always static when
    we create the connection pool at the console .
    How do i dynamically validate other users using the same connection pool ??
    Eg - The connection pool at design time in the console uses user A and password
    - passA . Now at run time lets say I prompt the user for a login screen and want
    to trap the user id and apssword parameters entered by the user and use it with
    the connection pool created earlier . I tried using the below code snippet :-
    Properties props = new Properties();
    props.put("connectionPoolID", "Oracle_Thin_Driver_Pool");
    props.put("user" , userId );
    props.put("password",userPass);
    myDriver = (Driver) Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = myDriver.connect("jdbc:weblogic:pool", props);
    But always it connects to the database using the userid and password set in the
    console while creating the connection pool . So how i get the connection pool
    to validate my current userid and password entered through the login screen ??
    Thanks in advance
    Keith

    Hey Bob.
    So I assume you're -completely- working with built executables?  You're not going to work in the editor environment to modify your projects at all?
    If this is the case, then having a generic deployment phase at the beginning of the executable (with a "setting up hardware for your app" splash screen) isn't a bad idea -
    Check the binary on the target, ensure it matches the binary you have on the host machine (in case you ever decide to update).
    If they don't match, FTP the new file down to replace the old one.
    FTP the ni-rt.ini file, ensure the startup exe is enabled and is pointing to the correct location.  
    If it's not enabled or not pointing to the correct startup file, modify the .INI file and FTP back to the target.
    If you had to update the INI file, ask target to reboot itself.  Wait 30 seconds, and wait for target to become available again.
    Connect to the target. If you cannot connect, reboot target.  If the target comes back and you still cannot connect to the app, notify user.
    That's almost exactly how we handle installation and deployment via MAX.  
    The big assumption here is that the built executables were all built with the same version of LabVIEW Real-Time.  If not, you'd need a system replication step in there to make sure the proper version of LabVIEW is on the target before launching the built .rtexe.  
    -Danny

  • 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

  • Update step limit name at run-time

    I need to run through some test steps in a TestStand sequence multiple times.  This wouldn't be a loop on a single step or group of steps but probably a goto a label "for" loop in TestStand.  BTW, TestStand 2.0.1 calling code from a LabWindows/CVI DLL via the standard prototype adapter.  Each iteration I need to have the test step limit names be updated with a different suffix.  So step1 might have results0 and results1 and on the 2nd run results0 would be renamed to results0b.  How do I update the limit names, at run-time, from a LabWindows/CVI function?  I.e. the first test in the sequence's Main would update the steps below it to update the suffix.  I started down the path of using TS_SeqContextGetProperty to get the sequence handle
    TS_SeqContextGetProperty( testData->seqContextCVI, &errorInfo, TS_SeqContextSequence, CAVT_OBJHANDLE, &seq_hndl );
    then using TS_SequenceGetNumSteps( seq_hndl, &errorInfo, TS_StepGroup_Main, &num_steps ) to determine the number of steps in the Main tab.  
    Enter a for loop:
    TS_PropertyGetValString( testData->seqContextCVI, &errorInfo, buf, TS_PropOption_NoOptions, ( char ** )&rslt_name ) with buf as "Sequence.Main[0].Result.Measurement[0]" errors out with an invalid name message.  The idea is to get this value, update it based on the iteration in TestStand ( this is already acquired and working ), and then set the value back.  Then, move on to the next step and so forth.
    Any suggestions?
    Thanks.
    -G-
    Solved!
    Go to Solution.

    So, I tried the example and it works but only for a single step.  I've tried two options:  1. having a single step that programmatically changes all the result names in all the other steps in the sequence. 2. having each step update the result names itself.  For thought 1 the loop would run and the changes would occur but when the function was exited I'd get an exception from TestStand.  No real information in the details as it looked like a memory corruption error.  I then examined the details of what occurred and tried more experiments.  If I had the loop have more than 1 iteration this behavior occurred.  If I comment out the set function it still occurs.  Then, for thought 2, it works like a champ on all the steps until I loop back to the top of the sequence.  Then, on the first step ( 2nd time through ) it bombs out.
    Attached is the code for the 2nd possible solution.
    Does anyone know what the problem is or if there's a way to do this?
    -G-
    Attachments:
    Change Step Name.txt ‏7 KB

  • Passing Column name(String) in setting CallableStatement

    Is it possible to pass Column Name while setting the CallableStatement while using drivers for JDK 1.4, if yes how do I do it.
    Thanks!

    You don't necessarily need to use dynamic SQL;
    create or replace procedure p
      p_a number default null,
      p_b number default null,
      p_c number default null
    ) is
    begin
      insert into t
      values
        (p_a, p_b, p_c);
    end;
    Procedure createdUsing named notation;
    exec p(p_a =>1, p_c => 3);
    PL/SQL procedure successfully completed
    exec p(p_b =>20, p_c => 30);
    PL/SQL procedure successfully completedPassing NULLs;
    exec p(4, null, 6);
    PL/SQL procedure successfully completed
    exec p(40, 50, null);
    PL/SQL procedure successfully completed
    select * from t;
             A          B          C
             1                     3
                       20         30
             4                     6
            40         50

  • How to get column names for a specific view in the scheme?

    how to get column names for a specific view in the scheme?
    TIA
    Don't have DD on the wall anymore....

    or this?
    SQL> select text from ALL_VIEWS
      2  where VIEW_NAME
      3  ='EMP_VIEW';
    TEXT
    SELECT empno,ename FROM EMP
    WHERE empno=10

  • How to create transparent image at run-time?

    How to create transparent image at run-time? I mean I want to create a (new) transparent image1, then show other (loaded) transparent image2 to image1, then show image1 to a DC. The problem is - image1 has non-transparent background...

    i'm not sure, but you can set the alpha value to 0 in all pixels which are 'in' the background..
    greetz
    chris

  • How to get column names in table maintenance dialog?

    I created a new Z table and created a maintanance dialog so that I can maintain the table through sm30. i don't see columns names on maintenance screen, just a "+" sign for each column! Could someone please tell me how to display column name?
    Thanks.
    Mithun

    Hello Mithun
    The column texts are taken from the field descriptions of the data elements used in your z-table. A "+" sign usually indicates that none of the field descriptions of the data element has been maintained.
    Regards
      Uwe

  • How to pass user name and password in openConnection method ?

    Hi, Exports,
              I am trying to post data from applet to another application which is
              protected by network password.
              How to pass user name and password when I use openConnection method? In java
              doc, this method looks like do not accept these two parameters.
              Thanks
              ----- my code in applet ---------
              URL url = new URL("http://127.0.0.1/xml/index.cfm");
              URLConnection connection = url.openConnection();
              connection.setDoInput(true);
              connection.setDoOutput(true);
              connection.setUseCaches(false);
              connection.setAllowUserInteraction(false);
              DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
              dos.writeBytes("POST " + path + " HTTP/1.0\r\n");
              dos.writeBytes("Referer: http://127.0.0.1/XML/index.cfm\r\n");
              dos.writeBytes("Content-Type:
              multipart/form-data;boundary=---------------------------7d0b414b04\r\n");
              dos.writeBytes("Host: "+host+":"+port+"\r\n");
              dos.writeBytes("Content-Length:" + buff.length()+"\r\n");
              dos.writeBytes("Connection: Keep-Alive\r\n\n");
              dos.writeBytes("-----------------------------7d0b414b04\r\nContent-Dispositi
              on: form-data;name=\"xmlDoc\"\r\n\r\n");
              dos.writeBytes(buff.toString());
              dos.writeBytes("\r\n-----------------------------7d0b414b04--\r\n");
              dos.close();
              

    you need to negotiate Authentication in ur applet code...
              For example:
              If u r using Form based auth u need to send Post a request with j_user_name &
              j_password to the action j_security_check. and when server returns back the
              cookie
              u need to hold it and pass that cookie to the each and every request made to the
              protected application.
              Basically u need to imitate the browser.
              regards
              aseem
              David wrote:
              > Hi, Exports,
              >
              > I am trying to post data from applet to another application which is
              > protected by network password.
              > How to pass user name and password when I use openConnection method? In java
              > doc, this method looks like do not accept these two parameters.
              >
              > Thanks
              >
              > ----- my code in applet ---------
              > URL url = new URL("http://127.0.0.1/xml/index.cfm");
              > URLConnection connection = url.openConnection();
              > connection.setDoInput(true);
              > connection.setDoOutput(true);
              > connection.setUseCaches(false);
              > connection.setAllowUserInteraction(false);
              > DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
              > dos.writeBytes("POST " + path + " HTTP/1.0\r\n");
              > dos.writeBytes("Referer: http://127.0.0.1/XML/index.cfm\r\n");
              > dos.writeBytes("Content-Type:
              > multipart/form-data;boundary=---------------------------7d0b414b04\r\n");
              > dos.writeBytes("Host: "+host+":"+port+"\r\n");
              > dos.writeBytes("Content-Length:" + buff.length()+"\r\n");
              > dos.writeBytes("Connection: Keep-Alive\r\n\n");
              > dos.writeBytes("-----------------------------7d0b414b04\r\nContent-Dispositi
              > on: form-data;name=\"xmlDoc\"\r\n\r\n");
              > dos.writeBytes(buff.toString());
              > dos.writeBytes("\r\n-----------------------------7d0b414b04--\r\n");
              > dos.close();
              >
              > ------------------------------------------
              

Maybe you are looking for

  • Skype account hacked, information change can not r...

    Dear Skype community, My business skype account was hacked, password and and all information was change in it, I lost access to it complicit. I have Skype premium with over 1000 contacts in it and can not get any help.  I've tried all skype links and

  • IOS App link to Business Catalyst Analytics with Creative Cloud and DPS Prof.

    Hello, I have a Creative cloud membership and a DPS Professional account. I've made an iOS App and I want to link the App to the Business Catalyst Analytics. I can do that in the DPS account Administration. My question is, do I have an Business Catal

  • How to create an apex session in e.g. SQL*Plus?

    I would like to establish an apex session using a tool different from SQL Workshop. How can I achieve this using e.g. SQL*Plus or SQL Developer? Is there some document on the internet which addresses this question? I couldn't find it yet.

  • Photo stream different folders??

    Ok, so I have an iPhone 5 and I am trying to get rid of some pictures (this is a whole other issue) but I have different amounts of pictures stored?? This is what I have: PC: Photostream foder (402 pics) iPhone 5: Albums> Photo Stream (275 pics) iPho

  • Reader 10 can't open some .pdf files

    Reader 10 on a Windows Vista system cannot open some .pdf files. Ones that I create within MS Office open fine. An IRS file (Form W-9) opens fine online, but won't open after downloading. The computer response is "Not responding". Uninstall/reinstall