using the variable binding

drop table tab purge;
create table tab (number x, y varchar2 (5));
Insert tab values(1,'rr');
Insert tab values(2,'rr');
Insert tab values(3,'rr');
Insert tab values(4,'rr');
commit;
create or replace PROCEDURE get_data (p_data ON SYS_REFCURSOR,
P_ID IN varchar2)
is
sql_str varchar2 (100): = ' SELECT * FROM tab WHERE. X IN (: x)';
Start
Open p_data
for sql_str
using p_id;
end;
/

SET SERVEROUTPUT ON

VAR A REFCURSOR
VAR B VARCHAR2 (1000)

EXEC get_data (: one, '3', 4);

PRINT

following error, so that the value of product produced no arrow.
-------------------------
ERROR:
ORA-01722: invalid number
-------------------------

Here the implicit conversion does not work, and '3.4' is considered a stgring rather 2 separate values. I have to have to use bind variable and do not want to use dbms_sql. Is it possible, '3,4' is taken as 2-digit values, rather a string value helps Pl, thanks.

You cannot use list as a bind variable. Use:

SQL> create or replace PROCEDURE get_data (p_data IN OUT SYS_REFCURSOR,
  2  p_id IN varchar2)
  3  is
  4  sql_str varchar2(100) := 'SELECT * FROM tab WHERE tab.X IN (' || p_id || ')';
  5  begin
  6  open p_data
  7  for sql_str;
  8  end;
  9  /

Procedure created.

SQL> SET SERVEROUTPUT ON
SQL>
SQL> VAR A REFCURSOR
SQL> VAR B VARCHAR2(1000)
SQL>
SQL> EXEC get_data(:A, '3,4');

PL/SQL procedure successfully completed.

SQL>
SQL> PRINT A

         X Y
---------- -----
         3 rr
         4 rr

SQL> 

Or, if you want to use bind variable, use the composite type. Something like:

SQL> create or replace
  2    type NumberList
  3      as table of number
  4  /

Type created.

SQL> create or replace PROCEDURE get_data (p_data IN OUT SYS_REFCURSOR,
  2  p_id IN NumberList)
  3  is
  4  sql_str varchar2(100) := 'SELECT * FROM tab WHERE tab.X member of :x';
  5  begin
  6  open p_data
  7  for sql_str
  8  using p_id;
  9  end;
 10  /

Procedure created.

SQL> SET SERVEROUTPUT ON
SQL>
SQL> VAR A REFCURSOR
SQL> VAR B VARCHAR2(1000)
SQL>
SQL> EXEC get_data(:A, NumberList(3,4));

PL/SQL procedure successfully completed.

SQL> PRINT A

         X Y
---------- -----
         3 rr
         4 rr

SQL> 

SY.

Tags: Database

Similar Questions

  • 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...

  • How many times can I use a variable binding in a query of the VO?

    Is it possible that I can use a variable binding in a query of VO just once?

    I test a query that keeps throwing the Houston-27122 error by pressing the application module tester. I tried to limit the problem to the simplest possible case, and it seems that the error is caused by the fact that I use the same variable bind two or more times.

    When the query looks like this:

    query1.png

    I have run, enter 'x' and it returns me the result.

    When I change to:

    query2.png

    I have run, enter the value

    param.png

    and immediately get the error

    error.png

    The same thing in sqlplus runs without problem:

    sqlplus.png

    My version of JDev is build JDEVADF_11.1.1.9.0_GENERIC_150314.0718.6673

    Please, advise.

    P. S. where can I find documentation queries are supported in your? In particular, I'm interested if I can use WITH the clause. There seems to be some confusion on this matter (see, for example, Oracle SQL WITH clause support - JDeveloper and ADF)

    Thank you.

    It depends on:

    Open your VO in JDev and go the the query page.

    In the lower part, there is a drop down 'link type', it is usually set to "JDBC-positional. In this case, you will need to provide the bind value for each occurrence of the variable binding separately.

    You could change that to "named" (don't remember the exact name). But beware, this will also affect all relatioships master retail to others your. I think that this is not a good idea to change the style of binding to a single VO.

    Good bye

    DPT

  • Use sessionScope as the value of the Variable binding

    Dear all,

    I have a variable in sessionScope, and I want to use it as a condition of application of a ViewObject.

    I found a thread talking about, there's only one: (Re: set the value in the global variable. )
    How to use the value in the scope of session groovy script?

    Model project:
    Set variable in the scope of the session:
    ADFContext.getCurrent () .getSessionScope () .put ("Empno", empno);

    Getting value of session scope:
    Object empno is ADFContext.getCurrent () .getSessionScope () .get ("Empno");.

    ViewProject:
    Set variable in the scope of the session:
    FacesContext.getCurrentInstance () .getExternalContext () .getSessionMap () .put ("Empno", empno);

    Getting value of session scope:
    Object empno is FacesContext.getCurrentInstance () .getExternalContext () .getSessionMap () .get ("Empno");.

    Getting value of scope jspx page session
    #{sessionScope.Empno}

    Hi Samson,.

    Here are the groovy expression to access the value of the sessionscope:

    adf.context.sessionScope.role
    

    But, as the said John instead to access the session of the model can be a method of model (whether in AMImpl or voImpl) who takes the role as a parameter value and sets the value of the variable binding of the vo, then call this AM from the bean method passing the role value by getting the scope of the session.

    Jean Lou

  • How to set the value of the variable bind in VO on page load?

    Hello, I use JDeveloper 11.1.2.3.0.

    I created a VO in my application that uses a variable binding in the where clause. I want to put the value of this variable on the loading of the page automatically.

    I read that I can do this through setNamedWhereClauseParam()... but I can't find out where and how to use it.

    Can anyone help please?

    You can put in different places:

    AppModuleImpl,

    ViewObjectImpl,

    ViewRowImpl

    Just him export the customer interface and use whenever you want

  • How to use a variable binding in an IN clause

    I'm trying to use a variable binding in an IN clause where the column is a type varchar2. Something like:
    select *
    from test
    where test_column in (:bindVariable)
    I tried the assignment of channels bind variable separated by commas (for example, test, test, test) and separated by commas strings with quotation marks (for example. 'test', 'test', 'test'). None of these work. Anyone know the correct way to do this?

    Thanks in advance.

    http://tkyte.blogspot.com/2006/06/varying-in-lists.html

    Presents many options.

  • 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

  • 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)

  • 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

  • Using the data binding on each button in a ToggleButtonBar

    Can someone tell me if it is possible to use the data binding on the individual buttons in a ToggleButtonBar and, if so, how?

    I want to be able to use the data binding for each individual button in the ToggleButtonBar 'enabled' property, but is not possible using MXML because the ToggleButtonBar takes a data provider to display labels for each button and, obviously, I can't set the "enabled" on the values of dataprovider property because they are not objects Button. For example, I'm not allowed to do something like this:

    < mx:ToggleButtonBar id = "tbb".
    toggleOnClick = 'true '.
    itemClick = "clickHandler (event)."
    creationComplete = "tbb.selectedIndex = 1" >

    < mx:Button label = "A" active = "{...}" / >
    < mx:Button label = "B" enabled = "{...}" / >
    < mx:Button label = "C" enabled = "{...}" / >

    < / mx:ToggleButtonBar >

    Ah! The ToggleButtonBar. Liaison. MXML. mysterious. Not obvious. But yes, we CAN do...
    First, you will need to get the buttons to toggle. Did you know that they are actually ButtonBarButtons? Once you get an instance of each of them, you can do the binding in MXML.

    Each button LINK below the ViewStack is bound to a ToggleBarButton.
    When you click a related button below, the LINK button above it will have its enabled enabled/disabled property. Then a link fires, setting the enabled property of the related ToggleBarButton.

    This example requires that you know advance how toggle buttons and buttons, you have, so it will not evolve well. Whenever you add a button, you will need to enter hard in the 'getButtons' function, which implements the ButtonBarButton instances. But if you have a known quantity of buttons, no problem.

  • How to use the data binding on a cluster?

    Hello

    I just discovered the data binding and used it on some primitive controls/indicators. I love the cleanliness of the approach (no additional querying and son required!)

    Now, this page gives to think I can link a cluster with a shared too variable. However, when I right click-> properties, I see that the tabs appearance and Documentation (and I know that I did not accidentally choose an element inside the cluster, because (1) there is a typedef strict, and said the title of (2) 'The Cluster Properties' dialog box). Where can I find the data binding tab?

    Thank you

    Hi JKSH,

    What you're doing is possible if you make the file .ctl as the definition of type rather than a strict definition of type. With a strict definition of type all instances of the same .ctl file link that is why you cannot use data binding.

  • ViewObject accesses the variable binding a sessionScope setting?

    Hello

    using the Fusion of ADF Jdev11g request
    ViewObject get a sessionScope parameter and set in the binding variable? without the help of executeWithParameter

    Thank you
    greenApple

    N °

    You must call a method in the model layer and pass the parameter.

    Timo

  • declare the variable binding

    I do homework here and ran into the wrong hope that someone here can help

    1. I thought that I understand the conscept of variable binding (which I think it is the same concept as the pointer in C/C++ programming), is that correct?

    2. I write the code and find the problem below, please point out what I did wrong?


    SQL & gt; describe the plants
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    PLANTID NOT NULL NUMBER (5)
    COMMONNAME NOT NULL VARCHAR2 (30)
    LIKE NOT NULL VARCHAR2 (30)
    SPECIES NOT NULL VARCHAR2 (30)
    FLOWERCOLOR VARCHAR2 (10)
    HEIGHT NUMBER (4.1)
    DATE OF ACQUIREDDATE
    LISTPRICE NUMBER (6.2)




    SQL & gt;
    declare


    bv_color variable varchar2 (10);
    v_price plants.listprice%Type;



    cursor cur_color is
    Select distinct lower (flowercolor) color
    plants;



    Start


    for rec_color looping cur_color

    : bv_color: = rec_color.color;



    Select avg (listprice)
    in v_price
    plants
    where lower (flowercolor) =: bv_color;



    dbms_output.put_line)
    "The average price for our plants with ' |: bv_color |"
    "flowers is $' | Round(v_price,2) | '.');
    dbms_output.put_line ('thank you');



    end loop;



    exception
    while others then
    dbms_output.put_line (' my exception:' | sqlcode |)
    ' : ' || SQLERRM);
    end;
    /
    SP2-0552: Bind "BV_COLOR" variable not declared.

    This is the way of declaring bind variables in SQL * more.

    In a PL/SQL block, you do not use bind variables like SQL * more. You just use normal variables. The PL/SQL engine is smart and sends SQL statements to the SQL engine containing all PL/SQL variables converted to bind variables. If it works transparent in PL/SQL and you don't have to do something more.

    Kind regards
    Rob.

  • Using the Variable more than once in a statement

    I tried searching but can't seem to find any other discussions where people have this problem.

    I use a select statement, and it contains, I have the same variable used several times. The problem is that when I run the statement, the substitution variable appears as many times as the variable appears in the declaration. It is not a show-stopper, but it's pretty boring. There is an option somewhere that I don't see who would do this work by popping only once?

    Normally you use bind variables (:) instead of substitution variables (&), but if you insist on using them, use DEF to define them before issueing your statement.

    Have fun
    K.

Maybe you are looking for

  • Satego P100-10F: Windows XP Lan, usb slots and the sound does not work

    Hello I have problems with windows vista, so I checked the forum to get information on the windows xp installation. I downloaded the drivers windows xp since the P100 Satellite (pspa6e), my only problem is that the LAN, usb slots and my sound does no

  • Pro iPad battery problem

    I bought an iPad pro 128 gig and the battery life doesn't help. After a full charge and it is 100%, then without removing fees then watching youtube videos and the battery loses power and it's always on the charge. It breaks down within 2 hours of 10

  • Recovery discs - HP Pavilion dv6t 1200 CTO Entertainment Notebook PC

    I need to order Windows Vista 64-bit for a HP Pavilion dv6t 1200 CT laptop.  I don't see on the driver and software for the model page.  Does anyone know a number I can call to see if you can order them? Thank you!

  • &lt; Unknown &gt; seller and no updated Version

    Hello I hope that there may be a simple solution to my problem. I created an application in Blackberry JDE (4.2.1), changed the properties of the file to include a version 1.0 and the name of the seller, workspace I built, Registered and signed the a

  • BlackBerry software Blackberry Q10 - Outlook calendar

    Try to sync tasks and notes sections from my Outlook to my new Q10 calendar. Through transfer of Blackberry link old 9330 to new Q10, but still not found of tasks and notes. Appreciate any assistance.