How to make a bind variable out of a comparison like statement

I have a statement similar to the following -
select x from atable where acolumn like '1%';
How do I turn that into a variable in an anonymous block like -
declare
l_var varchar2(1) := '1';
begin
select x from atable where acolumn like 'l_var%'
end;
I need to prevent the database from using a literal in the plan so I need to convert like '%1' into a variable.
Any suggestions?

Not quite sure what you mean by 'binding' or 'substitution'.
If you mean bind variables, the yes oracle does automatically use bind variables:
SQL> CREATE TABLE atable
  2  (
  3          x VARCHAR2(10)
  4  )
  5  /
Table created.
SQL>
SQL> INSERT INTO atable VALUES ('1234');
1 row created.
SQL> COMMIT;
Commit complete.
SQL>
SQL> set serveroutput on size unlimited
SQL>
SQL> declare
  2    l_var atable.x%TYPE := '1';
  3    l_str atable.x%TYPE;
  4  begin
  5    select x
  6      into l_str
  7      from atable
  8     where x like l_var || '%';
  9
10    dbms_output.put_line ('l_str = "' || l_str || '"');
11  end;
12  /
l_str = "1234"
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT SQL_TEXT FROM v$sql WHERE sql_text LIKE 'SELECT %ATABLE%' AND sql_text NOT LIKE '%V$SQL%';
SQL_TEXT
SELECT X FROM ATABLE WHERE X LIKE :B1 || '%'
SQL>Where that is the sql statement that the sql engine actually ran on behalf of the pl/sql routine.
GP>

Similar Messages

  • HT4642 ios numbers:how to make cell height variable with auto line brake setting ?

    ipad numbers; How to make cell height variable with auto line break setting?

    That's strange. I responded earlier and the whole message got trashed. Hence the test post before retyping the entire thing again.
    Thanks for the reply.
    The video clip is a single screen capture video clip. This is what I've found by playing around with this more.
    The original clip resolution is greater than 640x480. If I use QT Pro to convert the original clip to 640x480 and then use either Flip4Mac or PE7, then the resolution looks good.
    Just trying to figure out if should keep all workflow on the MacOS side. There are several different version of Flip4Mac. $49 gives me 640x480, but if I ever want to make it slightly larger then I would need to go with the $99 or HD version.
    I also tried to export to AVI with QT Pro and the import with Windows MovieMaker but it didn't work really good. I liked the simplicity (since PE7 hogs a lot of resources especially through VMWare).

  • How to use the bind variable in custom.pll

    Hi,
    How to use the bind variable in custom.pll.Its through error.
    any one gem me.
    very urgent.
    M.Soundrapandian.

    Hello,
    Please, ask this kind of questions in the e-business forum.
    Francois

  • How to declare a bind variable with 'date' data type in command prompt?

    how to declare a bind variable with 'date' data type in command prompt?
    sql>variable q date;
    when i execute it show list of datatypes

    Hi,
    As Lokanath said, there are no DATE bind variables.
    You can use a VARCHAR2 bind variable, and convert it to a DATE in your SQL statment.
    If you're using SQL*Plus, consider a substitution variable. It won't be as efficient as a bind variable, but it will be as convenient.
    For example:
    DEFINE  first_entrry_date = "DATE '2010-06-20''
    SELECT   ...
    WHERE   entry_date >= &first_entry_date
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to make the zoom in/out scale appear in the media browser ?

    How to make the zoom in/out scale appear in the media browser ? My videos only appear as a file list (only the names) and the zoom in/out device is currently not in the media browser...

    I meant that there is no "Icon mode" button or "List mode" button in my media browser. How to make them appear ?

  • How to make a short clip out of the original one ?

    Some days ago, I asked a question on editing a clip in this forum. The responder asked me to provide a few seconds of the clip for his examination. But I got stuck. I didn't know how to make a clip of a few seconds out of the original clip and that it had the exact same format and properties as the original clip.
    Neither Premier nor After Effect have an ouput option such as "same as original source" .
    So, my question is how to make a short clip out of the original one with everything the same properties as the original one.
    Thanks in advance.

    May be I haven't made myself clear
    Sorry, but I think that I am still not following you.
    I want to export and render the short clip to a new file which I want to have everything the same as the original clip. Just like I cut off a few seconds off it and that few seconds becomes an independent file.
    OK, you have your original source file. It is complete and is also unaltered. If you want a "Copy" of it, just use Windows Explorer, or similar to make that Copy. If you want a separate file of your edited version of that source file (as it appears in the Timeline), use the WAB (Work Area Bar) to include just that edited instance of the source footage, and Export just the WAB. This will give you a separate file with the edits in it.
    I still feel that neither is what you want. If you can step me through, maybe with screen-caps, what you have and what you wish to end up with, I can see the operation more clearly.
    Good luck,
    Hunt

  • How to make selection parameter gray out, not changeble mode

    Hi Experts,
      Selection screen having parameters, I am putting default values in that parametrs.
    How to make this parameter gray out, not changeable mode.
    Thanks in advance
    mahahe.
    See comments below
    Edited by: Rob Burbank on Jul 1, 2009 12:43 PM

    Hi,
    For the parameters required, while declaring them use the MODIF ID, lets say you have choosen the modif id as SC1.
    i.e. parametes: p_mat type matnr DEFAULT '100' MODIF ID SC1.
    Then in the initialization event, code as below.
        LOOP AT SCREEN.
          IF screen-group1 = 'SC1'.
            screen-input = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
    It will work.
    Regards,
    Nangunoori.

  • How can i create "bind variable"

    How can i create "bind variable" in my DB to support any procedure in my DB.
    Thank you very much.

    In SQL*PLUS we can defined bind variable
    SQL>var x varchar2(250); -- Is x bind variable or i'm misunderstand ?
    and ... in my procedure i can used ' &x ' to pass valued of 'x' from sql prompt to my procedure.
    but i'm not sure variable x is still remain in DB because i need to pass variable
    " v_stmt := 'and employee_id between ..... ' " from FORM to PROCEDURE in DB
    how can i do

  • How to make it repleatedly printed out by using timer??

    Dear Friends:
    I have following code to run, When I press R to repeat println, only 1 line print out,
    But I hope to make it continueously print out.
    How to make it repleatedly printed out until I press CTRL + C key ??
    Thyanks
    import java.util.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.*;
    public class CertainAndRepeatTime{
      public static void main(String[] args) throws IOException{
        int delay = 1;
        Timer timer = new Timer();
        ActionListener actionListener = new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              System.out.println("Hello World Timer");
        System.out.println("What do you want (Certain time or Repeat time)?");
        System.out.print("Please enter \'C\' or \'R\' for that: ");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String ans = in.readLine();
        System.out.print("Please enter  ans=" + ans  + " IsTrue=  " + (ans.equals("R") || ans.equals("r")) +"\n");
        if (ans.equals("C") || ans.equals("c")){
          //System.out.println("This line is printed only once start...");
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed only once.");
          },delay,1);
        else if(ans.equals("r") || ans.equals("R")){
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed repeatedly.");
          },delay, 1000);
        else{
          System.out.println("Invalid Entry.");
          System.exit(0);
        System.exit(0);
    }

    The Timer is working fine, but because it runs in another Thread, your program is ending before the Timer can repeat.
    The simplest way to make your program wait until it is force-quitted as you describe would be to make an infinite loop (although this isn't very good practice), like this:
        else if(ans.equals("r") || ans.equals("R")){
          timer.schedule(new TimerTask(){
            public void run(){
              System.out.println("This line is printed repeatedly.");
          },delay, 1000);
        while(true){} //This will make your main thread hang.
        }A better way, though, would be to listen again with your System.in reader until they enter a letter that means quit.

  • How to properly set bind variables

    Dear All,
    I am currently confused about how to properly set my Bind Variables
    I have this view using HR standard schema
    Select *
    from Employees
    where EMPLOYEE_ID = :EMP_IDI somehow see three options on how to use this bind variable in an application module.
    Option 1:
    ViewObjectImpl view = this.getEmployeesView();
    VariableValueManager vm = view.ensureVariableManager();
    vm.setVariableValue("EMP_ID", value);
    view.executeQuery();Option 2:
    ViewObjectImpl view = this.getEmployeesView();
    view.setNamedWhereClauseParam("EMP_ID", value);
    view.executeQuery();Option 3:
    EmployeeViewImpl empView =this.getEmployeesView();
    RowSetIterator it = empView.createRowSetIterator(null);
    empView.setEmployeeId(value);
    empView.executeQuery();Question is which is which and what should I use?
    JDEV 11G PS3

    I use is this
    DCIteratorBinding iteratorStatus = Util.getIterator("NameIterator");
    operationBinding.execute();
    Util is reserved in a class.
    public static DCIteratorBinding getIterator(String iteratorName){
    return getDCBindings().findIteratorBinding(iteratorName);
    }

  • How to identify the bind variable peeking problem?

    How to identify the bind variable peeking problem whether my db hitting or not and how to resolve it?
    currently we are doing the dbms_stat of application schema's with gather auto option and i hope this option we take the histogram stats also. Is there any option to improve it and its highly transactions oltp env of 11g.

    What is your exact 4 digits Oracle version ?
    Bind peeking issues are supposed to be solved with adaptative cursor sharing in 11.1 and 11.2:
    11.1 http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/optimops.htm#sthref919.
    11.2 http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/optimops.htm#PFGRF94588
    which says also:
    >
    Adaptive cursor sharing is enabled for the database by default and cannot be disabled. Note that adaptive cursor sharing does not apply to SQL statements containing more than 14 bind variables.
    >
    Edited by: P. Forstmann on 10 nov. 2011 13:50

  • Bind variables are not used in select statement

    Hello all of you,
    I have two parameters in Report 6i.
    1) Department
    2) Section
    There are many section in a single department. Both parameters are selected from list. The list for department name is as follows -
    select deptname from department_master order by deptname
    It works very well. The value is stored in :p_dept_name.
    I want to display section of selected department only using following code :-
    select sectname from section_master a, department_master b where a.deptcode = b.deptcode and b.deptname = :p_dept_name
    The value is stored in :p_sect_name.
    But it does not work. bind variables are not allowed in select statement, then how can I do this???
    Please suggest me.
    Thanx,
    Regards,

    Vikas,
    the forum is full of threads about that.
    Dependent Parameters in Reports are possible out-of-the-box in Reports.
    If you're running your report on the web, have a look at Metalink Note:185951.1
    Regards
    Rainer

  • Bind Variables are not allowed in select statement

    I created a lov to one parameter field in a report using select statement.
    select distinct mtrl_group||' - '||grup_desc
    from mtrl_mast a , grup_mast b
    where financial_year||financial_month = :P_cutofff_period)
    and a.mtrl_group = b.grup_code
    this is my select statement & i got the above error.
    how can i fix bind variables in this.
    Pls help me......

    Hi,
    have a look at Metalink-Note 185951.1     
    SAMPLE - How to create a parameter LOV based on another parameter value?
    Regards
    Rainer

  • How to substitute a bind variable for a IN condition?

    Dynamically I am setting the WHERE condition for one of my blocks using SET_BLOCK_PROPERTY Built in. The condition that I am attaching has two IN conditons..
    For Eg.,
    contracts_tbl.status_col IN ('NEW', 'OLD', 'EXPIRED', 'OPEN')
    AND contracts_tbl.id_col IN (1, 2, 3, 4)
    The number of choices in the IN condition will vary depending upon the user choice in my screen. Because of this the parsed SQL state is could not be shared and multiple of these are getting created in shared pool. To avoid this I would like to use bind variables.
    There are two ways I am trying to do this..
    1. Generating one bind variable for each value. i.e.,
    contracts_tbl.status_cod IN (:global.var1, :global.var2,
    :global.var3)
    Now this could result it memory error if no. of choices exceeds the avilable memory. Also its a tedious task to purge the variables after querying the block. Also because of multiple IN conditions, the chances of different set of selections are possible and then again sharing will be minimal.
    2. The second method is to set the one bind variable for each IN condition. i.e.,
    :GLOBAL.Var1 := '( 'NEW', 'OLD', 'EXPIRED', 'OPEN' )';
    :GLOBAL.Var2 := '(1, 2, 3)';
    contracts_tbl.status_col IN :GLOBAL.Var1
    AND contracts_tbl.id_col IN :GLOBAL.Var2
    In this case, forms is not querying as the IN condition takes the global variable value as one string and the query returns no rows though there are plenty available for each status. Also any NUMBER type condtions erroring out as the , and ( are invalid numerals.
    Q: Is there anyway you can make this work? or Is there any other better method to substitute bind variables in place to avoid creating new set of statements for each query in the shared pool?
    Your suggestions and pointers are higly appreciated. Please respond immediately as this is a P1.
    Thanks,
    -- Raam.

    2. The second method is to set the one bind variable for each >>IN condition. i.e.,
    :GLOBAL.Var1 := '( 'NEW', 'OLD', 'EXPIRED', 'OPEN' )';
    :GLOBAL.Var2 := '(1, 2, 3)';
    contracts_tbl.status_col IN :GLOBAL.Var1
    AND contracts_tbl.id_col IN :GLOBAL.Var2 This method should work - not sure if you put exact syntax in or not but your first assignment would cause a problem as everywhere you want one ' mark you would have to put two so that it does not close your quoted string
    Try the following syntax:
    :GLOBAL.Var1 := '( ''NEW'', ''OLD'', ''EXPIRED'', ''OPEN'' )';
    :GLOBAL.Var2 := '(1, 2, 3)';
    SET_BLOCK_PROPERTY('blk name',
    default_where,
    'contracts_tbl.status_col IN ' || :GLOBAL.Var1
    || ' AND contracts_tbl.id_col IN ' ||
    :GLOBAL.Var2);
    Hope this helps,
    Candace Stover
    Forms Product Management

  • How to set default bind variable value to task parameter value

    Hi,
    I 'm implementing a BPEL process with a human task, and I autogenerate the task form. I have a custom sql table that stores opinions, different processes should show different opinios, so my ADF table can only show records related to that process. A custom process number is sent to the task form as a task parameter. How do I use that value as the bind variable default and only value?
    Thanks,
    I.D.

    Hi Shay and thanks for your reply,
    What I want is what you have but without the login page. I tried to start my flow with an action and for some reason it didn't work.
    Is there anything else you can tell me?
    Thanks,
    I.D.
    P.S. I was able to get it to work using the aproach Frank Nimphius described in another post.
    Re: How do I prepopulate a bind variable from a session variable?
    Anyway just out of curiosity could you please tell me if I could have done it your way?
    Thanks a lot,
    I.D.
    Edited by: user8696770 on 5/Ago/2009 7:12

Maybe you are looking for

  • SSRS Cascading Parameter Setting Default Value of Parameter by Expression

    Hi All, I need some help on an issue I am running into in SQL server 2008 report parameters. I have the following Report Parameters defined: 1) @PredefinedDateSelection - Boolean (User Selectable True/False, Default Value - 'False') 2) @StartDate - T

  • How do I delete multiple rows and columns in an image?

    I am looking into how digital SLRs extract video data from a CMOS sensor. To give an example, the GH1 from Panasonic can record video at 1920 x 1080 from a 12 MPixel sensor that, say, is 4000 horizontal x 3000 vertical. How they do that seems to be n

  • Using iMac as base station

    First, forgive me as I new to Apple (former PC). I have the new iMac 27" i7 and was told that it has a built-in Airport Extreme. I just purchase an Airport Express and can't figure out how to get the AirPort Utility to recognize my iMac as the Base S

  • CD Artwork problems

    I had gotten a few songs from a CD of the bad "The Pillows" not long ago and had used a Photobucket graphic for hte CD cover. But when I synced my iPod and went to listen, the CD cover was all wrong but when I pressed the space bar to the CD Cover Me

  • PHP Self Processing Form

    Hi I'm tring to adapt a form processing script that appears in the book "PHP Web Development with Macromedia Dreamweaver MX 2004" published by Apress. The example in the book has a simple form containing a "comments" field and a "email" and "confirm