Typecast number to varchar

Hi,
I’ve got another question. Does anybody know, if it is possible to connect a number to a string in a sql-statement.
Example:
Select counter, counter || 'abc'
From table
Do I have to do a typecast? ??
Number->String
Lg
Anna

Yes, can be done. Try it just like you said (select counter||'abc'). This will result in an implicit conversion from number to char. You can also use to_char(counter) for an explicit conversion (and add a format mask in the to_char function).

Similar Messages

  • Convert number to varchar datatype

    hi,
    I am working in oracle 9i. i am using two variables
    v_trigger_time varchar2(1000);
    v_min_run_date varchar2(1000);
    v_int_count NUMBER;
    datatype as VARCHAR2 and Number .ie ) HH:MI
    here is the query :
    select to_char(min(RUN_START_TIME),'HH24:MI')
    into v_min_run_date;
    select to_char(min(RUN_START_TIME),'DY')
    into v_run_date;
    select count(*)
    into v_int_count
    from temp_int_list
    where
    trigger_time = v_min_run_date
    in the above query ,
    trigger_time and v_min_run_date are in varchar datatype . but the v_int_count is in number datatype,
    I need the difference between v_min_run_date and trigger_time using sysdate.
    but the sysdate datatype is in date format. how to fetch the differneces between these two columns using varchar datatype in sysdate functions.
    ie ) 11:00 to 12:00 am
    rgds,.,.

    how to get the differences between these two sysdate.We can get the difference between two dates as an INTERVAL datatype:
    SQL> select ((sysdate+345/1440)-sysdate) DAY TO SECOND from dual
      2  /
    ((SYSDATE+345/1440)-SYSDATE)DAYTOSECOND
    +000000000 05:45:00
    SQL>We can get the hours and minutes using the EXTRACT function:
    SQL> with t as
      2  ( select ((sysdate+345/1440)-sysdate) DAY TO SECOND as interval from dual)
      3  select extract(HOUR from interval) as hours
      4         , extract(MINUTE from interval) as minutes
      5  from t
      6  /
         HOURS    MINUTES
             5         45
    SQL> Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Validate field value is number or varchar

    Hi All,
    I want to validate field's value is number/varchar by single line query. is it possible?
    e.g.
    select is_number(fieldval, 'Number','Varchar') from dual;
    Thanks in advance.
    - Hiren Modi

    Hi,
    If you cannot use regexps (due to your DB-version perhaps) you could do something like:
    MHO%xe> create table t as (
      2  select 'YES' col from dual union all
      3  select 'NO' from dual union all
      4  select '1' from dual union all
      5  select '2' from dual union all
      6  select '3' from dual union all
      7  select '4' from dual union all
      8  select '5' from dual union all
      9  select '6' from dual union all
    10  select '7' from dual union all
    11  select 'NO' from dual union all
    12  select 'YES' from dual union all
    13  select 'ABCED' from dual union all
    14  select '33' from dual union all
    15  select '5699' from dual union all
    16  select 'KPKHIH' from dual union all
    17  select 'ASDFSDAFSD' from dual union all
    18  select 'ASDFASDFSDFSDFSDAFASD' from dual union all
    19  select '212121' from dual union all
    20  select '9689898' from dual union all
    21  select '6545454' from dual union all
    22  select '212121' from dual union all
    23  select '5745757' from dual union all
    24  select '9857441969*' from dual
    25  );
    Tabel is aangemaakt.
    MHO%xe> create or replace function is_number( p_string in varchar2 )
      2  return varchar2
      3  deterministic
      4  as
      5    l_num number;
      6  begin
      7    l_num := p_string;
      8    return 'Number';
      9  exception
    10    when others then return 'Varchar2';
    11  end;
    12  /
    Functie is aangemaakt.
    MHO%xe> select col, is_number(col) dtype from t;
    COL             DTYPE
    YES             Varchar2
    NO              Varchar2
    1               Number
    2               Number
    3               Number
    4               Number
    5               Number
    6               Number
    7               Number
    NO              Varchar2
    YES             Varchar2
    ABCED           Varchar2
    33              Number
    5699            Number
    KPKHIH          Varchar2
    ASDFSDAFSD      Varchar2
    ASDFASDFSDFSDFS Varchar2
    DAFASD
    212121          Number
    9689898         Number
    6545454         Number
    212121          Number
    5745757         Number
    9857441969*     Varchar2You could index is_number as well.
    See: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:15767849694647

  • Run Report with Pass Number and Varchar Lexical Parameter values

    Dear Sir/Madam
    Due to an urgent change required to a report I would most appreciate it if you can please advise me if it is possible to get this report working by either passing in multiple lexical parameters or one signle lexical parameter when calling the SRW.RUN_REPORT command with the following methods:
    Firstly: When calling report with a run_no and spr_cd passed in through one lexical:
    cmd_line: REPORT=D:\DEV\REMITTANCE.rdf BACKGROUND=YES BATCH=NO DESFORMAT=PDF DESTYPE=FILE DESNAME=D:\DEV\REMITTANCE.pdf
    CP_L_PARAM=RUN_NO=TO_NUMBER(28) AND SPR_CD=SUPP1
    Both with a TO_NUMBER and without, whereby I attempt to do a SUBSTR within the query of the called report to derive the RUN_NO Oracle Reports fails to accept the SUBSTR.
    Secondly: I am now trying to call the with passing two lexical parameters into the report as follows:
    cmd_line: REPORT=D:\DEV\REMITTANCE.rdf BACKGROUND=YES BATCH=NO DESFORMAT=PDF DESTYPE=FILE DESNAME=D:\DEV\REMITTANCE.pdf
    CP_L_RUN_NO=||TO_CHAR(lv_run_no)|| CP_L_SPR_CD=||lv_spr_cd;          
    NOTE: The above is an output of the actual command line and not what is passed into the command line, thus the quotes are missing. Please also note that the report is running fine with the only a hard coded RUN_NO value PASSED without the SPR_CD.
    Unfortunately this is also causing issues as the RUN_NO is a number and as you know you can only pass in strings.
    Your urgent help is required on this matter please as our client is expecting a solution this afternoon.
    Hope to hear form you soon.
    Kind regards
    Andrew Mason

    Dont Worry I've worked it out...

  • Concatenate NUMBER and VARCHAR issue

    I'm trying to concatenate an integer and a string. However, the number that i'm trying to concatenate is the a number returned from the rank function and it's within the context of a CASE statement. I realize that sounds a bit confusing, so here's a psuedo example of what I'm trying to do:
    WITH temp_table AS
    SELECT 1 AS col1 FROM DUAL UNION ALL
    SELECT 2 FROM DUAL UNION ALL
    SELECT 3 FROM DUAL UNION ALL
    SELECT 3 FROM DUAL
    SELECT CASE WHEN COUNT(*) OVER (PARTITION BY col1) > 1
                THEN
                      RANK() OVER (ORDER BY col1) || 't'
                ELSE
                      RANK() OVER (ORDER BY col1)
           END AS test
    FROM   temp_table;
    Desired result set:
    TEST
    1
    2
    3t
    3tWhen I do the above, I get a "inconsistent datatypes: expected CHAR got NUMBER" exception. I tried converting the "RANK() OVER (ORDER BY col1) " to a string via the TO_CHAR function and CAST function, but neither worked. I did figure out how to successfully achieve my desired result by creating a subquery, converting the test column to a char, and than appending the 't' character to it in the outer SELECT; i was wondering if it was possible to do what I have requested in one query (without a subquery).

    Solomon Yakobson wrote:
    Right, but all you need is convert RANK to char which will be a bit more efficient:I thought on this but it i didnt appear that aesthetic to me.
    However why stop on hte half way?
    WITH temp_table AS
    SELECT 1 AS col1 FROM DUAL UNION ALL
    SELECT 2 FROM DUAL UNION ALL
    SELECT 3 FROM DUAL UNION ALL
    SELECT 3 FROM DUAL
    SELECT CASE WHEN COUNT(*) OVER (PARTITION BY col1) > 1
                THEN
                      to_char(RANK() OVER (ORDER BY col1)) || 't'
                ELSE
                      to_char(RANK() OVER (ORDER BY col1))
           END AS test
    FROM   temp_table;@OP it is about implicit type conversion, which should be avoided if possible.
    Edited by: chris227 on 23.07.2012 16:14

  • Need to select number in varchar

    Hi
    I have a strring like (RAZOR_LADIES_TRPLE_100/CS) ...i want to select only 100 from it ..can we do that using locate function in 11g...i am unable to write proper syntax ..Any help will be deeply appreciated
    Regards
    Debo

    Hi,
    You can try the below formula in your fx:
    SUBSTRING('RAZOR_LADIES_TRPLE_100/CS' FROM (LOCATE('_','RAZOR_LADIES_TRPLE_100/CS',LOCATE('_','RAZOR_LADIES_TRPLE_100/CS',LOCATE('_','RAZOR_LADIES_TRPLE_100/CS')+1)+1) + 1) For (POSITION('/' in 'RAZOR_LADIES_TRPLE_100/CS') - (LOCATE('_','RAZOR_LADIES_TRPLE_100/CS',LOCATE('_','RAZOR_LADIES_TRPLE_100/CS',LOCATE('_','RAZOR_LADIES_TRPLE_100/CS')+1)+1) + 1)))
    Here, replace 'RAZOR_LADIES_TRPLE_100/CS' with your actual column name. What this formula does is that it picks the characters after 3rd underscore (_) and upto the slash (/).
    Also, you can refer to the below post:
    Re: extract a part of a string in a full  string
    Thanks

  • Problem with number fields using ASP

    Hello all,
    I am running IIS 5.0 on Windows 2000 SP 2. I have Oracle 8.1.5 installed on this machine. I am currently only using the sample database that with Oracle. When I run a simple select statement from the ASP page, I see everything correctly, except the number fields. In SQL Plus, the same query works fine. The query only has three types of fields --> varchar, date and number. Varchar and date fields show up fine but the number doesnt. It shows up as 0. I am giving the code I used below. Please let me know if I am missing something or if there is a bug that needs to be patched. If it is a bug, then please let me know where I can find the patch for it.
    Thanks a lot,
    Prateek
    <!-- Begin code -->
    <html>
    <head><title>My first ASP page</title></head>
    <body>
    <%
    Set db = Server.CreateObject("ADODB.Connection")
    db.Open "dsn=oracle_conn;uid=scott;pwd=tiger"
    set rs = Server.CreateObject("ADODB.recordset")
    //set rs=db.execute("SELECT * FROM emp")
    rs.Open "SELECT * FROM emp", db
    rs.MoveFirst
    response.write("<table border=1>")
    response.write("<tr>")
    for each x in rs.Fields
    response.write "<th>" & x.name & "</th>"
    next
    response.write("</tr>")
    Do While Not rs.EOF
    response.write("<tr>")
    For I = 0 To rs.Fields.Count - 1
    response.write "<td>" & rs(I) & "</td>"
    Next
    response.write("</tr>")
    rs.MoveNext
    LOOP
    response.write "</table>"
    rs.Close
    db.Close
    %>
    </body>
    </html>
    <!-- End code -->

    Hi all:
    It seems like the above mentioned case is a bug. Supposedly it has been fixed in newer versions of Oracle but I am not sure about it as I dont have the time or resources to test and find out. But here is the fix for it in 8.1.5.
    It seems only the fields that have a size defined along with the number field dont show up properly. If you leave the number field as it is (without specifying the size), then it seems to work fine.
    Thanks a lot for all your help,
    Prateek

  • Using a varchar field to select statement

    Hi all
    I have a single row and single column table
    T(command varchar2(4000))
    and the row is
    sno,name
    And I have another table T1(sno number,name varchar)
    Now can any body tell how can i use command column in table T to query T1 to get sno,name from T1
    I am looking for a select statement like this
    select (select command from T) from T1;
    but it is printing out the data in T i mean sno, name
    This is a copy of thread Selecting output of a select statement
    but explained more clearly
    Thanks,
    ganesh.

    I don't know why your tables are designed like this but what I think you want to do is join T1 with the data in T.
    select sno, name from T1
    where sno in (select substr(command,0,instr(command,',')-1) from T)
    and name in (select substr(command,instr(command,',')+1) from T);
    substr returns a string up to a position
    instr returns the position of a string
    and the other post you refer to as about as confusing as your one.

  • Expected NUMBER got CURSER - wierd

    Hi guys,
    Using oracle express 10.2.
    Im getting very strange behavior when trying to retorn a recordset from a function.
    If i run the following in sqldeveloper it returns the 3 colums in a single column like this
    rstest
    {<1=1,2=2,3=3>,}
    if i run it in the web interface it returns
    ORA-00932: inconsistent datatypes: expected NUMBER got CURSER
    type cur_type is ref cursor;
    function rsTest return cur_type;
    FUNCTION rstest
    RETURN cur_type
    IS
    rs cur_type;
    BEGIN
    OPEN rs FOR SELECT 1,2,3 FROM dual;
    RETURN rs;
    END rstest;
    select rstest from dual;
    any ideas, im really stuck.
    thanks

    Let me explain,
    The function you are using returns a CURSOR which is embeded in a column, the only way you can read the cursor is by fetching its value and looping it.
    This function you have is ment to return cursor(which is not a data type like NUMBER or VARCHAR), the calling environment has to fetch it and iterate it to understand the data received.
    SQL Loader is just formating the vlaue in that way so its readable for you. :)

  • Error while creating a folder in business area

    hi all,
    I am trying to create a folder in a business area using View.It is giving me the following error.
    View contains no items,folder will not be created.
    May i know the reason why it is prompting this error?
    There are items in EUL and i also checked in the backend as well.
    Thanks in advance
    kiran

    Hi Rod west,
    Thanks 4 replying me.
    But i dont have any columns with timestamp.
    I have columns with date,number and varchar.i unchecked the date and then tried creating a folder.
    But still the problem persists
    can u please tell me ,What else may be the problem?
    Thank u
    kiran.
    Edited by: user589042 on Sep 29, 2008 2:40 AM

  • If statement in loop

    for rec in cur loop
                   dID := rec.update_id;
                   dTYPE := rec.update_type;
                   dNUMBER := rec.patch_number;
                   dDESC := rec.description;     
                   dOLD := rec.old_db_version;
                   --search if patch is already installed, if Yes do nothing, else:
                   if dID = cID then     
                        --now check version of DB
                        if cVER = version then
                        exec procedures(1);
              end loop;
    Error on line 10
    DECLARE
    var NUMBER;
         version varchar(12);
         installed boolean;
         --var
    ORA-06550: line 79, column 12:
    PLS-00103: Encountered the symbol "PROCEDURES" when expecting one of the following:
    := . ( @ % ;
    The symbol ":=" was substituted for "PROCEDURES" to continue.
    ORA-06550: line 82, column 10:
    PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
    why that if statement make for loop broken?

    stil the same,. i will paste it there all :)
    --testing procedure
    set serveroutput on
    create or replace procedure sampleP is
    begin
    dbms_output.put_line('write something');
    end;
    DECLARE
    var NUMBER;      
         version varchar(12);
         installed boolean;
         --variables for reading from table in database - installed hotfix's
         dID varchar(128);
         dPACKAGE varchar(50);
         dSEQUENCE varchar(50);
         dNUMBER varchar(128);
         dBASE varchar(256);     
         dNEW varchar(128);
         --variables for reading from table in database - current hotfix
         cID varchar(128);
         cPACKAGE varchar(50);
         dSEQUENCE varchar(50);
         cNUMBER varchar(128);
         cBASE varchar(256);     
         cNEW varchar(128);                    
         --procedure's in array
         --array for procedures
         type p_procedures is table of varchar(100) index by pls_integer;
         procedures p_procedures;
         --array for hotfix , which version it have
         --it must match with procedures array
         type p_versions is table of varchar(100) index by pls_integer;
         versions p_versions;
         CURSOR cur IS SELECT update_id,update_type,patch_number,description,old_db_version FROM SWIZ_DB_UPDATE_HISTORY;
    BEGIN
         --set hotfix installed to NO = 0
         --installed := 0;
         --sampleP;
         --execute procedures in field
         --first fill it with correct names
         procedures(1) := 'sampleP;';
         procedures(2) := 'sampleP1;';
    --then execute them in loop
    for v_rec in procedures.first .. procedures.last loop
    --execute immediate 'begin ' || procedures(v_rec) || ' end';
         DBMS_OUTPUT.put(procedures(v_rec));
    end loop;
         -- get the current version of database
         SELECT version INTO version FROM SWIZ_DB_VERSION;
         --info about current hotfix
         SELECT ID into cID from A_ID;
         SELECT package_id into cTYPE from A_ID;
         SELECT base_version into cNUMBER from A_ID;
         SELECT description into cDESC from A_ID;
         SELECT new_version into cNEW from A_ID;
         SELECT seq into cSEQUENCE from A_ID;
         --loop that go through history of db updates
              for rec in cur loop
                   dID := rec.update_id;
                   dTYPE := rec.update_type;
                   dNUMBER := rec.patch_number;
                   dDESC := rec.description;     
                   dOLD := rec.old_db_version;
                   --search if patch is already installed, if Yes do nothing, else:
                   -- if dID = cID then     
                        --now check version of DB
                        -- if cVER = version then
                                                 execute immediate 'begin ' || procedures(1) || ' end;';
              end loop;
              --now check if hotfix can be installed to current version of DB
    END;

  • APEX SEND EMAIL FUNCTION NOT SENDING EMAIL

    Hi All,
    For some reason that I can't figure out is not send any email... Could yo please help me to find it?
    DECLARE
    CreationDate date;
    ClosureDate date;
    IncidentsQty NUMBER;
    Tool varchar(100);
    BEGIN
    SELECT COUNT(STUCK_RELATED_TO_PROBLEM) into IncidentsQty
    FROM INCIDENTS
    WHERE STUCK_RELATED_TO_PROBLEM = :P57_INCIDENT_ID;
    SELECT IDATE  INTO CreationDate
    FROM PROBLEMS
    WHERE ID = :P57_INCIDENT_ID;
    SELECT CDATE  INTO ClosureDate
    FROM PROBLEMS
    WHERE ID = :P57_INCIDENT_ID;
    SELECT TOOL  INTO Tool
    FROM PROBLEMS
    WHERE ID = :P57_INCIDENT_ID;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    APEX_MAIL.send(
    p_to =>  '[email protected]',
    p_from => :app_user,
    p_body => 'SERVICE DESK NOTIFICATIONS: NEW UPDATE HAS BEEN REPORTED INTO AN PROBLEM',
    p_body_html => '<p>The details of the problem closed are the following: <br>
    <p>Creation date: ' || CreationDate || ' <br>
    Closure date:  '|| ClosureDate ||'<br>
    Incidents Qty: '|| IncidentsQty ||'<br>
    Observations: '|| :P57_IUPDATE ||'</p><br>
    p_SUBJ => 'The problem for the tool ' || TOOL || ' (ID# '|| :P57_INCIDENT_ID ||') has been closed.',
    p_cc => '',
    p_bcc => NULL ,
    p_replyto => NULL
    END;

    Hello Bernardo,
    >
    For some reason that I can't figure out is not send any email... Could yo please help me to find it?
    >
    Please do provide necessary information so the picture about your problem is clear for the forum members.
    The blog post by one of the eminent person working with Oracle Technologies @Tom Kyte might help:
    http://tkyte.blogspot.in/2005/06/how-to-ask-questions.html
    Now coming to your posted procedure snippet:
    APEX_MAIL.send (
    p_to =>  '[email protected]',
    p_from => :app_user,
    p_body => 'SERVICE DESK NOTIFICATIONS: NEW UPDATE HAS BEEN REPORTED INTO AN PROBLEM',
    p_body_html => '<p>The details of the problem closed are the following: <br>
    <p>Creation date: ' || CreationDate || ' <br>
    Closure date:  '|| ClosureDate ||'<br>
    Incidents Qty: '|| IncidentsQty ||'<br>
    Observations: '|| :P57_IUPDATE ||'</p><br>',
    p_SUBJ => 'The problem for the tool ' || TOOL || ' (ID# '|| :P57_INCIDENT_ID ||') has been closed.',
    p_cc => '',
    p_bcc => NULL ,
    p_replyto => NULL
    );As you have not given APEX Version information I will go with APEX Version Application Express 4.2.0.00.27.
    I would recommend you to go through the documentation of [url http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_mail.htm#CIHDIEJI]APEX_MAIL to help you debug the problem.
    This is what i want you to check with your email configuration:
    <ul>
    <li>Have you configured the email settings on the Instance Settings page.
    Refer: http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35129/adm_mg_service_set.htm#BEJBCEEH</li>
    <li>Have you checked the configuration works fine? You can use the examples given in the documentation of APEX_MAIL.SEND Procedure.
    Refer: http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/apex_mail.htm#CHDDAAJE
    Note: User SQL Commands from your APEX Workspace for this purpose.
    Also after sending email check for the error in APEX_MAIL_QUEUE or APEX_MAIL_LOG using query:
    -- Check whether the mail has been queued
    SELECT *
       FROM APEX_MAIL_QUEUE;
    -- Push the mail for delivery
    BEGIN
      APEX_MAIL.PUSH_QUEUE;
    END;
    -- Check whether the mail has been delivered without any error
    -- check for MAIL_SEND_ERROR column
    SELECT *
       FROM APEX_MAIL_LOG;</li>
    <li>Are you using Oracle Database Release 11.1 or higher version ? If yes then you have to configure network services to enable the host to send email. Refer: http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35125/sec_admin_ssl.htm#HTMDB12006</li>
    <li>Are you invoking the APEX_MAIL procedures through a database package? If yes then you have to set the SECURITY_GROUP_ID.
    Refer the starting of APEX_MAIL documentation.
    Use the following code before invoking APEX_MAIL procedures:
    p_app_id should be the Application Number of your APEX application.
    for c1 in (
       select workspace_id
         from apex_applications
        where application_id = p_app_id )
    loop
       apex_util.set_security_group_id(p_security_group_id =>
    c1.workspace_id);
    end loop;</li>
    </ul>
    This is what i find doubting about the code snippet:
    <ul>
    <li>Is APP_USER passing valid email ID?</li>
    <li>Note the usage of utl_tcp.crlf in the APEX_MAIL.SEND procedure examples in the documentation.</li>
    <li>Why have you passed empty string to the parameter p_cc ? Note that empty string is not equal to NULL.</li>
    <li>Instead of passing data directly to the parameters you can use variables, assign data to variables and pass variables instead.</li>
    </ul>
    In order to get accurate/appropriate response you should include at least following information with your question:
    <ul>
    <li>Full APEX version</li>
    <li>Full Database version</li>
    <li>APEX Web server architecture (EPG, OHS or APEX listener)</li>
    <li>Browser(s) and version(s) used</li>
    <li>Operating system with version, architecture(32/64)</li>
    </ul>
    The above information will help the forum members to ascertain the problem context and post most relevant response.
    Please read the [url https://wikis.oracle.com/display/Forums/Forums+FAQ]FAQ and [url https://forums.oracle.com/forums/ann.jspa?annID=1324]forum instructions for more information on using OTN forums effectively.
    Please perform a [url https://forums.oracle.com/forums/search!default.jspa]forum search before posting a question as this will help reduce duplicate threads.
    Please mark the reply as helpful or correct as this will help other members on the forum with similar question.
    Hope it helps!
    Regards,
    Kiran

  • Multiple values from a function

    Hi ,
    I have a package spec and body like below and now i wanted to call a function to get the multiple records from the below mentioned record type (temp_cv).
    How can i assign the values into variables from the temp_cv record , after getting the values i have to do further process with these values looking for your valuable help.. Thanks
    create or replace PACKAGE timelabel IS
    type time_rec is RECORD
    (unit number,
    inspec varchar(10),
    status varchar(10));
    type time_cv is REF CURSOR return time_rec;
    function initialrefc(p_status varchar2) return time_cv;
    END;
    create or replace PACKAGE BODY timelabel IS
    function initialrefc(p_status varchar2) return time_cv is
    temp_cv timelabel.time_cv;
    begin
    open temp_cv for select unit,inspec,status
    from timezero where status =p_status;
    return temp_cv;
    end;
    END;

    here is a good example of ref cursor return results
    http://www.oracle-base.com/articles/8i/UsingRefCursorsToReturnRecordsets.php
    http://www.psoug.org/reference/ref_cursors.html

  • How to get the rows from a table having some column has any letter

    Hi All,
    suppose i have a table having columns id(number), code(varchar).
    code has alphanumeric characters (ex. ABC123, 67B56 etc).
    some codes are only numbers (2344, 7898 etc).
    how can i get the rows which have alphabets in the code.
    ex:
    id code
    1 AB45
    2 456
    3 890
    4 67B7
    how can i write a query such that it should give me the ids 1 and 4 (as they have alphabets in code)
    thanks in advance to all

    Thanks to one and all.
    i am gettig my required output.
    But i have a doubt in the operator.
    If i add or remove '[]' in the operator, i am getting different ouputs.
    There is a count difference in the result of the operators used.
    REGEXP_LIKE(<column>,'[[:lower:]]')
    REGEXP_LIKE(<column>,'[[[:lower:]]]')
    REGEXP_LIKE(<column>,'[:lower:]')
    Can anybody please explain what is the difference in using '[]', in the operator?
    What is the correct syntax, whether i have to use two '[]'s or one '[]'.
    Also, can i use REGEXP_LIKE() in oracle 8i version.( I am unable to use the operator in 8i)?
    Any query to get the required output in 8i version?
    Thanks in advance to all.

  • Help with table scan

    I have a problem with full table scans that make very slow the performance of a report.
    The test case is below. It looks that when the column is called from the table, the index is in use. If I use the same select from the view, then I get a table scan.
    I would appreciate any idea on how to optimize it.
    Thanks a lot for the help.
    mj
    <pre>
    create table test1 (id1 number , id2 number, id3 number, col1 varchar(10),col2 varchar(50), col3 varchar(100));
    create table test2 (id4 number , id5 number, id6 number, col4 varchar(10),col5 varchar(50), col6 varchar(100));
    ALTER TABLE test1 ADD CONSTRAINT PK_test1 PRIMARY KEY(ID1) USING INDEX REVERSE;
    create index index1 on test1(ID2);
    create index index2 on test1(ID3,col2 );
    ALTER TABLE test2 ADD CONSTRAINT PK_test2 PRIMARY KEY(ID4) USING INDEX REVERSE;
    create or replace view test_view as select t1.*,
    case (select t2.id4 from test2 t2 where t1.id2 = t2.id5 and t2.id6 = -1)
    when t1.id2 then t1.id3
    else t1.id2
    end as main_id
    from test1 t1 ;
    create or replace view test_view2 as select * from test_view; --(requred by security levels)
    select * from test1 where id2 =1000;
    select * from test_view where id2 = 1000;
    select * from test_view2 where id2 = 1000;
    SQL> select * from test_view where id2 = 1000;
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 1970977999
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 125 | 1 (0)| 00:00:01 |
    |* 1 | TABLE ACCESS FULL | TEST2 | 1 | 39 | 2 (0)| 00:00:01 |
    | 2 | TABLE ACCESS BY INDEX ROWID| TEST1 | 1 | 125 | 1 (0)| 00:00:01 |
    |* 3 | INDEX RANGE SCAN | INDEX1 | 1 | | 1 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("T2"."ID5"=:B1 AND "T2"."ID6"=(-1))
    3 - access("T1"."ID2"=1000)
    SQL> select * from test_view where main_id = 1000;
    Elapsed: 00:00:00.03
    Execution Plan
    Plan hash value: 3806368241
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 125 | 4 (0)| 00:00:01 |
    |* 1 | TABLE ACCESS FULL | TEST2 | 1 | 39 | 2 (0)| 00:00:01 |
    |* 2 | FILTER | | | | | |
    | 3 | TABLE ACCESS FULL| TEST1 | 1 | 125 | 2 (0)| 00:00:01 |
    |* 4 | TABLE ACCESS FULL| TEST2 | 1 | 39 | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("T2"."ID5"=:B1 AND "T2"."ID6"=(-1))
    2 - filter(CASE WHEN "T1"."ID2"= (SELECT /*+ */ "T2"."ID4" FROM
    MJ42."TEST2" "T2" WHERE "T2"."ID5"=:B1 AND "T2"."ID6"=(-1)) THEN
    "T1"."ID3" ELSE "T1"."ID2" END =1000)
    4 - filter("T2"."ID5"=:B1 AND "T2"."ID6"=(-1))
    SQL>
    </pre>

    If you think about what the two queries are doing, it is easy to see why the first uses an index and the second does not.
    Your first query:
    SELECT * FROM test_view WHERE id2 = 1000explicitly uses an indexed column from test1 in the predicate. Oracle can use the index to identify the correct row from test1. Having found that single row in test1, it uses the FULL SCAN test2 to resolve the case statement.
    Your second query:
    SELECT * FROM test_view WHERE main_id = 1000uses the result of the case statement as the predicate. Oracle has no way of determing what row from test1 to use initially, so it must full scan both tables.
    John

Maybe you are looking for

  • Web service proxy creation issue

    am facing an issue with the creation of web service proxy for an esb project that i have created based on oracle esb tutorial. In the web service proxy creation wizard, it is accepting the concrete URL for the wsdl in the first step however in the se

  • ITunes always busy in com.apple.MediaLibraryService

    Hi, I use Mac OS X 10.10.1 and iTunes 12.0.1.26. iTunes is almost always busy in com.apple.MediaLibraryService. com.apple.MediaLibraryService 198,0 15:57,85 4 1 72959 joswig 64-Bit 0 Byte 0 Byte 0 Byte 0 Byte Nein 0 Byte 0 Byte 0 0 0 Byte 0 Byte 0 By

  • How to upgrade a 6i Repository to the latest release

    Hi, does anybody know, how to upgrade a 6i Repository to it's latest release? We have version 4.0.52.1 (release 4) installed and we want to install relase 4.4. Following the installation/upgrade guide, I still got the problem, that the upgrade button

  • What is Trade Promotion Management?

    All, I am new to CRM domain and learning the concepts. I am comfortable with most of the concepts but I didn't understand what is meant my Trade Promotion Management. I have gone through help.sap.com but still didn't understand properly. I think my p

  • Glitched iPod showing yellow letters, won't sync, itunes unknown error 1621. Help please!

    6th generation touch screen ipod, only 1 week old.  While I was running, the music volume got loud, and then the ipod quit.  When trying to turn it back on, the ipod will only go to a screen with yellow lettering that reads: N20  Snowfox (4ao432) Vol