using the variable as a field name in a query

Oracle 10G


Hi all

I have a table like:

TEST_MSL
CID NUMBER (10),
TEST_1 VARCHAR2,
TEST_2 VARCHAR2

Now, I want to use a procedure such as:

create or replace procedure TEST
(VARIABLE_1 IN VARCHAR2) Possible values (TEST_1, TEST_2)
as
BEGIN

declare
cursor c1 is
Select the CID
where VARIABLE_1 = 'BLAH '.

My problem is:

How can I use this variable as a domain name?

Kind regards

Menk Slot

Published by: Menk slot on June 3, 2010 10:46

If you know that there are only two possibilities so preferable to use as static SQL statements

procedure test(v_cloumn_name varchar2) IS
IF v_column_name='TEST_1' THEN
SELECT CID INTO var where TEST_1='BLABLA';
ELSE
SELECT CID INTO var where TEST_2='BLABLA';
END;

Otherwise, use Ref cursour as

declare
v_sql_stm varchar2(200);
refcur sys_refcursor;
begin
v_sql_stm:='SELECT CID FROM TEST_MSL WHERE '||v_cloumn_name||' = ''BLABLA''';
open refcur for v_sql_stm;

Tags: Database

Similar Questions

  • How to use a value in a variable as a table name in a query?

    I fetch a value in a variable like:

    < select application_short_name in the fnd_application l_appl_nm where application_id =: p_appl_id >

    Now, I need to use the value retrieved in the variable "l_appl_nm" as a name of partition table in the following query.

    Anyone can guide me please on this concept.

    Expected answers as soon as possible!

    Create dynamic SQL statements with your variable, and then run this SQL with the "EXECUTE IMMEDIATE" command.

    Thank you

    Lokesh

  • Dynamically create a file using the variable

    HI, I am facing a problem in creating file on the time of execution using the variable.
    I have a variable file name. In the tab refresh, I wrote a query SELECT TO_CHAR (SYSDATE, 'YYYY, MM, DD') | 'TEST' FOR DOUBLE. I tested the variable and its value is correct.

    I've created an interface allowing to extract the data in the table and store it in the file. I assigned the variable file name in the file.

    Now when I run the interface... the file is created, but the header is created in different file and its name is ambiguous, g (19) and the data are placed in the other file with the name that matches the value of the variable filename...

    It is two ODI creates two files a single header and other data...

    When I run my interface in a package of the file created perfectly... but one i want to use package I want to create a file via the interface only running

    What is the name of the second file? (the file that does not have the name of the variable)

  • How to change the value of string clustered, to implement using the node value of property instead of writing directly on the flow of data or using the variable

    new to labview :-) and I have a problem when I want to change the value of a string in bunches, and I want to implement this using the node value of property instead of writing directly to the stream or by using the variable, enclosed is the picture.   No matter, I have change in cluster (control) or value of Popery out (indicator) cluster, the value (sensor 7) dataflow keeps unchanged even I gave the new value by value of property node. Thank you to give me some advice about this.

    Hi GerdW

    Thanks a lot for your answer. The reason I'm stubbornly tring to break the flow of DATA is: we have a test system that have about 100 screws, they have a few connected flow, some of them will be unbundling a cluster dataflow chain to check the value in order to make the different cases.  Now I want to insert user event by changing the control and influential cases during run time.

    As I initially uses a global variable (to control cases) instead of unbundle string data flow, it works well.  But then, I found there are a lot of screws that are using the string unbundle.  One of the 'lazy' means, I tried is to change the value via the property node (because that way, I did not need to find all the places where using the unbundle string and replace them with the global variable), then I noticed a problem with "dataflow", the value in the stream of cluster in fact will not be changed by changing the value of the property node.

    I did a test with VI simple (like the picture in last post), and after reading your advice, I tell myself that I need to understand the concept of "DATAFLOW" in labview, it seems that my "lazy" way can not work in this scenario.

    I have attached the criterion VI here, have you furthur suggestions on what I can do in this case?

    Mant thanks!

    Minyi

  • How do I configure the iPad2 to synchronize the iPad-Mailclient with Exchange 2010 via Active Sync using the certificate SSL client and name of user and password?

    Active Sync iPad ssl Client certificate

    How do I configure the iPad2 to synchronize the iPad-Mailclient with Exchange 2010 via Active Sync using the certificate SSL client and name of user and password?

    Hi Ewoki,

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the TechNet Exchange forum. Please post your question in the Forums TechNet in Exchange Server.

  • Execution plan will change if I use the variable binding instead of the literal value?

    Hi guys,.

    Suppose I have a select "... Of... WHERE ID = 2 and... "if I go to use the variable binding instead of the literal value 2," SELECT... " Of... WHERE ID =: p_id and... ", the execution plan change?
    I test multiple statements, the plan does not change, but I don't know if it would even as well as in some other cases.
    Someone at - it ideas?

    Thank you very much.

    Anneso wrote:
    Hi, sorry for the unclear post, it's 11 GR 2.

    As Sybrand already mentioned, there are a lot of change that came in the implementation of the bind variable in some versions of Oracle db. Since you're on 112, it is still true with the introduction of Adaptive Cursor Sharing . Please have a read on it since the post below written by the development of Oracle optimizer group.
    http://blogs.Oracle.com/optimizer/entry/why_are_there_more_cursors_in_11g_for_my_query_containing_bind_variables_1

    Aman...

  • You should have seen the date using the variable of presentation

    Hi all

    I am facing a problem in the display of the selected date of the guest in the report using the variable of presentation. I have a guest of data (calendar prompt), where the user selects the value. I take this value in the variable RBAP of presentation and report when I try to display this value using the same presentation variable, I get my date in the following format

    "TIMESTAMP 2010-10-22 00:00:00 '.

    I'm just using ' @{RBAP}' in the formula in the column.

    I want to show my date in the format DD/MM/YYYY. How to do this?

    I have used CAST (' @{RBAP} {' as DATE} and tried to change the data to dd/mm/yyyy format, but it does not work.)

    Please suggest

    Thank you
    Ronny

    in the default section to write the SQL...

    Select the OPTION case SENSITIVE WHEN 1 = 0 THEN AnyExistedDateColumn CURRENT_DATE of OTHER END OF SubjectArea

  • How to use the variable in the path of the source of an image in flex

    Hello
    I just want to know that how to use the variable in the path of the source of an image in flex

    Hello
    I just want to know that how to use the variable in the path of the source of an image in flex

  • Text added to the text field using the variable does not appear

    Hello

    I have a test field I created dynamically.  If I add some text to it by writing: myField.text = 'text', the text if poster, but if I add text using a variable is nothing.  If I trace trace text in the text field ("text =" myField.text) get good value.

    Someone at - it ideas?

    Best regards

    Chris McLaughlin

    Try to comment out the two lines below and see if it helps...

    ["textField" + guestCueCnt 'c'] .defaultTextFormat plus myFormat;
    ["textField" + guestCueCnt + 'c'] .embedFonts = true;

  • How to use the variable instead of the table name in the select statement of procedure

    I have a procedure with a select statement with dynamic from clause. How can I use instead of the name of the table variable.

    create or replace procedure scc_chemical_analysis
    is
    v_table_name varchar2 (100);
    Start

    declare
    cursor c1 is select * from v_table_name; -This is the variable name. How can I use it in the select statement.
    .
    .
    .
    .



    end;

    Hello

    something like that.

      1  declare
      2     vSQLString      VARCHAR2(32000);
      3  pTableName varchar2(1000):='EMP';
      4  BEGIN
      5     vSQLSTRING :=
      6  'SELECT ''x'' FROM ' || DBMS_ASSERT.sql_object_name(pTableName) || ' WHERE rownum<=1 ';
      7     EXECUTE IMMEDIATE vSQLSTRING;
      8* END;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
  • How can we use the variables name, for example?

    I use 9 textbox in my step. The names are similar, only difference is the last character. (s1_0, s1_1, s1_2,...). I am using these textbox in a loop. But I couldn't find the right typing... s1_ [i], (i) s1_ or s1_ {i} gives an error.

    s1_0.text = 0
    s1_1.text = 0
    s1_2.text = 0
    s1_3.text = 0
    s1_4.text = 0
    s1_5.text = 0
    s1_6.text = 0
    s1_7.text = 0

    How can he do the shortest hits for this problem?

    Use the operator [] table:

    for (var i: uint = 0; i<>

    This ["s1_" + i.ToString ()] .text = 0;

    }

  • How we use the variable checkbox?

    I use Cap 8. Finally, I want to set a variable to store the user's decision to play any narration automatically, or do not play automatically narration.

    A check box appears as a perfect way to let the user make this decision, so I used the box widget to display only a single checkbox. Successfully, I set the text property of checkbox and entered a unique variable name (myNarrationDefault) to store the State of the checkbox. Now how to access the variable?

    I added a text field, so I could see the value of this variable. However, when I try to insert a variable, I don't see the new user variable, in the list. Then I tried to add an action to a button just to see if the variable appears in the tool; There can be no.

    I'm doing something wrong?

    Thank you

    Pete

    In fact, you will need to create so that the variable you made in the interaction interface, CP does not do it for you, project/Variables in the top Menu.

    When the box is checked, the value is then assigned to the variable.

  • Use the Edittext text as layer name?

    I build my own window prompt() for a script, but may not know how to use the text in the text field.

    What I want to do is to use the text as the name of the layer.


    Is there an input method or something I can use for this?



    Prompt() custom;


    var promptWin is new window ('dialogue', 'Pre dial the name');.

    var promptInputGroup = promptWin.add ('group');

    promptInputGroup.add ('statictext', undefined, ' name: ');

    var textFiled = promptInputGroup.add ('edittext', undefined, 'Demo');

    textFiled.characters = 20;

    textFiled.active = true;

    var groupTwo = promptWin.add ('group', undefined, "GroupTwo");

    groupTwo.orientation = "row";

    var okDialog = groupTwo.add ("button", undefined, "OK");

    var cancelDialog = groupTwo.add ("button", undefined, "Cancel");

    groupTwo.alignment = 'right ';

    promptWin.show ();

    Quentin

    Should be as simple as the definition of an onClick for button okDialog send the value to a variable or use the value immediately.

    var myVal;

    okDialog.onClick = function() {}

    myVal = textFiled.text;

    }

    You can also define an onChanging rather than the value to be sent in real-time as the user types. With each character typed, it would save everything right to your variable. I have to be careful though as malicious code could also quickly being sent to your script, depending on how you manage data the user enters.

    okDialog.onChanging = function() {}

    myVal = textFiled.text;

    }

  • How to use a variable as a column name in a select statement

    Hello, I am using

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    I have a procedure looking for groups that have not been updated for the current month. The columns are month_01, month_02, month_03 etc. I'm becoming if I can automate every month, but I need to be able to use a variable as the name of the column for the month. Can someone help me with this?

    Example of Table

    CREATE TABLE TEST_TABLE
    (
      IDENTITY_CODE      NUMBER(10),
      YEAR_S             NUMBER(5),
      MONTH_01           NUMBER(18,2),
      MONTH_02           NUMBER(18,2),
      MONTH_03           NUMBER(18,2),
      MONTH_04           NUMBER(18,2),
      MONTH_05           NUMBER(18,2),
      MONTH_06           NUMBER(18,2),
      MONTH_07           NUMBER(18,2),
      MONTH_08           NUMBER(18,2),
      MONTH_09           NUMBER(18,2),
      MONTH_10           NUMBER(18,2),
      MONTH_11           NUMBER(18,2),
      MONTH_12           NUMBER(18,2) 
    );
    INSERT ALL
    INTO TEST_TABLE VALUES(640,2015,124,123,125,126,127,128,547,888,987,567,145,685)
    INTO TEST_TABLE VALUES(098,2015,587,874,0,587,652,222,444,777,885,999,657,547)
    INTO TEST_TABLE VALUES(608,2015,587,874,687,587,652,222,444,787,885,999,657,547)
    select 1 from dual;
     

    Here's my current procedure

    CREATE OR REPLACE PROCEDURE RRM_EMAIL_NOTIFICATION IS
    
    v_output VARCHAR2(10000);
    v_message VARCHAR2(1000);
    v_date date;
    cursor v_check is 
    SELECT *
      FROM (SELECT '640' AS ds FROM DUAL
            UNION ALL
            SELECT '098' AS ds FROM DUAL
            UNION ALL
            SELECT '608' AS ds FROM DUAL
            UNION ALL
            SELECT '618' AS ds FROM DUAL
            UNION ALL
            SELECT '617' AS ds FROM DUAL
            UNION ALL
            SELECT '614' AS ds FROM DUAL
            UNION ALL
            SELECT '610' AS ds FROM DUAL
            UNION ALL
            SELECT '616' AS ds FROM DUAL
            UNION ALL
            SELECT '643' AS ds FROM DUAL)
    WHERE LPAD (ds, 3, '0') NOT IN
              (SELECT DISTINCT (SUBSTR (IDENTITY_CODE, 2, 3)) AS Blah_Blah_Blah
                 FROM TEST_TABLE
                WHERE     month_03 <> 0
                      AND year_s = 2015
                      AND (   SUBSTR (IDENTITY_CODE, 2, 3) = '640'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '098'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '608'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '618'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '617'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '614'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '610'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '616'
                           OR SUBSTR (IDENTITY_CODE, 2, 3) = '643'));
    
    BEGIN
    v_date := SYSDATE;
    open v_check;
    loop 
    fetch v_check into v_output;
    exit when v_check%NOTFOUND;
    v_message := v_message || chr(13) || v_output;
    END LOOP;
    close v_check;
       
    send_mail('The RRM one-time initiatives that have not been processed for '||v_date|| ' are ' || chr(13) ||v_message,'[email protected]','RRM ONETIMES NOT PROCESSED FOR ' || v_date);
       
    END RRM_EMAIL_NOTIFICATION;
     

    I need to be able to substitute the name e.g. MONTH_01 with a variable column so that it will be MONTH_ | "" some months "

    A variable can be created as v_month: = 'month_ | TO_CHAR (T_DATE, 'MM')

    If I'm not mistaken that should come out as month_03 for March

    The output should be in an email as follows:

    Capture.JPG

    Something like:

    CREATE OR REPLACE PROCEDURE RRM_EMAIL_NOTIFICATION IS

    v_output VARCHAR2 (10000);

    v_message VARCHAR2 (1000);

    date of T_DATE;

    v_check SYS_REFCURSOR;

    BEGIN

    T_DATE: = SYSDATE;

    Open the v_check FOR

    Q' {}

    SELECT *.

    FROM (SELECT '640' DS DUAL FROM

    UNION ALL

    SELECT '098' LIKE ds FROM DUAL

    UNION ALL

    SELECT '608' LIKE ds FROM DUAL

    UNION ALL

    SELECT '618' LIKE ds FROM DUAL

    UNION ALL

    SELECT '617' LIKE ds FROM DUAL

    UNION ALL

    SELECT '614' LIKE ds FROM DUAL

    UNION ALL

    SELECT '610' LIKE ds FROM DUAL

    UNION ALL

    SELECT '616' LIKE ds FROM DUAL

    UNION ALL

    SELECT '643' DS DUAL FROM)

    WHERE LPAD (ds, 3, '0') NOT IN

    (SELECT DISTINCT (SUBSTR (IDENTITY_CODE, 2, 3)) AS Blah_Blah_Blah

    FROM TEST_TABLE

    {WHERE month_}' | TO_CHAR (T_DATE, 'MM') | Q'{ <> 0

    AND year_s = 2015

    AND SUBSTR (IDENTITY_CODE, 2, 3))

    '640'

    '098'

    , ' 608 "

    '618'

    '617'

    '614'

    '610'

    '616'

    '643')

    )

    }';

    loop

    extract the v_check in v_output;

    When the output v_check % NOTFOUND;

    v_message: = v_message | Chr (13) | v_output;

    END LOOP;

    close v_check;

    send_mail ("one-time initiatives the RRM that haven't been treated for ' |") T_DATE | «are» | Chr (13) | v_message,' [email protected]',' ONETIMES UNPROCESSED for RRM ' | T_DATE);

    END RRM_EMAIL_NOTIFICATION;

  • Cannot use the variable in the Interface.

    Hello

    I create a variable in the reference to 11g odi below

    V_name = FTClient

    DataType = alphanumeric

    default value = "BANK 1"

    I create a filter on the source table to pull records only for 1 BANK and talk CELL_SRC_TBL1. CLIENT = #FTClient in the filter.

    But when I try to execute its error display interface.

    "Caused by: java.sql.SQLSyntaxErrorException: ORA-00936: lack of expression.

    Thank you

    Paul

    You use ODI 11? If so the name of the variable must bee all uppercase and when you pass too!

    I hope this can help you!

Maybe you are looking for

  • Forgotten password el capitan 10.11.4

    Restarted the computer last night and, of course, do not remember the password.  The password can be reset?

  • 8007065e 8004ff07

    Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem

  • Windows Media Center has stopped working

    I get a message saying windows media center has stopped working, I also have one indicating Manager windows media center has stopped working, I think that there is also a manager of STF Windows as well. It's just so a new computer should have no prob

  • Can't get my cable vga to work, worked before now show black screen on tv

    using a computer toshiba laptop to a samsung hd tv

  • ApplicationManager and open time

    I can some info on ApplicationManager and ApplicationDescriptor applications. can I get the last moment of the launch of the application?