Questions of the CASE expression.

I have a very simple as table below:


CREATE TABLE C_POST
(
POST_ID INTEGER NOT NULL,
CLOB POST_REPLY_SET
)

I have this line:

CASE post_reply_set IS NOT NULL THEN SELECT dbms_lob.substr (post_reply_set) ELSE 'NULL' END OF c_post;

Error: ORA-00923: KEYWORD not found where expected


then I have this line:

SELECT (CASE post_reply_set IS NOT NULL THEN dbms_lob.substr (post_reply_set) ELSE 'NULL' END) OF c_post;

Error: ORA-00907: lack the right parenthesis


Finally, I have this line:

SELECT CASE post_reply_set when IS NOT NULL THEN dbms_lob.substr (post_reply_set) ELSE 'NULL' END OF c_post;

Error: ORA-00936: lack of expression

Hello

You need the WHEN keyword.  It will immediately after the CASE keyword, like this:

SELECT THE CHECK BOX

WHEN post_reply_set IS NOT NULL

THEN dbms_lob.substr (post_reply_set)

ELSE 'NULL '.

END

OF c_post;

Lost or missing key words often lead to misleading error messages.

If you are testing just if a variable is NULL, you can use NVL2 instead of the CASE:

NVL2 SELECT (post_reply_set

dbms_lob.substr (post_reply_set)

, 'NULL '.

) AS col_alias

OF c_post;

Tags: Database

Similar Questions

  • BlackBerry Bold 9650 smartphone volume questions in the case

    I used my Bold 9650 in the Holster while I work in the gym and I was listening to Pandora. I noticed that the volume controls on the right side of the device will not work while the unit is in the Holster. If I get out of the Holster, the volume buttons work fine. Is it possible to allow these buttons while the case is used? I would have thought that they would work automatically by default. Thank you.

    I'm no expert on the cases, but I know that the magnet in the case puts your phone "sleep", turn off the screen.  This could also affect the side buttons.

    To make sure that this isn't just a problem with your phone, remove your battery when your phone is turned on, then replace it.  If the symptoms persist, it could be something with that you'll just have to live.

    I hope that helps you.

  • Question of the CASE statement

    Is it OK to mix conditions inside the case statement? as for example:

    SUM (CASE WHEN b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245', '5345', '87894') THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    ???

    I put in parentheses between the two conditions?

    SUM (CASE WHEN (b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245 ', '5345', ' 87894')) THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    is this legal syntax? because its not complaining do not, but I want to just make sure that these things are good to use and the data comes right back.

    Thank you!

    Kodiak_Seattle wrote:
    Is it OK to mix conditions inside the case statement? as for example:

    SUM (CASE WHEN b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245', '5345', '87894') THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    ???

    Yes, you can do that. The conditions must be related somehow.

    I put in parentheses between the two conditions?

    SUM (CASE WHEN (b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245 ', '5345', ' 87894')) THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    You have no need, but if it helps you (or one who has to maintain the code) to understand it better, then go ahead. The cost can be one millisecond extra when the query is compiled (it will run everything as fast so be it), and the benefits can be enormous.

    I find that formatting code contributes much more clarity to have additional parentheses. Why not use something like that?

    SUM ( CASE
              WHEN (    b.SUPPLIER_NUM     = 12345
                AND  c.VPN           IN ('3245', '5345', '87894')
                )
          THEN a.TRAN_AMT
          ELSE 0
          END
        )          AS SUMSPEND_MOS
    

    If you have really complicated conditions, where you mix ANDS and ORs, then you should certainly use parentheses. It goes the same for the WHERE clause.

    is this legal syntax? because its not complaining do not, but I want to just make sure that these things are good to use and the data comes right back.

    The syntax is fine.
    If the data comes in good or bad is another matter. What data are, and what you mean by 'comes back good' (in other words, what results do you get off these data)?

  • Select - the Question of the Case statement

    In my query:

    SELECT WR_ITEM_OID, TITLE,
    Title = WHEN 'No chocolate' THEN (select "#X #_G1_" ACE double groupname)
    When title = 'Chocolate' THEN (select "#X #_G2_" ACE double groupname)
    When title = 'Eraser' THEN (select "#X #_G3_" double groupname)
    When title = "Import complete" THEN (select "#X # 101_ _G' As double GroupName")
    When title = 'Export Total' THEN (select "#X # 102_ _G' As GroupName, the double")
    ANOTHER "END as GroupName
    OF WR_ITEM


    I want to change the title of "Export" when title = 'Export Total'

    How would I do that in this query?

    Thank you

    Hello

    Rich75 wrote:
    In my query:

    SELECT WR_ITEM_OID, TITLE,
    Title = WHEN 'No chocolate' THEN (select "#X #_G1_" ACE double groupname)
    When title = 'Chocolate' THEN (select "#X #_G2_" ACE double groupname)
    When title = 'Eraser' THEN (select "#X #_G3_" double groupname)
    When title = "Import complete" THEN (select "#X # 101_ _G' As double GroupName")
    When title = 'Export Total' THEN (select "#X # 102_ _G' As GroupName, the double")
    ANOTHER "END as GroupName
    OF WR_ITEM

    I want to change the title of "Export" when title = 'Export Total'

    How would I do that in this query?

    Thank you

    You can use another expression BOX to turn the title, usually to himself:

    SELECT  WR_ITEM_OID
    ,     CASE
              WHEN  title = 'Export Total'  THEN  'Export'
                                              ELSE  title
         END     AS title
    ,     CASE
              WHEN  title = 'Non Chocolate' THEN  '#X#_G1_'
              When  title = 'Chocolate'         THEN  '#X#_G2_'
              When  title = 'Gum'         THEN  '#X#_G3_'
              When  title = 'Import Total'  THEN  '#X#_G-101_'
              When  title = 'Export Total'  THEN  '#X#_G-102_'
                                                ELSE  NULL
          END      AS GroupName
    FROM       WR_ITEM
    

    There is no need for all scalar subqueries in double; I replaced the air conditioned and have literals.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.

  • I need to transfer my acrobat from adobe on a new computer.  Telephone customer service was able to help and directed me to post a question in the case where a person will get back to me.

    I am told that someone from Adobe technical support will respond to that.

    First of all, this isn't a technical support

    Chat support: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

    Cloud license allows 2 activations http://www.adobe.com/legal/licenses-terms.html

    -Install on a 2nd computer http://forums.adobe.com/thread/1452292?tstart=0

    -https://helpx.adobe.com/creative-cloud/help/sign-in-out-activate-apps.html

    -Windows or Mac has no importance... 2 on the same operating system or 1 on each

    -Two activations on one account CAN NOT be used at the same time (to be noted in the link above of the license)

  • Constants of output for the case of Structures

    Hello

    I have a pretty basic question about the case structures in labview. As indicated in the attachment below, using the structure case I've pretty much tried to create a three position switch. I'm trying out a value for the first (in the range and Coerce) and another value to the second. If [5-0] 0, [0 0] case for case 1 and case 2 [0, 5]. However when I try to connect all the way to the top, a broken line appears.

    How can I do this without error?

    Thank you

    Justin

    Something like this maybe? You need to change the task UP as well.

  • Problem with the case where the clause

    Hello

    I want to use cases in which clause. I wrote a very simple query to test how it works. However, I always got an error message. Here's what I did.

    Select eid, firstname, lastname from employee where eid = 1 works fine

    Select eid, name, name of the employee

    where

    cases where 1 = 1 then eid = 1

    When 1! = 1 then eid = 2

    end

    I ORA-00905: lack of keyword.

    Did I miss something?

    Thank you

    Jennifer

    Hi, Jennifer.

    Why do you want to use BOX in a WHERE clause?  The wonderful thing about the CASE is that it allows you to do IF-THEN-ELSE logic.  In a SELECT clause, or an ORDER BY clause, this is really useful, but the WHERE clause already allows you to use the IF-THEN-ELSE logic.

    However, if you use the BOX in a WHERE clause, it is as it does nowhere else.  Always BARGAIN instead of a single expression in a SQL data types.  All the clauses THEN (and ELSE, if there is one) must return a single expression, such as the NUMBER.  (There is no BOOLEAN data type in SQL).  So, you can use a CASE statement like this:

    ...

    CASES WHERE

    WHEN 1 = 1 THEN 1

    WHEN 1! = 1 THEN 2

    END = eid

    Here, the CASE expression takes the place of a NUMBER.

    However, if I was not sure if 1 = 1 or not, I would write the condition in this way, without a CASE expression:

    WHERE (1 = 1 AND eid = 1)

    OR (1! = 1 AND eid = 2).

  • TDE is not "transparent" to the CASE statement

    Hello

    I have installed oracle (10) database with TDE. It works very well with almost all queries. But I have problems when I try to use the CASE statement.


    He comes to the table, I created:

    {color: #0000ff} create table t_test)
    col1 varchar (128)); {color}

    This query returns an empty result (as planned, because there is still no data in the table).

    {color: #0000ff} to select)
    When col1 = 'test' then 'test '.
    end) as Carter
    of t_test
    {color}
    I now encrypt the column with the following statement:

    {color: #0000ff} change alter table t_test (col1 encrypt using "AES256" without salt); {color}

    And try again the same statement:

    {color: #0000ff} to select)
    When col1 = 'test' then 'test '.
    end) as Carter
    of t_test
    {color}
    He now returns {color: #ff0000} ORA-00932 inconsistent data types: expected BINARY got {color} CHAR

    But if I try:

    {color: #0000ff} select *.
    of t_test
    {color}
    There is no errors (returns empty result, as expected).

    I tried even with data, with the same result.

    Could someone please tell me what I'm doing wrong here?

    Thank you.

    You touch the Bug 6262107 'ORA-932 of the CASE expression sought with encrypted column:

    Description:
    "ORA-932 incompatible data types: expected BINARY got TANK ' is triggered.
    on a query with a case expression sought on a column with TDE.

    for example:
    CREATE TABLE TDE_TEST (COL1 VARCHAR2 (1));
    INSERT INTO TDE_TEST VALUES('1');
    ALTER TABLE TDE_TEST CHANGE (COL1 ENCRYPT WITHOUT SALT);
    SELECT CASE WHEN COL1 = '1', THEN 'A' OF ANOTHER END 'B' OF TDE_TEST;
    ^
    ORA-00932: inconsistent data types: expected BINARY got TANK

    Workaround solution:
    Convert a simple case of the searched case expression expression.

    So, I updated the sql works:
    SQL > select (case col1
    2 when 'test' then 'test '.
    3 end) as Carter
    4 * of t_test
    /
    no selected line

    I hope this helps.

  • A question I posted has been deleted without a valid response, another Admin sees the cases?

    A question I posted has been deleted without a valid response, another Admin sees the cases?

    I recently posted a valid, respectful and good question to the community and it has been deleted by an admin, the last answer about it was Tim kilt.

    Kind regards

    Your question was answered repeatedly in your double message. Repost the question will not change the answers.

  • the case-sensitivity of vCM compliance question

    I'm new to the vCM.  In fact, we had only the vCM installed for about three weeks now.  I worked on getting our environment vSphere guide 5.1-compatible hardening that I imported, but I seem to have encountered a problem.  On some virtual machine checks (i.e. disable-console-gui-options - explicitly disable copy and paste operations rule) I noticed came returned as nonconforming which I believe they shouldn't be so I went back and checked the logic of what the rule was looking for.  During the audit of the rule, everything seemed to be OK however the condition has been verified to some value to 'false' when in reality it is set to 'FALSE' on some virtual machines.  In my mind, this means it must be consistent, since it is the same value just a different case.  Does anyone know a way around this?  I tried the following.

    (1) change conditional to check the value = "false" or Value = "FALSE".

    (2) change conditional to check the value as 'false '.

    None of these worked.  Any help would be appreciated.

    Thank you!

    vSphere API data is case-sensitive. For example, you can have several virtual machines with the same name if the cases are different.

    In any case, for this rule, I think you want to change in value ('FALSE', 'false')

    If there is any other combination of case, you can add them to the list as well.

  • Question on the extension memory on the Satellite A80 117

    I have a question about the compatibility of memory.
    (The A8-117 is a Centrino 1.6 GHz (Pentuin M 730 processor) with Frontal 533 MHz bus and 2 MB of level 2, Intel® 915GM Express chipset)

    At the moment I have 1 chip of 512 MB (333 MHz, 2.5 CL) installed. I intend to switch to 1.5 or 2 GB. So what bothers me is: can I install a DDR2 533 MHz modules on this laptop (in this case the old 333 MHz one out)?
    Official website of Toshiba only 333 MHz DDR are provided, so that the 915GM express chipset allowes it.

    If it is not possible to 533, I guess I'll just buy 1 extra GB of 333 MHz DDR.

    Thanks in advance!
    Bostjan

    Hello

    At first, I want to say, which is always recommended to use RAM compatible and tested modules. On this way, you will be sure that it will work well and without any problems.

    According to the specifications of the laptop you can upgrade RAM to 2 GB max and compatible modules are: PC2700 512 MB (PA3312U - 2M 51) and 1024Mo PC2700 (PA3313U-2M1G).

    You can use faster RAM modules, but for me it is really not necessary. The specification of the laptop is the 333 MHz bus speed and faster modules will be not useful for laptop runs faster. It is best to buy 2 x PA3313U-2M1G and you will have no problem and portable will runs much more quickly than before.

  • Syntax of the case statement / WHEN

    The table I use a depreciation per fiscal year and the fiscal period.  I try to have the amount of depreciation to go to 2 different columns based on the fiscal year and the fiscal year.  I'm doing it with a nested case statement. I know that is not correct, because I get the message ORA-00905.  I'm relatively new to sql and it is contribtuing to my problem as well.  Here is the code I have and suggestions / corrections would be appreciated.  Thanks for the help...

    SELECT

    lao PDR. DEPTID as DEPTID,

    lao PDR. ASSET_ID as ASSET_NO,

    PA. Descr as DESCRIPTION,

    lao PDR. ACCOUNT_AD as AD_ACCT,

    PDL. DE_ACCT, to take into ACCOUNT

    lao PDR. ADEATH as AMT_DEPR,

    PDL. JOURNAL_ID as JRNL_ID,

    PDL. JOURNAL_DATE as JRNL_DT,

    lao PDR. FISCAL_YEAR as FY,

    lao PDR. ACCOUNTING_PERIOD AP,

    CASE

    WHEN RDP. FISCAL_YEAR = 2014 THEN

    WHEN RDP. PERIOD ACCOUNTANT = 11 THEN pdr. DEPR

    END AS CURR_MONTH,

    CASE

    WHEN RDP. FISCAL_YEAR <>2014

    WHEN RDP. ACCOUNTING PERIOD <>11 THEN pdr. DEPR

    END AS PRIOR_MONTH

    OF PS_DEPR_RPT pdr

    INNER JOIN PS_DIST_LN pdl

    THE pdl. BOOK = pdr. BOOK

    AND pdl. BUSINESS_UNIT = pdr. BUSINESS_UNIT

    AND pdl. FISCAL_YEAR = pdr. FISCAL_YEAR

    AND pdl. ACCOUNTING_PERIOD = pdr. ACCOUNTING_PERIOD

    AND pdl. ASSET_ID = pdr. ASSET_ID

    AND pdl. CF_SEQNO = pdr. CF_SEQNO

    INNER JOIN PS_ASSET PA

    WE pa. ASSET_ID = pdl. ASSET_ID

    AND pa. BUSINESS_UNIT = pdl. BUSINESS_UNIT

    WHERE

    lao PDR. BUSINESS_UNIT = "A0465.

    AND pdr. BOOK = 'RUN '.

    AND ((pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 11) OR (pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 10))

    Hello

    2713822 wrote:

    Thank you... I appreciate the information you provide when you answer these questions.  I always try to get the amount (from the same column) for 2 rows in different columns.  I tried the LAST_VALUE and LAG but it took a long time for the queries to run, I'm looking for another way to do the same.  I'm only using SQL to retrieve data.  I don't have the ability to create or insert.

    I looked the information above and the CASE statement to look like this:

    CASE

    WHEN RDP. FISCAL_YEAR = 2014

    AND pdr. ACCOUNTING_PERIOD = 11

    THEN the RDP. ADEATH AS CURR_MONTH

    ON THE OTHER

    lao PDR. ADEATH AS MONTHS PREVIOUS

    END

    But I'm now getting an "ORA-00905: lack of keyword" message.

    What I'm trying to do is to draw 2 lines 1 to 2014 / 11 and another for 2014 / 10.  The amount for the period 2014 / 11 should go in the current column and the amount for the period 2014 / 10 should go in the previous column.

    Before current assets management

    01 AB01 50.01 50.03

    ....

    If you want to give an alias for a column, then you can say "AS nome_alias" after that tell you what that is in this column.

    'AS nome_alias' applies to the entire column.  Cannot use 'alias_name' in the middle of an expression, for example, in the middle of a CASE expression, before the END keyword.

    If you want to have 2 separate output columns, curr_month and prior_month to your output, you must then 2 separate columns in your SELECT clause.  for example:

    SELECT pdr.branch

    pdr.asset

    CASE

    WHEN pdr.fiscal_year = 2014

    AND pdr.accounting_period = 11

    THEN pdr.depr

    END AS curr_month

    CASE

    WHEN...

    THEN...

    END AS prior_month

    PDR

    ;

    If post you some sample data (CREATE TABLE and INSERT statements), the results and explanations, I could show you how to complete the... sections.

    To find out what version of Oracle you have, use

    SELECT *.

    SINCE the release of v$.

    The output can be messy, like this:

    BANNER

    -------------------------------------------------------------------

    CON_ID

    ----------

    12 c Oracle database Release 12.1.0.1.0 - 64 bit Production

    0

    PL/SQL Release 12.1.0.1.0 - Production

    0

    CORE Production 12.1.0.1.0

    0

    AMT for 64-bit Windows: Version 12.1.0.1.0 - Production

    0

    NLSRTL Version 12.1.0.1.0 - Production

    0

    The important thing is the number 5 parts on the first line; 12.1.0.1.0 in the example above.

  • The AirPort Express Terminal is good enough for me?

    I need a new wireless router to replace my Netgear WNDR4300 'antiques '.  The network is only 2-3 laptops and iPhones 1-2 at a time, over a printer and Chromecast device.  We occasionally video stream, but not often.  Critics say the AirPort Express is best purchased as an add-on to an existing network, but I can't justify more expensive options from the airport.  I don't need the 11ac 802 that offer other options, and it seems that margin would be a problem, because it is limited to 5 GHz.  We have a two-storey house. Is the simple terminal AirPort Express good enough for my home network?

    The AirPort Express, pourraient deliver similar performance to your old Netgear router in terms of signal strength and the beach... but the only way to know with certainty if the Express will be good enough for your needs is to try in your home.

    Try to locate the Express up high on a shelf or Cabinet, if you can, to help in the dissemination of the signal.

    Fortunately, if you buy through Apple, you have one day 14, no questions asked return privilege, so if the Express does not provide the performance you need, you can return the unit for Exchange or a refund.

  • MacBook Air Mid 2011 Wifi only next to the Airport Express

    Hey everybody!

    These days I have trouble with one of my MacBook Air. I plug a new as my girlfriend needs a job.

    Anyway. I have updated to OS X El Capitan and struggle with the wifi. I made an appointment at the Genius Bar closest to you to solve the problems in the system.

    As I had to download the OS X on my Mac Pro, I had a problem with the wifi these permissions switch and system information. If you scroll to the installation, there should be a list of installed software. In my case nothing.

    After that the genius of Apple erased the disk and started the installation via ethernet with an Apple Server, I got a new version of OS X El Capitan on it. Everything appears fine (system information).

    The Wifi worked perfectly in the store.

    So, I got not any chance to try at home immediately. Today, I wanted to put the macbook for other facilities. I noticed that the wifi is extremely slow.

    I deleted the cache (which does not yet exist). I have reset the starting power setting. I have reset my Airport express from Apple. I changed the DNS to google DNS (8.8.8.8./8.8.4.4.). I too turned off bluetooth.

    All without any modification.

    BUT if I'm right in front of the apple express (literally sitting on the router), the wifi works without any problem.

    Please, I beg you! I have no idea what to do next. My other Mac Air and pro work perfectly. Any distance. (They have been disabled for testing). iPhone, iPad and Apple TV work fine.

    I seem to have this problem with my MacBook, a model of early 2015. What I was told is that the Wi - Fi antenna is nested in the compartment of the screen, located on the edge, practising thus pressure deforms it. Because the body is made of aluminum, the body involuntarily also acts as an antenna, interfere with the Wi - Fi signal. Here are the two plausible reasons why sometimes the signal is lost or slows down, and it made perfect sense to me.

    Maybe it's the issue here. If that's the case then I would attribute that to the misconception. I'm sure you can get it fixed, although I don't know how you would seeing that Apple seems to weld their new machines stop.

  • Connect a printer non-airprint for the Airport express

    Can I use an express train from the airport as a stand-alone wireless network to allow printing from an IOS device.  I want to connect an AirPrint not printer to the usb port on the Express with no ethernet cable is connected and so no internet and use it as a printer from an IPhone?

    My main questions are

    1. a no AirPrint printer allows printing from IOS using the Airport Express Terminal

    2. If so, the Airport express can not be connected to the internet?

    Thanks in advance.

    1. a no AirPrint printer allows printing from IOS using the Airport Express Terminal

    Actually, no. Connect a non-AirPrint printer to the USB port on the base station will NOT make it capable AirPrint. In order to print from a device iOS on this printer, you need to a third party (such as the Printopia) application running on a Mac.

    2. If so, the Airport express can not be connected to the internet?

    Function of the Express print server does not have Internet access at work. In other words, you can have the Express create a local wireless network, connect a USB printer and share the printer on the LAN. However, yet again, if the printer is capable non-AirPrint, iOS devices will not be able to print directly to it.

Maybe you are looking for