How to convert any datatype to a number

Hi --
I have a query I'm writing, and for error-trapping purposes I want to convert whatever information I received in a bind variable into a number.
For instance, in my query:
SELECT TO_NUMBER('c') FROM dual
I get an error because 'c' is not a number. I'm usually expecting a number, but if for some reason I receive a character, I want to convert that character to a zero, and if I do receive a number I want it to retain its value. I hope this is clear!!!
Any suggestions are greatly appreciated.
Thanks,
Christine

Unfortunately, I need to do this directly in the SQL statement if at all possible.If you don't want to use a function, try :
  1  select case when ascii('&1') between 48 and 57 then to_number('&1')
  2              else 0 end
  3* from dual
SQL> /
Enter value for 1: a
Enter value for 1: a
old   1: select case when ascii('&1') between 48 and 57 then to_number('&1')
new   1: select case when ascii('a') between 48 and 57 then to_number('a')
CASEWHENASCII('A')BETWEEN48AND57THENTO_NUMBER('A')ELSE0END
                                                         0
SQL> /
Enter value for 1: 5
Enter value for 1: 5
old   1: select case when ascii('&1') between 48 and 57 then to_number('&1')
new   1: select case when ascii('5') between 48 and 57 then to_number('5')
CASEWHENASCII('5')BETWEEN48AND57THENTO_NUMBER('5')ELSE0END
                                                         5
SQL> Nicolas.
ascii(9) => 57
Correction for ascii(0) => 48 and not 49...
Message was edited by:
N. Gasparotto

Similar Messages

  • I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.

    I know that how to convert any documents to pdf file, but don't know how to get barcode on it. I am using windows 8.1. and want to see barcode on my documents before the print. Please help.

    Hi Frank ,
    Please refer to the following link and see if this helps.
    https://helpx.adobe.com/acrobat/kb/error-organizer-database-damaged-reset-1.html
    Regards
    Sukrit Dhingra

  • How to convert an int variable into Number

    Hi all,
    I am using Jdeveloper 11.1.1.2
    When I insert a row in a entity object I want to create another row in another entity object, but when I am setting the attribute for the new row I have a problem.
    Here is the code:
    int a = EO1Impl.paramA;
    NameEO2Impl.setAttribute("Attribute1", a);
    The error is that variable a is an int, while Attribute1 is a Number.
    How can convert an int to a Number.
    Thank you.

    Andrea9,
    If a, as you say is an int, and assuming you mean an oracle.jbo.domain.Number,
    NameEO2Impl.setAttribute("Attribute1", new oracle.jbo.domain.Number(a));works just fine.
    John

  • Full Guide: How to convert any DVD and videos to iPod Touch/Classic/Nano

    This full guide includes four parts.
    (1) How to Crack DRM video and audio files
    (2) How to Rip a DVD to put it on iPod/iPhone 3G/PSP/Zune/Sansa View/iRiver……
    (3) How to convert and burn WMV/AVI video directly to DVD
    (4) How to transfer video/music from iPod to computer
    Part 1: How to crack DRM video and audio files
    Daniusoft Digital Media Converter Pro(http://www.topsevenreviews.com/daniusoft-digital-media-converter-pro.html) software is the quickest and easiest solution to remove drm from WMV, M4V, M4P, WMA, M4A, AAC, M4B, AA files by quick recording. You can use this professional tool to crack drm and put them on your iPod/iPhone 3G/PSP/Zune/Sansa View/iRiver……
    The process is as follows:
    Step 0: Download Daniusoft Digital Media Converter Pro(http://www.topsevenreviews.com/download/video-music-converter/daniu-digital-media-converter-pro.exe), install and run it.
    Stpe 1: Run the software and click “Add…” button to load WMA or M4A, M4B, AAC, WMV, M4P, M4V, ASF files
    http://www.topsevenreviews.com/guide/how-to-convert-drm-protected-music-movie/digital-media-pro-n2.jpg
    Step 2: Choose output formats. If you want to convert protected audio files, please select “Convert audio to” list; If you want to convert protected video files, please select “Convert video to” list.
    Stpe 3: You can click “Settings” button to custom preference for output files.
    Click “Settings” button bellow “Convert audio to” list for protected audio files
    http://www.topsevenreviews.com/guide/how-to-convert-drm-protected-music-movie/audio-output-setting.jpg
    Click “Settings” button bellow “Convert video to” list for protected video files
    http://www.topsevenreviews.com/guide/how-to-convert-drm-protected-music-movie/video-output-setting.jpg
    Step 4: Start remove DRM and convert your DRM protected music and videos by click on “Start” button.
    Part 2: How to rip a DVD to put it on iPod/iPhone 3G/PSP/Zune/Sansa View/iRiver……
    With Aiseesoft DVD Ripper you can rip and convert any DVD to most popular videos supported by your iPod, iPhone 3G, PSP, Zune, Sansa Video and other portable devices.
    Step 0: Download Aiseesoft DVD Ripper(http://www.topsevenreviews.com/aiseesoft-dvd-ripper.html), install and run it.
    http://www.topsevenreviews.com/image/aiseesoft-converter-suite/dvdripper-n2.jpg
    Step 1: Click “Load DVD” button to load your DVD.
    Step 2: Select the output video format you want from the “Profile” drop-down list.
    Step 3: Click the “Start” button to start your conversion and In a short while it will be finished.
    Tips:
    You can also use the powerful editing funtion (Snapshot, Merge, Effect, Trim, Crop)to edit your DVD.
    Part 3: How to convert and burn any video directly to DVD/VCD/SVCD
    With Cucusoft DVD/VCD/SVCD Creator Pro you can burn any AVI/WMV videos to DVD.
    The process is as follows.
    Step 0: Download Cucusoft DVD/VCD/SVCD Creator Pro(http://www.topsevenreviews.com/cucusoft-dvd-creator-pro.html), install and run it.
    http://www.topsevenreviews.com/image/burndvd-n2.jpg
    Step 1: Choose the “To DVD” button and click "Opne/Add" button to import WMV/AVI files to convert WMV/AVI to DVD.
    Step 2: Select Merge or Batch function.
    Batch Function, Support converting multiple files to DVD VCD SVCD MPEG1/2 at the same instance
    Merge/Join function, Support selecting several clips from different sources and combine them into one single output
    Step 3: Set your preference to burn WMV/AVI to DVD.
    Step 4: Click "More Advanced Settings" button to set advanced settings for your files.
    Step 5: Choose the “Output Folder” and Click “Convert & Burn” button to start.
    Part 4: How to transfer video/music from iPod to computer
    With Aiseesoft iPod to Computer Transfer you can tranfer or backup your videos and songs to your computer.
    Step 0: Download Aiseesoft iPod to Coumputer Transfer(http://www.topsevenreviews.com/ipod-to-computer-transfer.html), install and run it.
    http://www.topsevenreviews.com/image/ipod-to-computer/connectipod-n2.jpg
    Step 1: When you connect your iPod to the computer via USB cable and run the program, the program will detect and recognise your device automatically.
    Step 2: Then from the file list, you can choose the audio or video files that you want to transfer and a detailed list will be displayed at the right for your to choose.
    Step 3: Choose the songs you want to transfer and then click the "Start Transfer " button below the list to begin transferring files from iPod to computer.
    Step 4: In a short while your conversion will be finished
    Hope the guide collections can be helpful for all of you.
    Mac Video Converter(http://www.macsoftreviews.com/iskysoft-video-converter-mac.html)
    Best DVD Ripper(http://www.topsevenreviews.com/)
    iPhone Ringtone Maker(http://www.macsoftreviews.com/aiseesoft-iphone-ringtone-maker.html)

    Use Automator. QuickTime is Automator compatible. However, you will first need to download the "iPod" script from the Automator web site. For a tutorial and instructions, download Brian Gary's "Automator for the People" Ripplecast from the iTunes podcast area.
    2.0GHZ G5/533MHz G4 DeskTop/400MHz G4 PB   Mac OS X (10.4.3)  

  • How to convert "any" date format to internal format

    Hi,
    I want to convert any date format  to internal format. Is there any function module ?
    The date formats could be:
    DD.MM.YYYY
    MM/DD/YYYY
    MM-DD-YYYY
    YYYY.MM.DD
    YYYY/MM/DD
    YYYY-MM-DD
    Thank you,
    Surya

    Hi,
    Check this sample program..It will convert sap supported external format to the internal format..
    PARAMETERS: v_char(10).
    DATA: v_date TYPE sydatum.
    DATA: v_period TYPE usr01-datfm.
    Get the format.
    DD.MM.YYYY
    IF v_char+2(1) = '.'.
    CONCATENATE v_char6(4) v_char3(2) v_char(2) INTO v_date.
    ENDIF.
    MM/DD/YYYY
    IF v_char+2(1) = '/'.
    CONCATENATE v_char6(4) v_char(2) v_char3(2) INTO v_date.
    ENDIF.
    MM-DD-YYYY
    IF v_char+2(1) = '-'.
    CONCATENATE v_char6(4) v_char(2) v_char3(2) INTO v_date.
    ENDIF.
    YYYY.MM.DD
    IF v_char+4(1) = '.'.
    CONCATENATE v_char(4) v_char5(2) v_char8(2)  INTO v_date.
    ENDIF.
    YYYY/MM/DD
    IF v_char+4(1) = '/'.
    CONCATENATE v_char(4) v_char5(2) v_char8(2)  INTO v_date.
    ENDIF.
    YYYY-MM-DD
    IF v_char+4(1) = '-'.
    CONCATENATE v_char(4) v_char5(2) v_char8(2)  INTO v_date.
    ENDIF.
    WRITE: / v_date.
    Thanks,
    Naren

  • How to convert amount data element to number data element

    Dear Gurus,
    I have a requirement to get the data by calling BRF+ and then pass them to BAPI 'BAPI_ASSET_ACQUISITION_POST', in the BRF+ export structure, there is a field 'AMOUNT', I bind it to DDIC element 'BF_ANBTR', the type is Number.
    In BRF+, I call another global function to calculate the value, I define a local variant LV_VALUE to get export value from this function, this local variant's type is Amount, now I need to move this local variant value to the export field 'AMOUNT'.
    But BRF+ doesn't allow to convert amount data element to number data element directly, and I find there is no formula function available. Only there is a function 'TO_AMOUNT' to convert number data element to amount data element.
    Please help to get a solution for above solution.
    Thanks.

    Hi,
    within the formula expression within the category "Mathematical functions" you will find the function "TONUMBER". This converts a data element of type currency to a number. According to the help of this function:
    "The following conversion rules apply:
    <Amount>: The number part is returned. The currency unit is omitted."
    This is what you are looking for.
    For the other way round you already mentioned the correct function "TO_AMOUNT"
    BR
    Christian

  • Help with how to convert a string to a number ??

    Hi All,
    I am having problem converting a string to number.
    Looks like my to_number function is not working.
    Help is very much appreciated.
    My query is below, and I know my problem is in my inner query.
    I am getting the following error:
    what am I doing wrong ? and how should I fix it.
    If there is a better approach, please share it.
    ORA-01722: invalid number
    01722. 00000 -  "invalid number"
    *Cause:   
    *Action:
    SELECT
        A.OBJECT_NAME,
        A.TIMESTAMP,
        A.SESSION_ID,
        A.REQUISITION_ID,
        TO_DATE(CUT(RR_PACE_FUNCTIONS.NAME(A.REQUISITION_ID),3,'.'),'YYYYMMDD') CSD,
        SUBSTR(SUBSTR(RR_PACE_FUNCTIONS.DESCRIPTION(A.REQUISITION_ID),9),1,30) COURSE_ID,
        A.WEEK_GROUP,
        A.APTITUDE_AREA,
        SUM(NVL(GTEP_ASGN,0)) GTEP_ASGN,
        SUM(NVL(AI_ASGN,0)) AI_ASGN,
        SUM(NVL(GTEP_ASGN,0) + NVL(AI_ASGN,0) ) BMT_ASGN
      FROM
        (SELECT OBJECT_NAME,
          SESSION_ID,
          TIMESTAMP,
          TO_NUMBER(FIELD1) REQUISITION_ID,  -- I believe here is the problem
          TO_NUMBER(FIELD2) WEEK_GROUP,     -- here as well
          SUBSTR(FIELD3,1,80) APTITUDE_AREA,
          TO_NUMBER(FIELD4) GTEP_ASGN,  -- here
          TO_NUMBER(FIELD5) AI_ASGN      -- here
        FROM RR_REPORT_QUEUES
        ) A
      GROUP BY OBJECT_NAME,
        TIMESTAMP,
        SESSION_ID,
        WEEK_GROUP,
        APTITUDE_AREA,
        REQUISITION_ID ;Many Thanks,

    Are you sure Field1, Field2, Field4 and Field5 contain a number information in all rows?
    If there is a non numeric String in your Field<x> columns in any row the error will occor.

  • How to convert any date format?

    Hi,
    In the BPEL process I am getting the input in 'DD-MON-YYYY' format, I want to convert it to 'DD-MM-YYYY' format.
    The function xp20:formatDateTime('string', 'image') expecting the string to be in 'YYYY-MM-DD' format. and the 'image' can be set to any format.
    So i am able to convert to any format if I have the input string in 'YYYY-MM-DD' format, if I get in different format then how do I change them to required format?
    --Khaleel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Looks like you are sending the date in Oracle format. If the date is created by a DB adapter the date should be formated in the correct format for BPEL to format (YYYY-MM-DDTHH:MI:SS). To make sure this happensyour xml needs to be the date data type and the value sent maust be a date not a string, if it is a string use the to_date to make it a date field.
    You are correct once it is in the YYYY-MM-DD format you can change to any format.
    cheers
    James

  • How to convert the exponential data into number

    Hi,
    I have a table with a column which is a vaarchar2(60). I have a CSV file in which, I have stored value as 77052512125510000, but it got converted into 7.71E16. And when I have stored the same in the database, it got saved as 7.71E16. How can I get the original value
    Please help
    Regards
    Edited by: Sarma12 on May 25, 2012 3:11 AM

    Sarma12 wrote:
    The issue is, the data is already copied into the database. Now while retrieving from the database, I am getting that value in the scientific notation and not similar to the data which I have in the CSV file.
    RegardsYou need to be smarter than the tools you use
    bcm@bcm-laptop:~$ sqlplus user1/user1
    SQL*Plus: Release 11.2.0.1.0 Production on Fri May 25 09:50:02 2012
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    09:50:03 SQL> @test
    09:50:07 SQL> drop table test;
    Table dropped.
    09:50:09 SQL> create table test (id number);
    Table created.
    09:50:10 SQL> insert into test values (77052512125510000);
    1 row created.
    09:50:10 SQL> select * from test;
         ID
    7.7053E+16
    09:50:10 SQL> column id format 999999999999999999999
    09:50:10 SQL> select * from test;
                  ID
         77052512125510000
    09:50:10 SQL>
    09:50:10 SQL>

  • How to convert String "(50-10)" to number and get output as 40 as a number.

    Hi,
    I have a string with formula, eg: String formula="(ABC-DEF)";
    I replaced the values of ABC and DEF in the above string now I have formula="(50-10)";
    How can I calculate the above value and get output (40)as a number like int or double.
    Regards
    Alex.
    Edited by: AlexRaju on Dec 8, 2009 10:11 AM

    Values for ABC and DEF are coming from different java collections like HashMap or ArrayList etc. The formulas can be complex which need some string manipulations and atlast I will get a string like "(50-10)" or "(20+(Math.SQRT(25)/Math.Power(2,3)))". Here all the numbers are values for variables like ABC or DEF coming from different hashmaps and arraylists based on different conditions.
    Thanks
    Alex.
    Edited by: AlexRaju on Dec 8, 2009 10:36 AM

  • How to convert any date format to default US format using javascript???

    Hi,
    I was trying to convert a date format to default US date format. The date format will vary according to different regions (It can be dd/MM/yyyy or MM/dd/yyyy or yyyy/dd/MM or any). I need to convert it in to MM/dd/yyyy always (US Format). Please give some
    solutions for the same.
    Warm Regards,
    Tony Joy

    hi
    it is not trivial task in common case. We faced with similar issue when tried to localize date times in display templates in Sharepoint 2013 depending on site's locale, which can be done only via javascript. In order to do it you need to add date time locale
    information from server side to client side, e.g. by defining global variable. See the following article for details:
    Localize datetimes in display templates in Content by search web parts in Sharepoint 2013. I extended OTB global object _spPageContextInfo with new property (as far as I remember this object is also available in Sharepoint 2010):
    <script type="text/javascript">
    jQuery(function() {
    if (typeof (_spPageContextInfo) != "undefined" &&
    _spPageContextInfo != null) {
    <%
    var ci = new CultureInfo(1033);
    var cultureSerialized = new JavaScriptSerializer().Serialize(
    new
    name = ci.Name,
    dateTimeFormat = ci.DateTimeFormat,
    numberFormat = ci.NumberFormat
    %>
    _spPageContextInfo.currentCultureSerialized = <%= cultureSerialized %>;
    </script>
    Having different date time formats for your locale, you may use
    Date.localeFormat function from MS Ajax for formatting the date in specific format. If in your case format is predefined you may hardcode it without adding DateTime formats from server side.
    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

  • How to convert a string list to number list

    Hi
    I have a table1 that codeid is a number(2)
    and other table2 that obtain the codeidlist in a varchar2(50) where I save the codeid that I selected from table 1, I can be one o more : 1,2,4,5 etc.
    I wanna make this but It gives an error: Invalid Number
    Select * from tabla1
    where codeid i not in (select codelidlist
    from table2
    where cliente='Oscar')
    how can I solve that?

    if you want to get rid of the connect by level
    (not sure if it will speed things up or not)
    you could try model
    untested as I don't have your tables but something like
    /* Formatted on 4/11/2011 1:00:37 PM (QP5 v5.149.1003.31008) */
    with code_list as
    SELECT codelidlistt list
      FROM  table2
      where cliente = 'Oscar'
    MODEL RETURN UPDATED ROWS
       PARTITION BY (ROW_NUMBER () OVER (ORDER BY codelidlistt) rn)
       DIMENSION BY (0 d)
       MEASURES (codelidlistt)
       RULES
          ITERATE (1000) UNTIL codelidlistt[ITERATION_NUMBER] IS NULL
          codelidlistt [ITERATION_NUMBER + 1] =
                REGEXP_SUBSTR (codelidlistt[0],
                               '[^\,]+',
                               1,
                               ITERATION_NUMBER + 1))
    select *
      from table1
    where codeid not in (select list from code_list )Edited by: pollywog on Apr 11, 2011 1:03 PM

  • How to convert ASCII to an integer number??

    Here I am trying to send the number 1000000 from microcontroller through UART and I am recieving the ASCII in labview. But i would like to get exact 1000000 in labview too. So i am trying to convert ASCII to integer but i am unable to do that.
    Solved!
    Go to Solution.

    danil33 wrote:
    Hello mallik,
                       Please don't feel bad.Smercurio and all other experts are trying to make us to do things by our own.THis will make us experts in labview.Thats why he told you to go through the tutorials.I have heard such type of advice(sometimes they scold us) so many times.Still Iam hearingIt is our fault that we won't go through the tutorials properly.Don't get annoyed.
    Besides, the question is quite unclear formulated and makes me almost assume, that the OP hasn't even bothered to look for a solution himself. Since the OP receives a string it would be logical to look in the String palette for some function to do what he wants. And inside that palette there is magically a String/Number Conversion palette, which sounds almost like it could contain at least one function that could do the right thing. (In fact it contains 3 that could work, but I'm sure the OP can find the most logical one for his number easlily).
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to convert any CAML query to SharePoint Search query (like KQL , FQL )etc

    Hi ,
    To query multiple lists with lookup column, CAML query is preferred over Search API.
    Is there an easy way to get this done with Search API or  using Search OOB features like query rules,result types etc?
    Can CAML query configured in Content search webpart
    Swati
    SP Page: http://www.facebook.com/SharePointQ SP Blog: http://swatipoint.blogspot.com

    Hi Swati,
    As I understand, you would like to query lookup column in content search web part. I found a similar issue for your reference:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/6be2fd2b-df0d-4054-af5d-bb23200593b2/content-query-web-partquery-on-lookup-fields
    For more information:
    http://blogs.msdn.com/b/kaevans/archive/2009/02/23/the-content-query-web-part-and-working-with-lookup-fields-in-a-custom-web-part.aspx
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Essbase 9.3 Calc scripts. Pb with dates. How to convert (string = number) ?

    Hello,
    I've a problem with Essbase(Planning?) Scripts on version 9.3. It looks simple but I do not find any (clean) solution :
    On my Essbase database, I have a member called "Reference_Date" on my axis Indicators. It is a date data type, that is to say, it displays a number corresponding to a YYYYMMDD format. For example : 20091029 for October 29th 2009.
    In calc scripts I often need to compare the month included in that "Reference_Date" with the current Member of my Time Axis (I have 12 Months members based on the format M02 for February for example). The final aim is to calculate a number of complete years since that "Reference_Date".
    But theses two elements are not of the same "type" (one is a number value and the other is a "member" in Time Axis). So I'm forced to convert one of this two elements in order to compare it.
    For example I can extract the month value of the "Reference_Date"' and put an "M" before it to have a Time member equivalent or I can convert the member Name M10 to a number (10))
    in both cases I have the same type problem : I don't know how to convert a string into a number nor how to convert a number into a string.
    (For example @CONCATENATE doesn't work with numbers). and that my only remaining problem.
    I didn't find any Essbase Function which do this (conversion number <=>string).
    Is anyone have an Idea ?
    Thanks for your help
    Best regards

    I don't know any way for you to compare your data against your metadata. Not directly. To me it makes little enough sense to try that I'm not surprised the developers didn't provide for it.
    I've converted member names to strings, manipulated the strings (calc script functions are not good at this), and turned them back into member names, but that's really the only use I've had for string manipulation. I don't think an equivalency operator even exists for string data. And I see no way to begin thinking of a member name, once converted to a string, as a number.
    It makes even less sense to me to try thinking of a data value as a string. Even text values in Sys 11 are stored as numbers. Not encoded characters, but just a number to look up somewhere.
    I think you can do what you want though, with something like this...
    IF (@ISMBR("FY08"))
    vYr = 2008;
    ELSEIF (@ISMBR("FY09"))
    vYr = 2009;
    ENDIF;
    IF (@ISMBR("M01"))
    vMth = 1;
    ELSEIF (@ISMBR("M02"))
    vMth = = 2;
    ENDIF;
    "Years_Since_Reference" = ((vYr * 100) + Mth) - ("Reference_Date" / 12);
    Obviously, the math will need some work, coz that doesn't actually work, but the logic above essentially turns your metadata into numbers, which is what you are after.
    Good luck,
    -- Joe

Maybe you are looking for

  • Can I use a iTunes card for iTunes match?

    Igot a 25 dollar iTunes gift card and I tried redeeming it for iTunes match but it wont let me it still says I need a credit card on file.  Whats the deal APPLE? Can I use the gift card, if not what do I have to do?

  • Windows 7 Blue Screen Crash

    Hello, I recently have been getting a lot of blue screen crashes simultaneously. I haven't downloaded any games or anything. I just use this laptop for school work mostly. I already ran a memory diagnostic test and no problems found as well as restor

  • Can not access Adobe camera raw in PS CS5. Have a mac OS 10.9

    How do i access adobe camera raw for images fro Nikon D 7100.

  • Creating .pdfs

    I am having trouble creating pdfs. I am running the latest flavour of Leopard, Office Mac 2008, together with Acrobat Professional 8.1.2. If I try and create a pdf from within Acrobat using the Create command I get an error telling me that the docume

  • Vendor Tolerance

    First Question: We have tolerances for vendors. I read somewhere the foll tolerances are defined for vendors: 1. Quantity variance 2. Price variance 3. Purchase order price quantity variance 4. Date variance Can someone please explain all four of  th