TO_NUMBER function on varchar2 column with numbers and strings

I need to create a column in a view that converts a varchar2 column data to number. The problem is that some
of the data have strings and some numbers. I get "ORA-01722: invalid number" error when Oracle tries to covert
strings (e.g. 'ABCD') to number. What I need is to get a NULL value if the data is an invalid number.
How can I rewrite the following to get NULL value is a string is invalid number?
select to_number('abcd') numberColumn
from dual
thanx
Alfred

SQL> select * from test_char_num;
ALPHA_NUM
ABC
DEF
123
234
A12
SQL> select decode(NVL(length(trim(translate(alpha_num, '1234567890', ' '))), 0),
  2                0, alpha_num, 'NULL') new_alpha_num
  3  from test_char_num;
NEW_ALPHA_
NULL
NULL
123
234
NULLP.S I am printing 'NULL' just to show the result, Please replace the 'NULL string with NULL value in SQL.
Thx,
Sri

Similar Messages

  • How do I autofill a column with numbers increasing by 1?

    How do I autofill a column with numbers increasing by 1?

    Hi Patricia,
    Type in your first 2 values. Select both and drag the yellow dot down to fill the remainder.
    quinn

  • Boxes with numbers and letters show instead of certain images on some websites

    On yammer.com and linkedin.com, images for icons, like those that should display along the top of the screen do not display. Instead, I see a rectangle with numbers and letters. I've seen quite a few articles about the rectangles with numbers and letters that apply to characters but none involving images. I've also tried the steps in the article on troubleshooting images not displaying properly, and nothing seems to work.
    Thanks!

    Make sure that you allow pages to choose their own fonts.
    *Tools > Options > Content : Fonts & Colors > Advanced: [X] "Allow pages to choose their own fonts, instead of my selections above"

  • I´ve made four Columns with text and an Image over the middle of two columns. How do I put a text u

    I´ve made four Columns with text and an Image over the middle of two columns. How do I put a text under the Image that spans over the Columns?

    Did you mean that?
    or
    Did you mean that?
    Let me know.

  • I am now using the free 1 month CC trial. I got a free one year licence with a camera. I have a product key 24 characters long with numbers and letters. I can't find anywhere to put this key to activate the account? Using a PC, windows 8.

    I am now using the free 1 month CC trial. I got a free one year licence with a camera. I have a product key 24 characters long with numbers and letters. I can't find anywhere to put this key to activate the account? Using a PC, windows 8.

    Redemption Code Help
    Mylenium

  • I created a spreadsheet on my mac with numbers, and now it tells me  I have to buy a newer version of numbers to access the spreadsheet I created with the old program.  if I wanted problems like that I would go back to using windows

    I created a spreadsheet on my mac with numbers, and now it tells me  I have to buy a newer version of numbers to access the spreadsheet I created with the old program.  if I wanted problems like that I would go back to using windows

    Hi sar23,
    You may have inadvertently created or edited the document in the new Numbers 3.0 (which is free; you don't have to buy it) and are now trying to open it with the old Numbers 2.3.
    Both versions can be on your Mac at the same time, and can run at the same time.  The icons are similar so it's easy to confuse them (old on top here, new on bottom).
    The new Numbers 3.0 is in your Applications folder. The old Numbers 2.3 should be in a subfolder in the Applications folder named iWork '09 or similar.
    If you accidently edited an old document in the new version and want to take to take it back to the old version, you can export it:
    SG

  • Pop-up Menu with numbers and letters

    When using a pop up menu i only have numbers in there e.g. $50. What i want to have in there is 3hrs instead of $50 because that's what will be relevant but
    the formula sees 3hrs as $50 so the spreadsheet still works. If i add letters eg $50 = 3hrs I get the following error message
    It would be great if its could say 3hrs instead of $50  4hrs instead of $70  5 hrs instead of $80
    Hope that all makes sense and someone can help me
    Many thanks
    Danny Kirk

    Hi Danny,
    When you put a mixture of numbers and letters into a cell, Numbers treats it as a (text) string. The arithmetic operators ( +, - * and / ) work only with numbers, duration values, and Date & Time values. You are getting an error because a formula using the value placed in the cell by the pop-up menu expects a number, but you have given it a (text) string.
    You can supply the operator with the number 50, formatted as currency ( $50 ), or you can provide a duration ( 3h ). If you place the operator into a formula that can use the type of value you choose, you will not get the error message.
    There does not appear to be a linear relationship between the number of hours and the number of dollars. Unless you can specify a relations ship that can be expressed mathematically, you will need to use a lookup table to match the hour values in the pop-up's menu to the related dollar value to be returned.
    Here's a simple example. Note that "3h" (without the quotes) as used in SGIII's example above is a Duration value, "3hrs" (again without the quotes) will be interpreted by Numbers as a duration, and will be automatically reformatted to display as "3h". The dollar amount has been entered (and displayed) as a number. The Amount column on the Main table has been formatted as Currency, with the default two decimal places.
    The formula in each cell of Main::Column A is: =LOOKUP(B,Lookup :: A,Lookup :: B)
    (LOOKUP is the name of the function used. "Lookup" is the name of the table from which the information is retrieved.)
    Regards,
    Barry

  • Thanks for help with Numbers and web stock quotes

    Koenig Yvan,
    I want to public thank you for sharing your Applescript: InsertQuotes from 2009 that works with Numbers.
    I've successfully modified and simplified it for my purposes to be able to retrieve and set values for a portfolio of U.S. mutual funds that are our investments.  I have a spreadsheet that started out years ago as an Excel spreadsheet on Windows XP and used Microsoft's ability to retrieve information from the web from finance.yahoo.com and place it in Excel spreadsheet cells. 
    I converted that spreadsheet to Google spreadsheet using their GoogleFinance function.  It proved to be unreliable intermittently and now I've taken that spreadsheet into Numbers '09 and used your script, modified to use my portfolio's list of symbols and to put just the prices into a quotes sheet.  For each account I track in my Numbers spreadsheet I use the table Lookup function to search the quotes sheet for a specific symbol and have the function return the associate price.
    Following your instructions I put the Applescript in the ~/Library/Scripts/Applications/Numbers/ and after opening my Numbers spreadsheet, with one mouse click in the System wide Scripts menu, execute the script which accesses finance.yahoo.com and sets the latest prices into my quotes sheet.
    Thanks very much for sharing with everyone.  I appreciate having access to your work to make my work much easier.

    Which structure ?
    If you are wondering about the Library folder, it's a feature described thiuysands of time.
    In Lion, this folder is hidden.
    press Option while triggering the menu "Go to" give access to this folder.
    Yvan KOENIG (VALLAURIS, France) vendredi 14 octobre 2011 20:36:13
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • To_number function doesn't work with apex_collections in where clause

    One of my applications I have been using apex_collections and to_number function
    in the where clause. Since we upgraded apex to version 3.0.1 , it gives the invalid number error.
    Is this a bug in the new Version.
    I had to re-write the logic to fix the application.

    Can you show us that code? An example on apex.oracle.com where we can see the error would be great.
    Scott
    P.S. Please tell us your first name and put it into your handle and/or profile to help us.

  • How to create a first row in crystal report as opening balance which contains two columns with debit and credit

    I have created a crystal report with credit and debit column. Balance column created on the report. Report running with cummulative balance. THis report contain an option for date range. If i filtered this report its not showing the actual balance. I need
    a first row to indicate previous balance as opening balance in this report.  And following is the formula for balance column.
    Whileprintingrecords;
    Shared Numbervar balance;
    Shared Numbervar display;
    balance:={@debit}-{@credit};
    display:=display+balance;
    display

    As this question is out of the T-SQL queue, thus I would suggest you consult Crystal Report questions to the correct forums.
    C#
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral
    VB
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral
    people there have more knowledge on Crystal Report.

  • I can't seem to see sync my mac and iphone using iCloud with numbers and pages how can i correct this?

    Hi
    I've used Numbers and Pages for IOS for sometime now and when i use safari to look at my icloud account i can see all my files. Recently i bought Numbers for Mac and now whenever i create a spreadsheet on my mac i can't see it on my iphone but i can if i login to icloud. In fact i can only see about 16 files on my iphone when there is over 40 files.
    Although i don't yet have pages for mac i now have a similar problem with Pages, whenever i edit a file or even create a file on IOS it doesn't appear in icloud.
    I did think it was something to do with me not selecting backup to icloud so i then spent £14 to upgrade my storage to 15GB and that hasn't helped.
    I've checked all the settings and can't see anythng that will cause the problem.
    My iphone is running IOS 6 and my Mac is running Mountain Lion 10.8.2
    Does anyone know how to correct this mess?
    Many thanks in advance.
    Mick.

    Problems with buttons and links at the top of the page not working can be caused by an extension like the Yahoo! Toolbar or a Babylon extension that extents too much downwards and covers the top part of the browser window and thus makes links and buttons in that part of the screen not clickable.
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode

  • Cannot open previous files with numbers and pages since updating apps

    I updated the numbers and pages apps and am now unable to open any of my files it only shows as if they have no files attached.  Any suggestions are appreciated thanks

    Problem solve!
    I just re-install the flashplayer plugin using the firefox popup ( the button on top )
    and it works!

  • Fixed-length numbers and strings

    Hello,
    I have to make a critical decision about API usage. I would be grateful if some of you could share their experiences. This will help me make an informed decision and avoid potential trouble further down the line.
    I have to use fixed-length integer numbers and fixed-length strings such as for example:
    -A string that is exactly 5-letter long (no longer and no shorter than 5 letters). e.g. "abcde"
    -A number that is exactly 8-digit long (no longer and no shorter than 8 digits). e.g. "12345678"
    Ideally I would get some sort of exception when the "container" for the letters or digits contains less or more than what the spec says.
    I am not sure which classes or primitives could meet my needs. As far as the fixed-length string is concerned I initially thought of using a array of chars but an array of chars is not that easy to manipulate and contains "garbage" until you explicitely fill it in with data. I'd rather some sort of class.
    Can anyone please advise me?
    Thanks in advance,
    Julien.

    Why not use the same thing like in the case of the String
    /**Warning: this is an example and not very good design.*/
    public class FixedInteger {
       private int min, max;
       private int value;
       public int getValue() { return value;}
       public void setValue(int v) {
            if (v >= min && v < max) {
                throw new Exception();
            value = v;
       /**ex. min = 10000, max = 100000 for 5 digit numbers*/
       public FixedInteger(int min, int max, int value) {
           this.min = min; this.max = max;
           setValue(value);
    }You can do tricks like convert it to immutabla like the String and Integer class in the Java Api
    Edited by: szgy on Oct 5, 2007 2:22 PM

  • Adding Cells with numbers and text

    I am a real newbie at formulas - so if there is an obvious answer I am sorry.
    I am looking to add week numbers for a custom calendar. So in one cell I have Week 1. I am looking to have the following week add 1 to that - but keep the text Week - so we get Week 2. How can I easily go about this? Thanks

    That was interesting!
    The most difficult part was getting the calendar to recognize the closing days and make the necessary adjustments. Here's the result for September calendar, with the school year starting September 1 to demonstrate the effect of a closing day inserted after the year begins. (One fitting your year is shown below.)
    The small table to the right, "No School" is a one column table listing, in order, the dates (not including Sundays) on which the school will be closed. For periods where the school is closed for 2 or more consecutive days, each day must be included in the list. The table has two header rows and one footer row. As written, the formulas using this table require A1 to contain a non-date value, A2 to contain the date of the day before the first day of school—in the example, August 31, 2011; in your case, September 5, 2011, and the Footer row to contain a date after the last day of school.
    The cell displaying the month name, and all cells showing a day number, contain a Date and Time value, with the display determined by two Custom formats, set using the Cell Format inspector. The contents of the cells are used in calculations, and must be Date and Time values, not numbers.
    Row 1 is a header row.
    The full date for the first of the month to be shown is entered into the center cell in row 1. (This is a merged cell formed from the three cells C1, D1 and E1. Formulas using the value refer to it as C1.)
    G1: =EOMONTH(C1,0)
    This returns the date for the last day of the month of the date in C1. The date is used in a conditional formatting rule in the last row of the calendar. It can be hidden by setting the text color of this cell to match its background fill color (white).
    Row 2 is a header row, containing the names of the days of the week, using the Sunday to Saturday arrangement to match the illustration linked by the OP. A different starting day will require revisions to some formulas.
    A3: =C1-WEEKDAY(C1,2)
    This formula calculates the date of the last Sunday before the date in C1. If you don't like the fact that the "2" displays as "Monday is 1", the version below will produce the same result, with the second argument displaying as "Sunday is 1"
    A3: =C1+1-WEEKDAY(C1,1)
    B3: =A+1
    Adds 1 (day) to the date in A1. Fill this formula Right to column G.
    Select all cells in row 3 and format as Custom, Type: Date and Time, and including only the Day of Month element.
    B4: =(IF(MATCH(B3,No school :: $A,1)=MATCH(B3,No school :: $A,-1),"closed",("Week "&QUOTIENT(DATEDIF(No school :: $A$2,B3,"D")-MATCH(B3,No school :: $A,1),7)+1)))
    Fill this formula from B4 to G4. (Note that there is no entry in A4)
    At its heart, this is an IF statement that returns "closed" if the date in the cell above it is on the closed list or the text "Week n" if that date is not on the list.
    The first MATCH statement matches the 'largest' date less than or equal to the test date (in B3); the second matches the 'smallest' date equal to or more than the test date (in B3). If the date is on the list, both of the two MATCH statements will return the same value, and IF will return "closed".
    If the date is not on the list, the two MATCH statements will return different values, and IF will pass control to the "if false" part of the formula (everything following "closed", ).
    DATEDIF calculates the number of days since the first day on the No School list and subtracts the number of 'no school' dates in that time, using MATCH), then finds the Quotient when that number is divided by 7 (days in a week) and adds 1 to determine the week number. The concatenation operator ( & ) tacks that number to the end of the text string "Week " and returns the result.
    As can be seen in the Monday and Tuesday cells in row 4, the formula will return an error message (MATCH was unable to find...) if the date is earlier than any on the table. To eliminate this, insert IFERROR between the = sign and the parenthesis at the beginning of the formula, and ,"" (comma-quote-quote) between the last and next to last parentheses at the end. This is necessary ONLY on the first date row of the September calendar, so the change can be delayed until you have made a duplicate of the completed calendar table.
    Next, Select rows 3 and 4, then drag the Fill handle down two rows to copy all formulas into rows 5 and 6. Although the results may look correct, you should replace the formula in A5 with the one below:
    A5: =A3+7
    With that change made, select rows 5 and 6, then Fill down to rows 11 and 12.
    Conditional format rule: A3 - F3
    Set the rule: With Dates  Before the Date  C1
    Conditional format rule: A11 - G11
    Set the rule: With Dates  After the Date  G1
    The default format for both these rules is the grey text shown for the August and October dates on the September calendar.
    For months where another row of dates is needed, use the Add/Delete rows handle at the lower left of the active table to add two rows, select rows 11 and 12, and fill down. The filled cells will include the formatting set here.
    To create calendars for the rest of the months, select the table icon for the one completed, press command-D to duplicate it, move it to a free location, then enter the date for the first day on the month you want into cell C1 of the new calendar. Here's the result for May, 2012:
    And here's the September calendar fitted to your school year beginning on September 6, with no other closings in September (and with the error trap mentioned above applied to the first week of dates).
    Regards,
    Barry
    PS: email me directly for a copy of the file. Address available by clicking my name.

  • ICloud with Numbers and Pages on Lion

    I have two computers: an old one with the latest Lion and a new one with the latest Mountain Lion.   I have Numbers09 and Pages09 on both computers, bought long ago on disk. Exactly the same copy, copied from old to new computer.   I don't remember when I got the last update, it was also long ago.  Point is since they did not come from the app store, they did get not automatic updates to keep up with the cloud.  Apple orphaned them long ago.
    Now, both Pages and Numbers on the new computer can access iCloud, save docs to the cloud and move docs in and out (although if the new iWorks - iCloud or iOS version touches them, I can no longer open the docs, but that's something else).
    On the other hand, Pages and Numbers on Lion cannot access iCloud. There is no iCloud tab like on Pages/Numbers on ML.  Cloud is on, and Docs and Data checked.  It also warns me the local version of cloud docs will be deleted when I uncheck the box.  Cloud on Lion works fine otherwise: bookmarks, contacts, calendar.
    My question is: Is this expected or not? If not, how to fix it.
    Thanks in advance

    Never mind, now I see quite  a few threads.  It seems Apple disabled ~/Libray/Mobile Documents on Lion...

Maybe you are looking for

  • [SOLVED] DPMS screen off not working with xorg 1.16.0, gnome 3

    After the update of xorg into 1.16.0-2, screen is not turned off by DPMS in GNOME. I also tried an manual command: $ xset dpms force off but it's not working. In other WM, this command is working. With xorg 1.15.2 and gnome 3, there is not this probl

  • Does anyone know if Vista runs on MacPro?

    Just wondering if anyone has info on Windows Vista compatibility and functionality on MacPro. Like many, I have to keep a PC around to run certain applications, and I'm looking forward to the promise of the one box (MacPro) solution. Thanks!

  • Setting up default application?

    Hello, is there a way to make certain filetypes open with a different application on default? For example, say I have a bunch of video clips that are in .mov (which opens in quicktime on default). Is there a way to set it up so that any .mov would op

  • ITunes 10.01 crashes when trying to connect to iTunes store.

    I am wondering what is happening that my iTunes app crashes when it is connecting to the iTunes store. I recently had to reinstall the OS when my laptop stopped booting. I then re-populated my Mac with Migration assistant from a Time Machine back-up

  • How to export conacts, calendar, reminders from Z10??????

    Hi, What is the easiest and fastest way to export contacts, calendar entries and reminders out of Z10? I have tried everything, nothing seems to have worked so far: 1) BB Link - tried syncing to outlook already, IMAP issue, does not sync contacts to