Error number invalid when using case when

I have a table called NATIONAL_RARE_ECOSYSTEMS that contains 1 column called TEST_COLUMN (data type: varchar2):

TEST_COLUMN
rare ecosystem
rare
0
0
(null)
(null)

what I want is a query that will add a column called NRE_SCORE that will give each instance of line a score of 0 if it is null.
If it is 0, then the score should be 0.
If the line contains any text, partition should be 1

I wrote the request:

SELECT
(CASE WHEN test_column is null THEN 0)
WHEN test_column = 0 THEN 0
WHEN test_column > 0, 1
END) AS NRE_SCORE
OF NATIONAL_RARE_ECOSYSTEMS;

I get the error message:

ORA-01722: invalid number
01722 00000 - "invalid number."

I think it is because on the 2nd and 3rd line, trying to perform arithmetic operations on a column which is varchar2 which I know that I can't do.

How can I write a query that says: If the line contains text, then gives the score of 1?

I'm using oracle 11g.

Hello

993451 wrote:
I have a table called NATIONAL_RARE_ECOSYSTEMS that contains 1 column called TEST_COLUMN (data type: varchar2):

TEST_COLUMN
rare ecosystem
rare
0
0
(null)
(null)

what I want is a query that will add a column called NRE_SCORE that will give each instance of line a score of 0 if it is null.
If it is 0, then the score should be 0.
If the line contains any text, partition should be 1

Any text other than '0', you mean. I guess that doesn't matter if this text is all the numbers, like '9876 'or something with no numbers, as 'rare'.

I wrote the request:

SELECT
(CASE WHEN test_column is null THEN 0)
WHEN test_column = 0 THEN 0
WHEN test_column > 0 THEN 1
END) AS NRE_SCORE
OF NATIONAL_RARE_ECOSYSTEMS;

I get the error message:

ORA-01722: invalid number
01722 00000 - "invalid number."

I think it is because on the 2nd and 3rd line, trying to perform arithmetic operations on a column which is varchar2 which I know that I can't do.

You are not actually doing arithmetic, but you compare your VARCHAR2 column, so he tries to convert the string to a NUMBER, and that's why you get the error ORA-01722.
>

How can I write a query that says: If the line contains text, then gives the score of 1?

I'm using oracle 11g.

Here's one way:

SELECT       CASE
           WHEN  NVL (test_column, '0') = '0'
           THEN  0
           ELSE  1
       END          AS nre_score
,       ...          -- you must want other columns, too
FROM       national_rare_ecosystems
;

Since you are not really care on the numerical value, do not use numbers anywhere; stick with VARCHAR2s, for example '0'.

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Point where the above query was to get erroneous results, and explain, using specific examples, how you get these results of the sample data in these palces.
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • I get the error number: 0x80072EE2 when I try to run windows or microsoft update under Win xp

    I get the error number: 0x80072EE2 when I try to run windows or microsoft update under Win xp

    Hello

    I suggest you try all the steps in the following article.
    You may encounter temporary connection related errors when you use Windows Update or Microsoft Update to install updates.
    http://support.Microsoft.com/kb/836941

    I hope this helps.

  • Serial number invalid when you reinstall adobe acrobat 9 pro Presentation

    Serial number invalid when you reinstall adobe acrobat 9 pro on Dell inspiron 3521 Presentation, windows 8.1, laptop crashed and all re-installed OS, I bought on Amazon and have the box and original media.

    Hey barbarap79129410,

    Please see the below link mentioned the same thing:

    Error "invalid serial number". Acrobat 9 | CS4

    Let me know if it helps.

    Kind regards

    Ana Maria

  • I get error number ox80248015 when I try to install the update from the ms window

    I get error number ox80248015 when I try to install the update from the window

    see if that covers your situation: http://support.microsoft.com/kb/896226

    Also make sure that the date and the system time is set correctly.

  • Unknown error number 1 when you install adobe muse 2015

    Unknown error number 1 when you install adobe muse 2015

    What do I do? Help, please!

    Error code 1: "unable to install". Creative Cloud Desktop: https://helpx.adobe.com/creative-cloud/kb/failed-install-creative-cloud-desktop.html

    https://forums.Adobe.com/message/7533806

  • error [error number: 0x8DDD0007] when you try to use the MS update

    error [error number: 0x8DDD0007] indicating that the restart is required after MS updated to windows xp sp3. I've done several reboots but still get same error (restart required) - taken from the shield on the side right shows exclamation sign and indicates that a restart is required. I tried to run fix - it but added (info sent to MS) tried second answer - run regedit and remove "Restart required", but which was not displayed.

    Hello

    Follow the steps below

    Important : this section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    http://support.Microsoft.com/kb/322756

    How to back up and restore the registry in Windows

    (a) start the computer in Mode safe

    (b) press Windows R, type regedit and press enter

    (c) go to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Intelppm

    (d) right click on the boot entry in the right pane and select Edit

    (e) enter 4 in the value data box

    (f) close regedit, restart the computer

  • Error number: 0x8024D001 when you run windows update

    Here's my situation, I wiped recently my installation of Win XP Pro x 86 original seven ' 07, now running in the title error when you run windows update after reinstalling.

    A little of what I've done already;

    • http://support.Microsoft.com/kb/2497281/en-us
    • I went through the steps to download and win xp sp3 app, have always error WU (will abreviate Windows Update this for now).
    • To run Microsoft fix it found 50777 persists.
    • Has been through the steps in the method 1: save the Windows Update files. Problem persists
    • Spent by method 2: replace the folder C:\Windows\SoftwareDistribution Windows Update. Problem persists.

    Next

    Other

    • Set the firewall disabled (I know it is not recommended, but until it's resolved I leave it)
    • Internet Security in IE8 is set to medium
    • IE v8.0.6
    • IE 8 privacy set to low temperature

    Help please? :(

    First, download the .NET Framework here repair tool:
    http://www.Microsoft.com/en-GB/download/details.aspx?ID=30135

    If this doesn't fix the problem. try to run .NET Fixit recording:
    http://support.Microsoft.com/kb/976982/en-GB

    Or the other of these two should solve the problem for you, but in the case where it is not, then here are some alternatives:

  • I receive [error number: 0x8024400A] when you try to run Windows updates

    Recently, I rebooted my computer to make it work better. I have inserted the two disks of Intel and am having problems with the express Installer driver cd indicating that he can not upoad. When I run windows update, I get [error number: 0x8024400A]. I downloaded SP1, SP2 & SP3 from the Web site, but I still receive this message as not having no no access to SP3. Help, please.

    http://support.Microsoft.com/kb/2497281

    You may be unable to access the Windows Update site...

    If you have updated to SP3 see: resolution if you have already installed the latest Service Pack

    In case of doubt, to determine which service pack is currently installed on your computer, follow these steps:

    1. Click Startand then click run.
    2. Copy and paste, or type the following command, and then click OK:
      winver

      A dialog box displays the version of Windows and the service pack that is currently installed on

  • Error "the website has encountered a problem and cannot display the page you are trying to view. "Error number: 0x8024400A" when you try to install the updates

    Original title:

    I just reinstalled Windows XP on a laptop.  When I click on Windows Update in "all programs" selection, I'm headed on the update site, but I get this "the website has encountered a problem and cannot display the page you are trying to view. The options provided below may help you solve the problem. "Error number: 0x8024400A" is it an express update or Microsoft update.

    Hello
     
    Method 1:
     
    Run the fixit available at the following link.
    The problem with Microsoft Windows Update is not working
     
    Method 2:
     
    Check out the following link.
    Windows Update, on new installation 0x8024400A error
  • Error number: 0x800CCC0D when trying to email

    I get this error when you try to e-mail.

    The host 'smtp' could not be found. Please check that you have entered the server name correctly.
    Object ", account: 'pop3', server: 'smtp', Protocol: SMTP, Port: 25, secure (SSL): no, Socket error: 11001, error number: 0x800CCC0D

    SMTP is not a host or server name. POP3 is not an account name.

    Windows Mail: Setting up an account of end-to-end
    http://Windows.Microsoft.com/en-us/Windows-Vista/Windows-mail-setting-up-an-account-from-start-to-finish

    Connect with your e-mail server or visit their Web site for the correct settings.

    Bruce Hagen ~ MS - MVP [Mail]

  • Error number: 0x800CCCOF when sending mail through microsoft mail

    When you try to send e-mail through microsoft mail works on Windows Vista, I get this error number. I put my server out as smtp.west.cox.net.

    Give them the FULL error message when repost you your question; is not part of it.

    It comes with Vista, upgrade install and activate Forum.

    http://social.answers.Microsoft.com/forums/en-us/vistanetworking/threads

    "Connect to a network, electronic mailand the Internet."

    They will help you with your question in the Vista Networking Forum above.

    See you soon.

    Mick Murphy - Microsoft partner

  • Error number: 0xC800042D when installing updates day & computer is slow.

    Original title: error number: 0xC800042D.

    Computer running slow, and trying to go to windows update I get error number: 0xC800042D.  What seems to be the problem?

    0xC800042D - 939523027 HrVersionStoreOutOfMemory

    Reset the Windows Update components?

    http://support.Microsoft.com/kb/971058>

  • Error number return when and ORA: 01722 invalid

    Hi people, I posted this under another topic as well as eBusiness suite so apologies if some you've seen, but I would really appreciate the help on this one. Any suggestions are welcome.

    We strive to create a calculation that returns the number of days of absence a person has had in a given period of time. We need answer these absences which began before the period and are closed during it, lack that begins during the period and ends after she and those that open and close that it contains.

    The period is always a rolling 6 months from sysdate.

    It's the calc we found so far that works for some people, but we get the error invalid number if the absence includes a half-day - so 0.5, 1.5, etc..

    It's probably more complicated, but we are not the techno at all so learn we will!

    We use the business district of HRMS - Administration - Oracle Human Resources (Core) 10G and the folders present Absence and nobody.

    SUM (TO_NUMBER (NVL ((CASES WHERE the Attendance.Actual Absence Start Date < TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') THEN (BOX WHEN presence Absence.)))) "" Actual end date ' > SYSDATE SO (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), SYSDATE)) else (CASE WHEN (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence of Absence.)))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) "" Actual end date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." (((Actual end date")) END) END) END) IS NULL SO (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), SYSDATE)) else (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence Absence.))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) "" Actual end date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." (((((Actual end date")) END) END) END) END) END) else (WHEN BOX (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence Absence.)))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) "" Actual end date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." (((Actual end date")) END) END) END) IS NULL SO (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), SYSDATE)) else (BOX WHEN TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY') > = Absence Start Date of Attendance.Actual THEN (WORKING_DAYS_BETWEEN (TO_DATE (ADD_MONTHS (SYSDATE,-6), 'DD-Mon-YYYY'), presence Absence.))) (("" Actual end date ")) ELSE (CASE WHEN (WORKING_DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." Actual end date")) IS NULL SO (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (BOX WHEN SYSDATE < = presence Absence.) (("" END END END END END actual end Date ' THEN (WORKING_DAYS_BETWEEN (Attendance.Actual of Absence Start Date, SYSDATE)) ELSE (lack Attendance.Duration days))), (DAYS_BETWEEN (Start Date of Attendance.Actual of Absence, presence of Absence." ((Actual end date'))), '999999990 D 00'))

    Hello

    It could be that it's because you use SYSDATE that contains both as a fraction and not trunc (sysdate) that contains at present. It could be that your working_dates_between triggers this error.

    However, your formula is much more complicated that it should be.

    First of all, you want to watch the ADD_MONTHS (TRUNC (SYSDATE),-6) date at trunc (sysdate). So, you want to look the part of the absence which is located in the time stamp. It's the BIGGEST (Absence Attendance.Actual Start Date, ADD_MONTHS (TRUNC (SYSDATE),-6)) to LEAST (NVL (lack of attendance. (("" Actual end Date ", TRUNC (SYSDATE)), TRUNC (SYSDATE)). You may need to add 1 to the end of absence date because it is the last day of their absence, and not the date of their return. It depends on how you calculate the days between the beginning and the end
    Date of the absence. You can create calculations for the date of beginning and end of the absences in the time window of 6 months. Create the AbsenceStart calculation as

    Greatest (attendance absence. Actual Start date, ADD_MONTHS (trunc (sysdate),-6))

    and AbsenceEnd as

    LESS (NVL (lack of attendance. (("" Actual end Date ", TRUNC (SYSDATE)), TRUNC (SYSDATE))

    Next, you need to pick up only lack what part of the absence in your 6 months date window. To do this, you can use a condition in the workbook or a condition in a statement box. You must then calculate the difference between those dates and SUM all values.

    SUM (CASE WHEN AbsenceEnd > = AbsenceStart THEN WORKING_DAYS_BETWEEN (AbsenceStart, AbsenceEnd) END)

    That's all. Not so complicated after all.

    Rod West

  • Error number 1 when install Adobe CC to test Adobe Muse

    There is a solution to this problem?

    I discovered that the solution with Adobe Support Viviane H: is simply use Adobe Creative Tool Cleaner Cloud (I used version 8.0) to remove all the programs and processes Adobe and reinstall desktop Adobe Creative Cloud. It removes Flash Player and Adobe ACrobat but... works.

  • ORA-01722: error number invalid coming in Oracle 10 g.

    Hello

    We get the error "ORA-01722: invalid number" when opening a cursor using the CURSOR for LOOP.

    This error started only after we migrated to Oracle 10 g to Oracle 9i. Earlier, the same code used to work properly. And also on Oracle 10 g, this is not not the case every time. Sometimes, it gives error while sometimes it works.

    Does anyone know about any such bug in Oracle 10 g. Our cursor is a cursor parameterized accepting a VARCHAR2 parameter and the value that we have to it is also character.

    Our Oracle 10 g Enterprise Edition Release 10.2.0.3.0 - 64 bit Production database and runs on the UNIX server.

    And also on Oracle 10 g, this is not not the case every time. Sometimes, it gives error while sometimes it works.

    This is usually due to
    (a) environment settings that differ from one session to the next
    (b) or, more often, data

    The error means that Oracle expects a number and that it is unable to get an entry (data or SQL or bind variable) number provided. I agree with William that she looks a lot like implicit conversion TO_NUMBER() failure.

    Why not add a debugging code exception handler? When this exception occurs, the dump of the PL/SQL and call stack values of all variables and parameters of a table/record of debugging (using a standalone transaction).

Maybe you are looking for