Query to find out if the numeric string has letters in it. Please, help!

Hi, everyone!
Could you please help me in constructing the following query:
I want the query to return the records, for which a specified column contains at least 1 alpha-numeric character in it. For example, if I search the Items table, I want the rows with the following Item_Number values be returned: "34265af6", "bbbbbbbb", "9808677y" etc...
Thanks a lot.
Regards,
Eugene.

Would you consider the Null value for "p_string" input parameter as being NUMBER or otherwise? That's an interesting question. The function and query as is would treat nulls as numbers, consistent with how Oracle would treat a null as a potential number, by not raising any error when asked for to_number(null). However, if you wanted to exclude nulls, you could just add an additional filter condition to the where clause. See examples below.
-- selecting to_number(null) does not raise an error:
SQL> SELECT TO_NUMBER (NULL) FROM DUAL
  2  /
TO_NUMBER(NULL)                                                                
-- is_number(null) is considered numeric:
SQL> SELECT is_number (NULL) FROM DUAL
  2  /
IS_NUMBER(NULL)                                                                
Y                                                                              
-- combination of Oracle and user-defined
-- functions considers null as numeric:
SQL> SELECT DECODE (LTRIM (NULL, '0123456789-+E/.,'),
  2                NULL, is_number (NULL),
  3                'N')
  4  FROM   DUAL
  5  /
DECODE(LTRIM(NULL,'0123456789-+E/.,'),NULL,IS_NUMBER(NULL),'N')                
Y                                                                              
SQL> -- additional test data:
SQL> INSERT INTO items VALUES (NULL)
  2  /
1 row created.
SQL> COMMIT
  2  /
Commit complete.
SQL> SELECT * FROM items
  2  /
ITEM_NUMBE                                                                     
ABC123                                                                         
ABC                                                                            
DEF123                                                                         
123                                                                            
C123                                                                           
XYZ                                                                            
GHI                                                                            
8 rows selected.
SQL>
SQL>
SQL> -- unmodified select statement
SQL> -- treats nulls as numbers
SQL> -- and doesn't include null value
SQL> -- in result set when searching
SQL> -- for non-numbers:
SQL> SELECT *
  2  FROM   items
  3  WHERE  DECODE (LTRIM (item_number, '0123456789-+E/.,'),
  4                NULL, is_number (item_number),
  5                'N') = 'N'
  6  /
ITEM_NUMBE                                                                     
ABC123                                                                         
ABC                                                                            
DEF123                                                                         
C123                                                                           
XYZ                                                                            
GHI                                                                            
6 rows selected.
SQL>
SQL>
SQL> -- modified select statement
SQL> -- treats nulls as non-numbers
SQL> -- and includes nulls in result set
SQL> -- when searching for non-numbers:
SQL> SELECT *
  2  FROM   items
  3  WHERE  DECODE (LTRIM (item_number, '0123456789-+E/.,'),
  4                NULL, is_number (item_number),
  5                'N') = 'N'
  6  OR     item_number IS NULL
  7  /
ITEM_NUMBE                                                                     
ABC123                                                                         
ABC                                                                            
DEF123                                                                         
C123                                                                           
XYZ                                                                            
GHI                                                                            
7 rows selected.

Similar Messages

  • How to find out if a long String has a "subString" twice or more.

    I need to find out if a long String has the same number twice or more.
    I need to look matches for numbers running from 000, 001....999 and if a number is found twice or more, return that number and lines there were found.
    example String:
    -;000 ; 1 ; 2006-12-11 ; -; job;
    x;001 ; 2 ; 2006-12-11 ; 2006-12-12; do this
    -;002 ; 3 ; 2006-12-11 ; -; work
    -;003 ; 0 ; 2006-12-11 ; -; some
    -;004 ; 2 ; 2006-12-11 ; -; thing
    x;005 ; 1 ; 2006-12-11 ; 2006-12-11; reads
    -;003 ; 0 ; 2006-12-11 ; -; here
    Should return from example String:
    003 at lines 4 and 7
    Any ideas?

    So there are newlines in the String?
    You could use a StringTokenizer to break the String into lines, then searching on each line if it contains any of the search strings. (You need to clarify if a line can contain more than one search string).
    Probably you should use a Map<String, Integer> to record the searchcounts.
    Or an int[] Array if you are really sure that the Strings you search for really are numbers.
    Another option is to use:
    LineNumberReader lnr = new LineNumberReader(new StringReader(searchString));This will save you from explicitly having to take care for the line number.
    In any case your example looks like the individual lines are semicolon separated fields and the numbers you search for always are in column two.
    So after breaking up the original String in lines, you could use another StringTokenizer to break up the line in fields.

  • HT5622 Hi, I have verified my apple ID and it showed verified. However, it is still point out follow the verify link to your email. Please help

    Hi, I have verified my apple ID and it showed verified. However, it is still point out follow the verify link to your email. Please help

    I have this problem too

  • How do I query to find out if the MONITORING clause was enabled on a table?

    Our customers are currently running Oracle 8.1.7 in the field. I am writing a database schema updater tool that is supposed to examine the schemas and make necessary changes to them.
    Recently, the MONITORING clause was added to many of the tables in our schemas. I need to find out if the tables currently have MONITORING enabled.
    But, even though the Oracle documentation is very large, again, I cannot find any information about how to determine if MONITORING on a table is on or off.
    Any ideas? An SQL query? JDBC metadata?
    Tom Harris
    Cisco Systems, Inc.

    What is the output of the following statements on your system?
    Remember, table names are stored in caps in the dictionary if not enclosed within double-quotes.
    SQL> create table t (x number) ;
    Table created.
    SQL> select monitoring from user_tables where table_name = 'T' ;
    MON
    NO
    1 row selected.
    SQL> alter table t monitoring ;
    Table altered.
    SQL> select monitoring from user_tables where table_name = 'T' ;
    MON
    YES
    1 row selected.
    SQL> disconnect
    Disconnected from Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.5.0 - Production
    SQL>

  • I plug my I-touch but I-tunes doesn"t recognize it , nothing pops out on the left...... please help...

    I plug my I-touch but I-tunes doesn"t recognize it at all, nothing on the left side that pops out as usual... please help me...

    Assming you have a PC start here:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows

  • I am having problems with my hotmail email and new software update. It keeps asking me for my password even though the email account has been verified. Please help

    It keeps asking me to re- enter the password. Is there something that I am doing wrong, the account has been verified but as soon as I exit out of settings it will ask me to re-enter my password.

    I have done this and keeps saying the same thing. I have even tried setting my account through Microsoft exchange but no luck

  • Query to find out the time used by an user for an application

    Hello All,
    I want to know the query to find out the whole time used by the user for an application. Please view the below data
    Employee:
    SNO EMP_ID EMP_NAME EMP_DATE LOGIN_TIME LOGOUT_TIME
    1 10 Visu 21-Nov-2010 06:30:00 07:30:00
    2 10 Visu 21-Nov-2010 06:40:00 07:20:00
    3 10 Visu 21-Nov-2010 06:50:00 07:50:00
    4 10 Visu 21-Nov-2010 07:30:00 08:30:00
    5 10 Visu 21-Nov-2010 09:30:00 10:30:00
    By checking the above data we can say that the total time Visu used the application is
    8.30 - 6.30 (From 1,2,3,4 records) = 2hrs
    10.30 - 9.30 (Based on 5th rec) = 1hr
    So the total time Visu used the application would be 3 hrs = 180 mins.
    Could you please help me in getting the result from that data using a query?

    odie_63 wrote:
    I think it may be solved with analytics too.
    with t1 as (
                select 1 sno,10 emp_id,'Visu' emp_name,'21-Nov-2010' emp_date,'06:30:00' login_time,'07:30:00' logout_time from dual union all
                select 2,10,'Visu','21-Nov-2010','06:40:00','07:20:00' from dual union all
                select 3,10,'Visu','21-Nov-2010','06:50:00','07:50:00' from dual union all
                select 4,10,'Visu','21-Nov-2010','07:30:00','08:30:00' from dual union all
                select 5,10,'Visu','21-Nov-2010','09:30:00','10:30:00' from dual
         t2 as (
                select  emp_id,
                        emp_name,
                        emp_date,
                        to_date(emp_date || login_time,'DD-MON-YYYYHH24:MI:SS') login_time,
                        to_date(emp_date || logout_time,'DD-MON-YYYYHH24:MI:SS') logout_time
                  from  t1
         t3 as (
                select  t2.*,
                        case
                          when login_time < max(logout_time) over(
                                                                  partition by emp_id,emp_date
                                                                  order by login_time
                                                                  rows between unbounded preceding
                                                                           and 1 preceding
                            then 0
                          else 1
                        end start_of_group
                  from  t2
         t4 as (
                select  t3.*,
                        sum(start_of_group) over(partition by emp_id,emp_date order by login_time) grp
                  from  t3
         t5 as (
                select  emp_id,
                        emp_date,
                        min(login_time) login_time,
                        max(logout_time) logout_time
                  from  t4
                  group by emp_id,
                           emp_date,
                           grp
    select  emp_id,
            numtodsinterval(sum(logout_time - login_time),'day') time_spent
      from  t5
      group by emp_id
      order by emp_id
        EMP_ID TIME_SPENT
            10 +000000000 03:00:00.000000000
    SQL> SY.

  • Query to find out the list of user who have delete access

    Hi,
    I need a query to find out the list of users who have delete access on perticular folder/universe/ reports  in infoview.
    Please advice.
    Regards,
    Neo.

    orton607 wrote:
    thanks for replying guys. But the thing is i am using dynamic sql execute immediate in my package, so i want those tables also and the schema name.
    thanks,
    ortonThis is not possible. The best you could do is to have a good guess.
    Or how would you parse some dynamic statement as this:
       v_suffix := 'loyees';
       v_sql := 'Select count(*) from (select ''nonsense'' col1 from emp'||v_suffix||') where col1 = ''Y'''';
       execute_immediate(v_sql);
    ...What is the table name? How do you want to parse that?
    Better rewrite all dynamic SQL statements into non dynamic ones. Or do the source control logic for those dynamic parts in an extra module. For example implement your own dependency table and force every developer to add there all dynamic parts.

  • Need query to find out the sum till a period

    Hi,
    I need to write one query to find out the cumulative sum of raw_cost of table pa_budget_lines till the specified period, I tried to do this by analytical function, but that is not working in Report 10g. Can anybody help me in this.
    Thanks

    not familiar with report but could you do something like this
    with t as
      select 1 grp, 10 * level the_cost, add_months (sysdate,  level) effective_dt from dual connect by  level < 11 union all
      select 2 grp, 5 * level the_cost, add_months (sysdate,  level) effective_dt from dual connect by  level < 11
    input as
      ( select null grp, null the_cost, null running_total,  v_eff_dt effective_dt   from dual)
    select * from(
    select t.grp, t.the_cost, sum(t.the_cost) over (partition by t.grp order by t.effective_dt) running_total, t.effective_dt,
           lead(t.effective_dt) over (partition by t.grp order by t.effective_dt) next_effective_dt,
           input.effective_dt  inp_eff_dt
    from t, input
    where inp_eff_dt between effective_dt and next_effective_dtv_eff_dt would be the input date you are interested in

  • Query to find out the Activities done against a table

    Hi,
    One table has been truncated and data reloaded into the table by the user. But at latter stage user deny that activity. I believe all these activities stored in any oracle 10g database table.
    Need a query to find out the activities done on a specific date say 6th Sep.
    This is too urgent. Thanks in advance

    Hi,
    Welcome to the forum!
    If you don't have enable table auditing maybe you can see last_ddl_time column of user_objects view:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> select * from test2;
          COL1       COL2       COL3
             1          1          3
             1          2          3
             1          3          3
    SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
    TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
    12/09/2009 12:20:26            12/09/2009 12:20:27
    SQL> truncate table test2;
    Table truncated
    SQL> select to_char(uo.created, 'DD/MM/YYYY HH24:MI:SS'), to_char(uo.last_ddl_time, 'DD/MM/YYYY HH24:MI:SS') from user_objects uo where uo.object_name = 'TEST2';
    TO_CHAR(UO.CREATED,'DD/MM/YYYY TO_CHAR(UO.LAST_DDL_TIME,'DD/M
    12/09/2009 12:20:26            12/09/2009 14:01:21
    SQL> Regards,

  • Please give the query to find out primary key in table in Sql plus

    Dear friends,
    Please give me the query to find out the primary key in Sql plus.

    hi
    SQL> DESC user_constraints
    Name                                                                                                  
    OWNER                                                                                                 
    CONSTRAINT_NAME                                                                                       
    CONSTRAINT_TYPE                                                                                       
    TABLE_NAME                                                                                            
    SEARCH_CONDITION                                                                                      
    R_OWNER                                                                                               
    R_CONSTRAINT_NAME                                                                                     
    DELETE_RULE                                                                                           
    STATUS                                                                                                
    DEFERRABLE                                                                                            
    DEFERRED                                                                                              
    VALIDATED                                                                                             
    GENERATED                                                                                             
    BAD                                                                                                   
    RELY                                                                                                  
    LAST_CHANGE                                                                                           
    INDEX_OWNER                                                                                           
    INDEX_NAME                                                                                            
    INVALID                                                                                               
    VIEW_RELATED                                                                                          
    SQL> SELECT constraint_name,table_name,r_constraint_name,status
      2  FROM user_constraints WHERE constraint_type='P';
    CONSTRAINT_NAME                TABLE_NAME                     R_CONSTRAINT_NAME              STATUS
    SYS_C003141                    CUSTOMERS                                                     ENABLED
    PK_DEPT                        DEPT                                                          ENABLED
    SYS_C003139                    SALESREPS                                                     ENABLEDKhurram

  • How do we find out who the query originator is on the DB2 database side?

    OBIEE 11g will typically connect to the database using a generic account. Some of the queries are using too
    many resources on our DB2 database. How do we find out who the query originator is (by userID), on the DB2 database side, and not on the OBIEE side? Our research is leading us to Query banding used in Teradata.
    We are looking for something similar, that would work in DB2. 

    If you go to www.speedtest.net it will display which ISP you're with in the bottom corner. There are a few other websites which tell you too but the URLs escape me at the minute
    Dean
    BTCare Community Mod
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • How to use ONE query to find out tree structure?

    ID------------upperID----------Name------------------------isFolder
    1------------ 0---------- Folder
    1------------------------------------1
    2------------ 1------------ Folder 1- Sub
    Folder--------------------1
    3------------ 2------------
    Folder1-Item1-A--------------------------0
    4------------ 1------------ Folder 1- Sub
    Item-----------------------0
    Hi all, if I have a table like above to demonstrate the
    folders and item relationship. This structure allows the user to
    create unlimited folders and items.
    Now I would like to use one query to find out the tree
    structure of this table, how could I do the query.
    Any help on this will be highly appreciated!
    Thanks,
    ez

    Also, see this thread:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=12 55788&enterthread=y

  • How do I find out who the BB provider is at my pro...

    brief history.
    Bought my existing property in july2012 .
    Ordered BT combined phone and BB package 2 with 40Gb and free calls August 8th 2012
    took BT 5 xweeks to connect my phone line although there was an existing line working at the house .?
    Also 5xweeks to connect the BTHub3 broadband.
    Today i learn that BT cancelled my BT broadband service over a month ago because there was a previous broadband provider still active at the property .
    I am now told that my BT router has been connected to an unknown ISP for the past 6x weeks ????
    How can I find out who the ISP is so I can cancel it as I cannot contact the previous property owner.
    BT have not advised me of any of this by the way. If I hadn't phoned today to query why I have no caller ID or answerphone service or email address and my number isn't ex dir as requested then I'd never have known

    If you go to www.speedtest.net it will display which ISP you're with in the bottom corner. There are a few other websites which tell you too but the URLs escape me at the minute
    Dean
    BTCare Community Mod
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • How do I find out if the pressed key is printable?

    I have made a game and now I'm working on a hiscore table for it. But with my function the program doesn't know if the pressed key is printable or if it's shift, ctrl or something like that. And I made it possible to enter maximum 40 letters as name, so if the user holds the shift key for a while then the whole String is filled with shift characters and nothing shows on the screen and he/she isn't able to type in any more letters... So is there any way to find out if the pressed key contains a printable char?
    This is what my function looks like now. My program is quite big so I just post the function and try to explain what is happening
    /* high is an array of
    int score;
    String name;
    boolean WritingName;
    boolean GAMEOVER;
    boolean newgame;
    public void keyPressed(KeyEvent e) {
         if (GAMEOVER){  // checks if the game has ended
             char button = e.getKeyChar();
             int keyCode = e.getKeyCode();
             if (newgame){  // this is false if the hi-score list is showing otherwise its true. i.e. its true when typing name for hiscore list
                   if (keyCode == 10) {       // check if the pressed key is enter
                        WritingName = false;  // Tells an other function that the user has finished typing his/her name so it can save it and start showing the hiscore-list on the screen
                   } else {
                        if (keyCode == 8){    // check if the pressed key is backspace and if so removes the last char from the string
                             if (high[99].name.length() > 0){
                                  high[99].name=high[99].name.substring(0,high[99].name.length()-1); 
                        } else {  // if any other key is pressed then add it to the end of the string
                             if (high[99].name.length() <= 40 ) high[99].name += button;
                   paint(getGraphics());
              } else {  // checks if space is pressed to stop showing the hiscore-list and start a new game
                   if (keyCode == 32) newgame = true;
    }

    But with my function the program doesn't know if the pressed key is printable or if it's shift, ctrl
    or something like thatProbably the easiest way is to check and see if e.getKeyChar() < a space character or if e.getKeyCode() >= 127. You can use e.getModifiers() to get the modifier, etc... -- take a look at the documentation for java.awt.event.KeyEvent class.
    V.V.

Maybe you are looking for