LIKE statement in CASE statement

Hi,
I have a table called amounttagged as below
Amount Tag
10000 ABDCBD
20000 CBDADE
30000 CBDABD
40000 ABDADE
and my sql statement is as below,
select Amount, case when tag like '%ABD%' then 'ABD' else when tag like '%CBD%' then 'CBD' else 'ADE' end as tag
from amounttagged
The problem is when the tag is ABDCBD it will only be displayed for 'tag like '%ABD%' statement and the tag is only ABD. How can I make it to appear for both tag ABD and CBD?
Pls see example of result of sql
Amount Tag
10000 ABD
20000 CBD
30000 CBD
40000 ADE
How can I make the amount 10000 appear for tag CBD as well? Pls advise.

I just tested mine, and I missed off a couple of commas...
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 10000 as amount, 'ABDCBD' as tag from dual union all
  2             select 20000, 'CBDADE' from dual union all
  3             select 30000, 'CBDABD' from dual union all
  4             select 40000, 'ABDADE' from dual)
  5  --
  6  -- end of test data
  7  --
  8  select Amount, decode(rn,1,abd,2,cbd,ade) as tag
  9  from (
10        select Amount,
11               case when tag like '%ABD%' then 'ABD' else null end as abd,
12               case when tag like '%CBD%' then 'CBD' else null end as cbd,
13               case when tag not like '%ABD%' and tag not like '%CBD%' then 'ADE' else null end as ade
14        from t /* amounttagged */
15       )
16      ,(select rownum rn from dual connect by rownum <= 3)
17  where decode(rn,1,abd,2,cbd,ade) is not null
18* order by amount, tag
SQL> /
    AMOUNT TAG
     10000 ABD
     10000 CBD
     20000 CBD
     30000 ABD
     30000 CBD
     40000 ABD
6 rows selected.
SQL>

Similar Messages

  • Help with TYPE and LIKE statements

    HI guys,
    I know this is really novice stuff, but I am a little confused.
    Can anyone please explain the exact difference between TYPE and like with the help of a program, to understand it.
    What situation would demand the use of each of the LIKE statement, since I can do all these things using the TYPE ?

    Hi Akhil,
    I summarized the info in SDN posts and SAP Help, to make it easier for you to understand. I also included some code snippets. Hope these prove to be helpful to you.
    The following is from SAP Help:
    The Additions TYPE and LIKE
    The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.
    ·        Definition of local types in a program
    ·        Declaration of data objects
    ·        Dynamic creation of data objects
    ·        Specification of the type of formal parameters in subroutines
    ·        Specification of the type of formal parameters in methods
    ·        Specification of the type of field symbols
    A known data type can be any of the following:
    ·        A predefined ABAP type to which you refer using the TYPE addition
    ·        An existing local data type in the program to which you refer using the TYPE addition
    ·        The data type of a local data object in the program to which you refer using the LIKE addition
    ·        A data type in the ABAP Dictionary to which you refer using the TYPE addition. To ensure compatibility with earlier releases, it is still possible to use the LIKE addition to refer to database tables and flat structures in the ABAP Dictionary. However, you should use the TYPE addition in new programs.
    The LIKE addition takes its technical attributes from a visible data object. As a rule, you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context.  The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
    ·        In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.
    ·        You can also refer to the data objects of other visible ABAP programs. These might be, for example, the visible attributes of global classes in class pools. If a global class cl_lobal has a public instance attribute or static attribute attr, you can refer to it as follows in any ABAP program:
    DATA dref TYPE REF TO cl_global.
    DATA:  f1 LIKE cl_global=>attr,
           f2 LIKE dref->attr.
    You can access the technical properties of an instance attribute using the class name and a reference variable without first having to create an object. The properties of the attributes of a class are not instance-specific and belong to the static properties of the class.
    Example
    TYPES: BEGIN OF struct,
             number_1 TYPE i,
             number_2 TYPE p DECIMALS 2,
           END OF struct.
    DATA:  wa_struct TYPE struct,
           number    LIKE wa_struct-number_2,
           date      LIKE sy-datum,
           time      TYPE t,
           text      TYPE string,
           company   TYPE s_carr_id.
    This example declares variables with reference to the internal type STRUCT in the program, a component of an existing data object wa_struct, the predefined data object SY-DATUM, the predefined ABAP type t and STRING, and the data element S_CARR_ID from the ABAP Dictionary.
    The following info is from various posts:
    --> Type: It is used when userdefined object link with SAP system data type.
    Local types mask global types that have the same names. When typing the interface parameters or field symbols, a reference is also possible to generic types ANY, ANY TABLE,INDEX TABLE, TABLE or STANDARD TABLE, SORTED TABLE and HASHED TABLE.
    --> Like: It is when data object link with the other data object.
    --> TYPE, you assign datatype directly to the data object while declaring.
    --> LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
    you can refer to all visible data objects at the ABAP program's positon in question. Only the declaration of the data object must be known. In this case it is totally irrelevant whether the data object already exists physically in
    memory during the LIKE reference. Local data objects mask global data objects that have the same name.
    --> Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
    Types: var1(20) type c.
    data: var2 type var1. ( type is used bcoz var1 is defined with TYPES and it
    does not occupy any memory spce.
    data: var3 like var2. ( like is used here bcoz var2 is defined with DATA
    so it does occupy space in memory ).
    data: material like mara-matnr. ( like is used here bcoz mara-matnr is stored in memory)
    --> Type refers the existing data type
    --> Like refers the existing data object
    Please Reward Points if any of the above points are helpful to you.
    Regards,
    Kalyan Chakravarthy

  • SQL LIKE statement in JSP

    I tried to write a query in jsp page using LIKE statement. However, Apache Tomcat report back an error in the query string. I tried to run the same query style in MS Access and it works. Can someone please tell me where is the error in jsp code:
    JSP Code:
    sql = "SELECT tblStudent.firstName, tblStudent.lastName, tblStudent.studentID FROM tblStudent WHERE (((tblStudent.firstName) LIKE '%" + g_firstNameInput + "%')) ORDER BY tblStudent.firstName";
    MS Acccess:
    SELECT tblStudent.firstName, tblStudent.lastName, *
    FROM tblStudent
    WHERE (((tblStudent.firstName) Like '*e*'))
    ORDER BY tblStudent.firstName;
    PS: I tried changing from '%' to '*' already, but still does not work
    Thanks

    Don't use JSP for SQL querries... to complicated.
    1) Write a Java application that does what you want (as far as interacting with the database
    2) Isolate the database access code into its own class/classes
    3) Double check that you can then use those isolated classes inside a command line application
    4) Adapt the code you used in 3) to use those same classes from a JSP - preferrably using Java Beans and DTOs

  • Complex query using 'sql like' statement.

    Given the following basic class structure.
    public class Project {
         private String name;
         private Architecture architecture;
         private Resources resources;
         public Architecture getArchitecture();
         public void setArchitecture(Architecture architecture);
         public Resources getResources();
         public void setResources();
         public String getName();
         public void setName(String name);
    public Architecture {
         private String name;
         public String getName();
         public void setName(String name);
    public Resources {
         private String name;
         public String getName();
         public void setName(String name);
    we want to be able to do a query like:
         find all Projects where (Project.name.indexOf("a") > 0) &&
    (Project.architecture.name.indexof("b") > 0)
    In essence a "like" comparison across String properties of the JDO objects.
    Is it supported in KODO?? Anyone tried it out? Also, is it possible to
    generate SQL type query in KODO?
    rgds
    NK

    Note that this relies on a current bug in Kodo -- we should escape out the
    '%' character, but we don't.
    Some day, we'll fix that bug. But, before then, we will introduce a proper,
    supported mechanism for finding records that have a string field that
    contains some substring.
    -Patrick
    On 5/30/02 6:12 PM, "Andrew" <[email protected]> wrote:
    Hi,
    I wanted to perform a LIKE statement to get records where the partial string
    existed in a field -> eg. select a where a.field LIKE "SPRING" - 2 records,
    SpringSteen & MindSprings
    I did it like this:
    setFieldName("Spring");
    String sFilter = "field.startsWith(%\" + getFieldName() + \"%)"; -
    Extent anExtent = pm.getExtent(this.getClass(), true);
    Query aQuery = pm.newQuery(this.getClass(), anExtent, sFilter);
    return (Collection) aQuery.execute();
    Hope it helps. oh, don't know about the generating sql query.
    Nitin Kanani wrote:
    Given the following basic class structure.
    public class Project {
    private String name;
    private Architecture architecture;
    private Resources resources;
    public Architecture getArchitecture();
    public void setArchitecture(Architecture architecture);
    public Resources getResources();
    public void setResources();
    public String getName();
    public void setName(String name);
    public Architecture {
    private String name;
    public String getName();
    public void setName(String name);
    public Resources {
    private String name;
    public String getName();
    public void setName(String name);
    we want to be able to do a query like:
    find all Projects where (Project.name.indexOf("a") > 0) &&
    (Project.architecture.name.indexof("b") > 0)
    In essence a "like" comparison across String properties of the JDO
    objects.
    Is it supported in KODO?? Anyone tried it out? Also, is it possible to
    generate SQL type query in KODO?
    rgds
    NK
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Not Like statement in Crystal?

    In SQL server there is a statement that goes along the lines of (field1) not like '09%'
    In Crystal Reports there is a statement "Like".  Is there any statement in Crystal that is "Not Like"?
    I'm trying to get a wildcard of 09 to work in Crystal so far I have......
    (field1) <> "09*"
    But it needs to be something like the following ........
    (field1) not like "09*"
    Does Crystal have a Not Like statement?  What are my choices if Crystal does not have that statement?
    Thanks

    I'm looking for anything that does not contain any thing like "09".  The actual "09" field is "09xx", and the report will need to pull back everything that is not "09"
    I used the * symbol to try and do a wildcard that would not pull back anything that is like "09".
    I was wondering if the * symbol was Crystal Reports answer to "Not Like"?

  • Named query problem with "like" statement

    I'm having issues with a named query that contains a 'like' statement in it. I have other named queries that have like statements that have hardcoded like values in them that work fine.
    (i.e. select * from foo where foo.col1 like 'foo%' )
    But when the like value to be tested is a parameter, it doesn't seem to work at all, no matter what variation i've tried, other than no wildcards.
    (i.e.
    this DOES work
    select * from foo where foo.col1 like #fooParm
    this DOES NOT work
    select * from foo where foo.col1 like '%#fooParm%'
    Any suggestions on how to get this to work?
    Thanks in advance

    Try building your select statement in a different way.
    Instead of:
    select * from foo where foo.col1 like '%#fooParm%'
    Try something like:
    select * from foo where foo.col1 like '#fooParm'
    And include the wild cards in the parameter.
    i.e. if fooParam was 'abc', make fooParm = '%abc%'

  • Multiple like statements in a query

    Hi,
    I wonder if it's possible to have multiple like statements in a query.
    suppose instead of
    select * from someTable where remarks like '%ab%'
    I want to search for many string patterns such as '%edi%' '%odi%' '%di%' '%gf%' '%od%' '%podi%' etc. in one query.
    BTW, the table contains many millions of records.
    Regards
    Crusoe
    Edited by: Crusoe on 19-Jan-2009 00:25

    Crusoe wrote:
    This regexp_like function does not work with the development server to which I have rights to create tables etc. I guess it only works in 10g or greater. However i tried a quick test in the production server and it worked. It returned rows where the values between the | characters were found anywhere in the field ( I must learn this regex syntax sometime). Yes, regular expressions are 10g upwards. (You really should have your development server reflect your production server)
    There was a thread a while back giving an introduction to regular expressions...
    Introduction to regular expressions ...

  • Indixes and like statement

    hi folx,
    hmm i need to know of there is any chance
    to create an index or a kind of hash table
    for a column (varchar) wich needs to be compared to '%string%'. No index is usefull for me
    cause to many differences for bitmap index.
    normal and reverse indexes would imho
    not be used by the parser.
    I thought about context cartridge but varchar(80) is too small i think to get any performance back from the query.
    thanks in advance
    mfg
    markus

    Statement should be quicker than Prepared Statement, because
    Statment do only one thing: send that sql to server or run that sql directly.
    Prepared Statement should do two (or more than two)things:
    1. parse your sql first, prepare a store procedure, then call that store procedure.
    Or
    2. prase your sql first, then use your value to replace "?" for getting a new sql, then work like Statement.
    Prepared Statement is quiker when you use it repeatedly.

  • How is it possible to use Index Seek for LIKE %search-string% case?

    Hello,
    I have the following SP:
    CREATE PROCEDURE dbo.USP_SAMPLE_PROCEDURE(@Beginning nvarchar(15))
    AS
    SELECT * FROM HumanResources.Employee
    WHERE NationalIDNumber LIKE @Beginning + N'%';
    GO
    If I run the sp first time with param: N'94', then the following plan is generated and added to the cache:
    SQL Server "sniffs" the input value (94) when compiling the query. So for this param using Index Seek for AK_Employee_NationalIDNumber index will be the best option. On the other hand, the query plan should be generic enough to be able to handle
    any values specified in the @Beginning param.
    If I call the sp with @Beginning =N'%94':
    EXEC dbo.USP_SAMPLE_PROCEDURE N'%94'
    I see the same execution plan as above. The question is how is it possible to reuse this execution plan in this case? To be more precise, how
    Index Seek can be used in case LIKE %search-string% case. I expected that
    ONLY Index Scan operation can be used here.
    Alexey

    The key is that the index seek operator includes both seek (greater than and less than) and a predicate (LIKE).  With the leading wildcard, the seek is effectively returning all rows just like a scan and the filter returns only rows matching
    the LIKE expression.
    Do you want to say that in case of leading wildcard, expressions Expr1007 and Expr1008 (see image below) calculated such a way that
    Seek Predicates retrieve all rows from the index. And only
    Predicate does the real job by taking only rows matching the Like expression? If this is the case, then it explains how
    Index Seek can be used to resolve such queries: LIKE N'%94'.
    However, it leads me to another question: Since
    Index Seek in
    this particular case scans
    all the rows, what is the difference between
    Index Seek and Index Scan?
    According to
    MSDN:
    The Index Seek operator uses the seeking ability of indexes to retrieve rows from a nonclustered index.
    The storage engine uses the index to process
    only those rows that satisfy the SEEK:() predicate. It optionally may include a WHERE:() predicate, which the storage engine will evaluate against all rows that satisfy the SEEK:() predicate (it does not use the indexes to do this).
    The Index Scan operator retrieves
    all rows from the nonclustered index specified in the Argument column. If an optional WHERE:() predicate appears in the Argument column, only those rows that satisfy the predicate are returned.
    It seems like Index Scan is a special case of Index Seek,
    which means that when we see Index Seek in the execution plan, it does NOT mean that storage engine does NOT scan all rows. Right?
    Alexey

  • Would like to develop: cases, silicon jackets & sc...

      Would like to develop: cases, silicon jackets & screen protectors for Nokoia cell phones (like I do for Apple-iphones). Where can I find detailed dimensional drawings? (Apple publish such information for case developers under: http://developer.apple.com/ipod/cases.html
    Waiting on your reply/answer'
    Yours truly,
    Erez Weintraub
    Moderators Note : personal info removed.
    Message Edited by shameers on 14-May-2009 08:49 AM

    Contact Nokia for that. This forum is populated by users of Nokia products, not by Nokia staff (other than the moderators who cannot offer assistance).
    Was this post helpful? If so, please click on the white "Kudos!" star below. Thank you!

  • How to use a parameter field value as a substring in a "like" statement?

    Hi all,
    I'm trying to use a parameter field in a Record selection formula where the parameter field value would be a substring of the data stored in the field.
    My parameter field (SlctResearcher) is constructed as follows:
    Type: string
    List of Values: static
    Value Field: (Reports) RptAuthors
    (in Value Options) Allow custom values?: True
    {Reports.PubDate} in DateTime (2009, 04, 01, 00, 00, 00) to DateTime (2010, 03, 31, 23, 59, 59) and
    {Reports.RptAuthors} like "*{?SlctResearcher}*"
    When I hit F5 to generate the data, I get no results (and the parameter prompt field does not even come up...)
    If I modify the formula to put a hard-coded string, like
    "*Jones*"
    after the 'like', I get results (all the reports where "Jones" is a substring in the RptAuthors string.) If I modify the formula to just use the parameter field without the quotes/stars like:
    {Reports.PubDate} in DateTime (2009, 04, 01, 00, 00, 00) to DateTime (2010, 03, 31, 23, 59, 59) and
    {Reports.RptAuthors} like {?SlctResearcher}
    I do get the parameter prompt field, but still no results even if I put in a valid substring value (since it is not searching for a substring anymore...)
    How can I do this?
    Thanks,
    Will

    1st thing... Make a copy of your report before doing anything!!!
    To use a SQL Command, you'll want to open the Database Expert and look at the Current Connections. Expand the data source and the 1st option you see is the Add Command option.
    To find the SQL That CR is currently using, choose Database from the menu bar and select Show SQL Query...
    You can copy this and paste it directly into the command window. (If you you can write your own SQL you don't need copy CR's, it's just an option.)
    You'll also want to take not of any parameters that you have, you'll need to add them the the Parameter List of the command as well... be sure to spell them EXACTLY as they are in the design pane.
    Anyway, once the SQL statement is in the Command window you'll be able to alter the WHERE clause to use the wild cards.
    For future reference... What type of database are you reporting against???
    Jason

  • How to write statement using LIKE statement in jsp

    hi
    I am new to jsp. I would like to retrive the data from database using like command. But my query dosen't work well. Can you help me in this topic.
    String name = request.getParameter("username");
    int i = st.executeQuery("select * from emp where empname LIKE '%name%'");
    Plase help me..
    Thanking you
    sure...

    Using LIKE :
    ==========
    The following SQL statement will return persons with first names that start with an 'O':
    SELECT * FROM Persons
    WHERE FirstName LIKE 'O%'
    The following SQL statement will return persons with first names that contain the pattern 'la':
    SELECT * FROM Persons
    WHERE FirstName LIKE '%la%'
    Hope this might have helped you
    REGARDS,
    RaHuL

  • SQL "LIKE" statement isn't working right -- help please!

    Good day everyone,
    I thought about putting this in the "SQL on Oracle" forum, but it looked like those messages were geared more toward the Oracle platform itself, so here I am.  I apologize if this isn't the best forum.
    I have the following SQL statement:
      SELECT zzreporting_ut1
             zzreporting_ut2
             zzreporting_ut3
             zzreporting_ut4
             zzreporting_ut5
          UP TO 1000 ROWS
          INTO TABLE it_gmia_gmgrresp_data
            FROM gmspprogram
       WHERE ( ( zzreporting_ut1 LIKE '4011%'   OR
                 zzreporting_ut1 LIKE '4012%'   OR
                 zzreporting_ut1 LIKE '4013%' ) OR
               ( zzreporting_ut2 LIKE '4011%'   OR
                 zzreporting_ut2 LIKE '4012%'   OR
                 zzreporting_ut2 LIKE '4013%' ) OR
               ( zzreporting_ut3 LIKE '4011%'   OR
                 zzreporting_ut3 LIKE '4012%'   OR
                 zzreporting_ut3 LIKE '4013%' ) OR
               ( zzreporting_ut4 LIKE '4011%'   OR
                 zzreporting_ut4 LIKE '4012%'   OR
                 zzreporting_ut4 LIKE '4013%' ) OR
               ( zzreporting_ut5 LIKE '4011%'   OR
                 zzreporting_ut5 LIKE '4012%'   OR
                 zzreporting_ut5 LIKE '4013%' ) ).
    All I want to do is bring back the rows where one of those 5 "ut" fields begins with 4011, 4012, or 4013.  However, when I run it, it brings back anything:  rows where all 5 "ut" fields are empty, where the ut1 field begins with 4014, etc.
    Does anyone know what I'm doing wrong in my SQL statement?
    Thank you!  And as always, points awarded for ALL HELPFUL answers!
    Dave
    Edited by: Dave Packard on Jul 1, 2008 2:18 PM

    Hi Dave,
    because I don't know such a table named gmspprogram I'm not sure what to say.
    According to boolean expression syntax you do not need any of the brackets because the only operator used is OR.
    I'd suggest.
    data: lt_pattern_range type range of gmspprogram-zzreporting_ut2.
    perform insert_range using 'ICP':
      '4011*' '' changing lt_pattern_range,
      '4012*' '' changing lt_pattern_range,
      '4013*' '' changing lt_pattern_range.
    SELECT
      zzreporting_ut1
      zzreporting_ut2
      zzreporting_ut3
      zzreporting_ut4
      zzreporting_ut5
      UP TO 1000 ROWS
      INTO CORRESPONDING FIELDS OF TABLE it_gmia_gmgrresp_data
      FROM gmspprogram
      WHERE zzreporting_ut1 in lt_pattern_range
         OR zzreporting_ut2 in lt_pattern_range
         OR zzreporting_ut3 in lt_pattern_range
         OR zzreporting_ut4 in lt_pattern_range.
    * need form
    *&      Form  insert_range
    *       insert selection range - handles any range type "CLI20061218
    FORM insert_range  USING    p_signopt     TYPE c            "#EC CALLED
                                p_low         TYPE any
                                p_high        TYPE any
                       CHANGING pt_range      TYPE table.
      FIELD-SYMBOLS:
        <range>                               TYPE ANY,
        <sign>                                TYPE ANY,
        <option>                              TYPE ANY,
        <low>                                 TYPE ANY,
        <high>                                TYPE ANY.
      DATA:
        lv_ref                                TYPE REF TO data.
      CHECK NOT (
                  p_low     IS INITIAL AND
                  p_high    IS INITIAL ).
      CREATE DATA lv_ref                      LIKE LINE OF pt_range.
      ASSIGN lv_ref->* TO <range>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>.
      CHECK sy-subrc                          = 0.
      ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>.
      CHECK sy-subrc                          = 0.
      <sign>                                  = p_signopt(1).
      <option>                                = p_signopt+1(2).
      <low>                                   = p_low.
      <high>                                  = p_high.
      READ TABLE pt_range WITH KEY table_line = <range> BINARY SEARCH
        TRANSPORTING NO FIELDS.
      CHECK sy-subrc                          <> 0.
      INSERT <range> INTO pt_range INDEX sy-tabix.
    ENDFORM.                    " insert_range
    At least - I think - this looks better. And you may reuse the FORM insert_range whereever you want.
    Regards,
    Clemens

  • CreateNativeQuery using parameter in select LIKE statement

    Can I use setParameter on native query (createNativeQuery) using LIKE in select statement?
    I have the following code and it doesn't work:
    Query qry = manager.createNativeQuery("Select * from Type as t where t.typeid LIKE '%?1%'", Type.class);
    qry.setParameter(1, "2");
    Thanks.

    You could do this using the CONCAT function (+ ||, depending on the database). i.e. concat '%' + ?1 + '%'. You can do this in a native query, but JPQL does not allow functions in like (although some providers may support it). If your using TopLink Essentials or (TopLink/EclipseLink) you can do this using an Expression query.
    But, in general it may be better and easier to just concat "%" to your argument.
    -- James : [http://www.eclipselink.org]

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

Maybe you are looking for

  • What happened to reliable wireless in a mac mini...?

    My Mac Mini is having fits with its Airport card. If it recognizes it then it will connect for about 30 seconds then drop the signal and will not reconnect. The rest of the time it won't even acknowledge that it has an Airport card. If I switch over

  • Down payment process for Poland, new business process or not ?

    Hello, I'm a little bit confused about implementation down payment process for Poland. The OSS-notes 818079 and 1007635 describe a solution for this. How do I have to implement the correct down payment process for Poland ? Do I have to create an extr

  • Adobe Premiere Elements 9 Classroom in a Book - eBook DVD?

    I bought this from Amazon just now. It seems to need the DVD that comes with the printed version. I assumed that if there was any content that goes along with it I could download it. Is the eBook unusable without also having the printed book? Or can

  • Problem with my hotspot

    I have two Iphone 5's, A/  On my Iphone5 i have linked it with my son's Ipad through WiFi, on day two of tryin this i cant find my hotspot name!! I have tryed looking for the hotspot through my laptop and can see it.... help!! B/  On my wife's Iphone

  • Interface with I2C SDA and SCL with PCI 6224 digital ouputs in C/C++

    I am trying to use the pci 6224 in order to send SDA and SCL to an I2C. I have been able to control the Digital Output, but I have been unsuccessful with generating a clock source to satify the I2C. I am writing this code in C/C++. Any ideas or examp