Prompts  in Case Statement

Hello Friends,
I am using Prompts in BI Publisher.
My Query in data model is as below and I get an error
SELECT
CASE WHEN "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Year" in (:P_Year) THEN SUM("- Nx_PA Budget Actuals
FROM "[Analytical] eDW_Projects"
where "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Month" < (:P_Month)
ERROR : java.io.IOException: prepare query failed[nQSError: 42032] Parameters are not supported in the select list.
But when I do
SELECT
CASE WHEN "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Year" in ('2010') THEN SUM("- Nx_PA Budget Actuals
FROM "[Analytical] eDW_Projects"
where
where "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Month" < (:P_Month)
it works fine.
Please help. Is there an option to sue prompts is Select/ Case Statement other than where statement.
Thanks
------

Thanks friend,
I am trying to do the foll: and want to calculate M2M and Y2M ,, For example if the Month in Prompt is MAY and Year is 2010 , then I am expecting
1) Budget Actuals from Jan till MAY 2010
2) Budget Actuals for MAY 2010
But My actual SQL is like
SELECT
CASE WHEN "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Year" in (:P_Year) THEN SUM("- Nx_PA Budget Actuals)
CASE WHEN "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Year" in (:P_Month) THEN SUM("- Nx_PA Budget Actuals)
SUM("- Nx_PA Budget Actuals)
FROM "[Analytical] eDW_Projects"
where "- Nx_Transaction Date Attributes (Nightly PA Budget Actuals Summary)"."Calendar Month" < (:P_Month)

Similar Messages

  • User input prompt in CASE statement

    I would like to obtain user input via a prompt and use what the user selects in my OBIEE Report case statement.
    For example &START_DATE AND &END_DATE are user inputs:
    CASE when SHIP_DATE BETWEEN &START_DATE AND &END_DATE THEN 1
    Thanks

    Use presentation variables for start and end_dates
    In the criteria tab->SHIP_DATE->click on fx
    on Edit Column Formula->Bin Tab->
    Add Bin->Add button->Variable->Presentation
    Use the presenation variables with with required condition
    Okay then set 1 at Edit Bin Name
    Mark if helps
    Srini VEERAVALLI on Feb 7, 2013 5:23 PM
    Any updates on this?
    Edited by: Srini VEERAVALLI on Feb 20, 2013 4:10 PM

  • Pushing case statement applied in answers formula to Database

    Hi All,
    There are three prompts, for which there is a kind of header report with narrative view, now when user selects value in prompt element1 and do not select anything in prompt element 2 and 3, in the header only element1 should be displayed and emlement2,3 and few other elements should be nullified, to do this, i used presentation variables for element2,3 directly in narrative view. but for other non-prompt elements not to show up, i used case statement like:
    case when length(@{presntation_var}) > 0 then "display.column" else NULL end
    Now OBIEE is executing in such a way that, it is retrieving all the columns from the database and then applying logical case statement at BI server level, I need to push this case statement to DB level, can anyone help me how this could be accomplished.
    Thanks,
    Sreekanth Jala

    Hi
    why cant u use the condition in RPD.
    In rpd use the case condition and make that as a one logical column. Test=" Fact"."Service Revenue" / "Fact"."Hours Budget". make it as a logical sum.
    Then bring this column in to answerside, and use the case condition
    case when
    "Fact"."Location" <> 'X'
    then
    (" Fact""Test")
    else 
    "Fact"."Hourly Rate"
    end
    Regards,
    VG

  • Question in Case Statement....

    Hi Gurus, I have a case statement as below: Here I have to get the Initials of person only where desc = underwriter. ( P.S sometimes there are multiple underwriter, thats why i put the min() around a character.)
    Initials =
    min(case when ( table1.DESC ) = 'UNDERWRITER' then table2.INITIALS when ( table1.DESC ) ='ASSIGN' then table2.INITIALS end )
    Please see data below:
    Underwriter Initials : SE
    -------------------------------XY
    Assign Initials : NR
    ----------------------------PQ
    Through my SQL I intend to get SE for Underwriter. But my SQL returns NR as it it is the minimum in the order. Any ideas please...........
    P.S: The Initials column is actually displayed in one of my reports; and the Initials column is dynamic; meaning ....i am prompting the User to select DESC values: Underwriter or Assign
    and based on that the prompt; the Initials Column should display either Underwriter Initials or Assign Initials.
    Thanks a lot.

    Hi Frank, thanks a lot for your reply. I am a lot closer to solving it now. A little more help please.
    The expected output is like below:
    1) Initials 2) Desc
    SE-------------- Underwriter
    NR---------------Assign
    Yes , i understand the whole purpose of case is to give different scnarios but in this case i have tried using something like:
    case when CR_ROLE_TYPE_DESC_REF.ROLE_TYP_DESC = :p_role_typ_desc then CR_PARTY_DIM.PARTY_NAME_INITIALS end
    but it gives me the wrong values. which i think is due to the Decode statement below:
    Please see the modified SQL:
    Here the user chooses prompts (DESC: Underwriter) and also pick a person name which has a decode for ASSIGN in it
    SELECT
    CR_ACCOUNT_DIM.ACCOUNT_NM,
    min(case when ( CR_ROLE_TYPE_DESC_REF.ROLE_TYP_DESC ) = 'UNDERWRITER' then CR_PARTY_DIM.PARTY_NAME_INITIALS when ( CR_ROLE_TYPE_DESC_REF.ROLE_TYP_DESC ) ='ASSIGN' then CR_PARTY_DIM.PARTY_NAME_INITIALS end)
    FROM
    CR_ACCOUNT_DIM,
    CR_CNSMR_RQST_PARTY_ROLE_RLSHP,
    CR_PARTY_DIM,
    CR_CONSUMER_RQST_DIM,
    CR_BUSINESS_SGMNT_REF,
    CR_CONSUMER_RQST_FACT
    WHERE
    ( CR_CONSUMER_RQST_FACT.CNSMR_RQST_DIM_PK_ID=CR_CONSUMER_RQST_DIM.CNSMR_RQST_DIM_PK_ID )
    AND ( CR_PARTY_DIM.PARTY_DIM_PK_ID= CR_CNSMR_RQST_PARTY_ROLE_RLSHP.PARTY_DIM_PK_ID )
    and
    decode(CR_CNSMR_RQST_PARTY_ROLE_RLSHP.ROLE_TYP_DESC,'ASSIGN',CR_PARTY_DIM.FIRST_NM || ' ' || CR_PARTY_DIM.MIDDLE_INTL || ' ' || CR_PARTY_DIM.LAST_NM ) = 'ROBERTO NIEL'
    Any ideas please....

  • Issue with referencing Presentation variables(Date cols) in Case statement

    Hi,
    I m trying to reference presentation variables created on a Date column in the case statement of one of the request's columns as shown below:
    case when "- Quote Details"."Creation Date" between '@{from}{1999-1-1}' and '@{until}{2999-1-1}' then "- Quote Metrics"."# of Quotes" end
    I m getting a view display error with the below error message:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 17001] Oracle Error code: 1861, message: ORA-01861: literal does not match format string at OCI call OCIStmtExecute
    SQL Issued: SELECT "- Quote Types"."Level2 Name" saw_0, case when "- Quote Details"."Creation Date" between '4/1/2009' and '4/15/2009' then "- Quote Metrics"."# of Quotes" end saw_1 FROM "(Unity) Quotes Catalog" WHERE "- Quote Details"."Creation Date" BETWEEN timestamp '2009-04-01 00:00:00' AND timestamp '2009-04-15 00:00:00' ORDER BY saw_0
    When I created the prompt on the date field I put the following formula in the prompt:
    cast("- Time".Day as DATE)
    When I apply a filter on the request using these variables it works fine.
    If anyone has faced this kind of issue earlier and have a resolution, please help me out.
    Thanks,
    Kartik

    Thanks Goran!!
    I've created prompts by selecting columns from the logical tables (i.e. I've selected 2 different cols of datatype DATE...inorder to assign 2 presentation variables).
    Yes I m using calendar widget for prompts.
    I haven't included any filter in my report. I m trying to display a metric when it satisfies the case statement.
    I will defintley go through the blogs you mentioned for better understanding.
    Thanks,
    Kartik
    Query fired on physical db:
    WITH
    SAWITH0 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5
    from
    (select T192898.QLS_FIRST_ACAP_DT as c1,
    TO_DATE('3/2/2009','mm/dd/yyyy') as c2,
    TO_DATE('4/29/2009','mm/dd/yyyy') as c3,
    T188666.LEVEL2_NAME as c4,
    T188666.ID as c5,
    ROW_NUMBER() OVER (PARTITION BY T188666.ID, T192898.QLS_FIRST_ACAP_DT ORDER BY T188666.ID ASC, T192898.QLS_FIRST_ACAP_DT ASC) as c6
    from
    XXSLS_GBL_QTE_TYPES_V T188666,
    XXSLS_GBL_QTE_DTL_F T192898
    where ( T188666.ID = T192898.QUOTE_TYPE_ID )
    ) D1
    where ( D1.c6 = 1 ) ),
    SAWITH1 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3
    from
    (select count(distinct T192898.QUOTE_HEADER_ID) as c1,
    T188666.LEVEL2_NAME as c2,
    T188666.ID as c3,
    ROW_NUMBER() OVER (PARTITION BY T188666.ID ORDER BY T188666.ID ASC) as c4
    from
    XXSLS_GBL_QTE_TYPES_V T188666,
    XXSLS_GBL_QTE_DTL_F T192898
    where ( T188666.ID = T192898.QUOTE_TYPE_ID )
    group by T188666.ID, T188666.LEVEL2_NAME
    ) D1
    where ( D1.c4 = 1 ) ),
    SAWITH2 AS (select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3
    from
    (select case when SAWITH1.c2 is not null then SAWITH1.c2 when SAWITH0.c4 is not null then SAWITH0.c4 end as c1,
    case when SAWITH0.c1 between SAWITH0.c2 and SAWITH0.c3 then SAWITH1.c1 else NULL end as c2,
    case when SAWITH0.c5 is not null then SAWITH0.c5 when SAWITH1.c3 is not null then SAWITH1.c3 end as c3,
    ROW_NUMBER() OVER (PARTITION BY case when SAWITH0.c5 is not null then SAWITH0.c5 when SAWITH1.c3 is not null then SAWITH1.c3 end , case when SAWITH1.c2 is not null then SAWITH1.c2 when SAWITH0.c4 is not null then SAWITH0.c4 end ORDER BY case when SAWITH0.c5 is not null then SAWITH0.c5 when SAWITH1.c3 is not null then SAWITH1.c3 end ASC, case when SAWITH1.c2 is not null then SAWITH1.c2 when SAWITH0.c4 is not null then SAWITH0.c4 end ASC) as c4
    from
    SAWITH0 full outer join SAWITH1 On SAWITH0.c5 = SAWITH1.c3
    ) D1
    where ( D1.c4 = 1 ) )
    select SAWITH2.c1 as c1,
    SAWITH2.c2 as c2
    from
    SAWITH2
    order by c1

  • SQL script into a CASE statement ?

    Hy,
    can someone tell me, please, if is it possible insert into a case statement (shell unix script) one or more SQL script ?
    For example :
    case aaa in
    1 )
    sqlplus blabla <<!
    update ...
    insert ...
    2 )
    esac
    Thank you very much !
    Andys

    /unix/sqlplus -s username/pwd @file_name.sql
    This will work on unix prompt. use this in shell script and implement. file_name.sql containts update logic.
    I hope it will solve ur problem.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Andys:
    Hy,
    can someone tell me, please, if is it possible insert into a case statement (shell unix script) one or more SQL script ?
    For example :
    case aaa in
    1 )
    sqlplus blabla <<!
    update ...
    insert ...
    2 )
    esac
    Thank you very much !
    Andys<HR></BLOCKQUOTE>
    null

  • Using Presentation variables..along with case statements..

    Hi All.
    I have a issue using presentation variable along with CASE statements. My approach is
    1) I have a dashboard prompt, which is being set as Presentation variable.
    Based on the value selected in prompt, for ex the values of prompt can be 'ABC' and 'DEF'.
    I have a calculated column, the calculation goes this way...
    The forumal is
    CASE WHEN @{Presentation Variable Name} = 'ABC' THEN xxxxxxxxxx ELSE IF @{Presentation Variable Name} = 'DEF' END. It gives error of "no table being referenced"..
    Is this is the right approach??
    Can i get the values of variable in a column formula, so that a column can have values selected in prompt?
    Can anybody pls help me here..
    Thanks in advance...

    Hi
    Thanks for the quick response..
    I agree to ur point..
    But the requirement is
    Based on the value of the prompt I need to switch the calculation in one of the formula area of one column..
    If Prompt value is ABC then one kind of calculation in Fx and If the prompt value is DEF then one kind of calculation in the same Fx..
    How can I acheive this?
    Thanks in advance..

  • Case Statement and Sequential Count

    I would like to obtain user input via a prompt and use what the user selects in my OBIEE Report case statement. I ve done the parameter part with a presentation variable.
    and a filter with the following.
    Recv Date is between @{Repair_Start_Date}{01-01-2013} and @{Repair_End_Date}{01-01-2013}
    Now I would like to have a sequential count of the records that meet the case statement, please advise.
    For example &START_DATE AND &END_DATE are user inputs:
    CASE when SHIP_DATE BETWEEN &START_DATE AND &END_DATE THEN 1
    Thanks

    Hi,
    Here is a way you could try.
    CASE when SHIP_DATE BETWEEN &START_DATE AND &END_DATE THEN RSUM(1) END
    So, what it does?
    Whenever the CASE statement is satisfied, it increments 1 by 1.
    Hope this helps.
    Thank you,
    Dhar

  • Need help to write case statement

    Hi Guys,
    I have dashboard in which its has pprompt called PROPMT1 in that prompt it has three values A,B,C
    but iwant the full abbreviation of those values like A=APPLE B=BOY and C=Cindy
    and also in the report i have the coloumn is prompted by PROMPT1 which has again A,B,C values that need to be modified as A=APPLE B=BOY and C=Cindy
    how can i do it with case statement.

    For the prompt, write this in the Show window>SQL Results:
    1) CASE WHEN 1=0 THEN char_columnname ELSE 'A = APPLE' END FROM "your subject area" UNION ALL CASE WHEN 1=0 THEN char_columnname ELSE 'B = BOY' END FROM "your subject area" UNION ALL CASE WHEN 1=0 THEN char_columnname ELSE 'C = Cindy' END FROM "your subject area"
    2) Save the prompt to a presentation variable, pv_choice
    This will give you your three values. Make sure you use a CHAR column, doesnt matter what column, though.
    For the report,
    1) Create a BINS column on the column that contains the A, B, C values and make the BINS A = APPLE, B = BOY, C = Cindy just like the prompt values.
    2) Now put a filter on this BINS column and set it equal to your pv_choice presentation variable.
    That's it.
    NOTE: Obviously, if you want the prompt values to just say "APPLE," "BOY," and "Cindy," then take off the 'A = ', 'B = ' and 'C = ' appropriately. Same for the BINS in your report.
    Edited by: David_T on Jun 8, 2011 10:57 AM

  • SQL Expression in decode function or case statement?

    Can I put SQL expressions in decode function or case statement?
    For example,
    select le.profile, decode( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile, 0, 'N', 'Y')
    from element le;
    or
    select le.profile, case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0 THEN 'N'
    ELSE 'Y'
    from element le;
    None of the above work.
    Can anyone tell me how to make it work?
    Is there any workaround?
    Thanks,
    J

    You simply needed and END to your CASE statement;
    SQL> with profile_data as (
       select 'XXXX_AFTER' name, 1 object_id from dual),
         element as (
       select 1 profile from dual union all
       select 2 from dual)
    select le.profile,
       case WHEN ( select count(1) from profile_data where NAME= 'XXXX_AFTER' and object_id = le.profile) = 0
       THEN 'N'
       ELSE 'Y'
       END new_col
    from element le
       PROFILE N
             1 Y
             2 N

  • CASE not found while executing CASE statement on Submit Form

    Hi to all APEX users and developers.
    I have several APEX applications and they are all working well, but recently I got one strange exception when I try to submit page:
    Session: Fetch session header information
    ...metadata, fetch page info
    ...Validate item page affinity.
    ...Validate hidden_protected items.
    Add error onto error stack
    ...Error data:
    ......message: Error processing request.
    ......additional_info: ORA-06592: CASE not found while executing CASE statement
    ......display_location: ON_ERROR_PAGE
    ......is_internal_error: true
    ......apex_error_code: APEX.UNHANDLED_ERROR
    ......ora_sqlcode: -6592
    ......ora_sqlerrm: ORA-06592: CASE not found while executing CASE statement
    .....error_backtrace: ORA-06512: at "APEX_040100.WWV_FLOW", line 9273
    ......component.type: APEX_APPLICATION_AUTH
    ......component.id: 41350431648668800
    ......component.name: MNRFR
    ...Show Error on Error Page
    ......Performing rollback
    Processes - point: AFTER_ERROR_HEADER
    Processes - point: BEFORE_ERROR_FOOTER
    End Page Processinga
    Page has more than 120 items (most of them are hidden), so my first thought is that page has problem with posting so many items, but APEX error message doesn't hel me at all. Any help would be very appreciated :)
    Almir

    Hi Almir,
    actually it is the 100 page item limit. See (http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/limits.htm)
    I also had a look into the source code and the code at the position where the error gets raised only supports 100 page items.
    Can you have a look into the generated HTML code and look if you have a page items which is mapped to p_t101 or a higher number ?
    I will file a bug to show a better error message.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Case statement

    hi.
    i have a case statement query. i wonder if in the select statement, can i do computation using different parameter from the main report to subreport?
    for example, (qty * parameter)
    if parameter = 0, i uses $P{abc} to multiply qty
    if parameter > 0, i uses $P{xyz} to multiply qty
    in this case, i've writen a sql (as below) but its does not execute.
    select ....., (QTY *
    case $P{QTY}
    when 0 then ' * $P{abc}'
    else ' $P{xyz}'
    end
    from....
    hence, what should i do in order to get the right parameter to multiply with? pls guide. thanks.

    I'm not sure about these parameter placeholders which are specific to whatever report tool you are using, but the structure would be (assuming the parameter value would never be less than zero):
    qty * case when $P{QTY} = 0 then $P{abc} else $P{xyz} end

  • Case Statement in Answers Filter

    Hi,
    I'm trying to build a query in Answers that filters the data returned based on the current month number. If the current month is 1 then we want to show all 12 months, otherwise we want to show months less than the current month. If I use the following:
    CASE WHEN extract(month from current_date) = 1 THEN "Calculated Values Monthly"."MONTH" >= 1 ELSE "Calculated Values Monthly"."MONTH" < extract (month from current_date) END
    I get the error below. All works fine until I add the CASE.
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Location: saw.views.evc.activate, saw.httpserver.processrequest, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool, saw.threadpool, saw.threads
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near <>=>: Syntax error [nQSError: 26012] . (HY000)
    Can you use a case statement in a filter? If not, what are the other options, if any?
    Thx

    ziekc wrote:
    Hi,
    I'm trying to build a query in Answers that filters the data returned based on the current month number. If the current month is 1 then we want to show all 12 months, otherwise we want to show months less than the current month. If I use the following:
    CASE WHEN extract(month from current_date) = 1 THEN "Calculated Values Monthly"."MONTH" >= 1 ELSE "Calculated Values Monthly"."MONTH" < extract (month from current_date) END
    I get the error below. All works fine until I add the CASE.
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Location: saw.views.evc.activate, saw.httpserver.processrequest, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool, saw.threadpool, saw.threads
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near <>=>: Syntax error [nQSError: 26012] . (HY000)
    Can you use a case statement in a filter? If not, what are the other options, if any?
    ThxAccording to your requirements, when the month is January, you want all 12 months; any other number and you want months from 1 to "1 less than the current month number." Yes? Okay, here's what to do:
    In the filter on your date column, click on the filter button, convert it to SQL and enter this:
    MONTH(tablename.date_column) BETWEEN 1 AND CASE WHEN MONTH(CURRENT_DATE) = 1 THEN 12 ELSE MONTH(CURRENT_DATE)-1 END
    Here's the logic:
    a) When the current month is January, then the case statement will yield 12 and the filter will be:
    WHERE MONTH(tablename.date_column) BETWEEN 1 AND 12 ...or all 12 months.
    b) When the current month is any other month, say June, then the case statement will yield one less than the what the month number is, or in this case 5.
    WHERE MONTH(tablename.date_column BETWEEN 1 AND 5 ...or all the months from 1 to 5 (Jan through May)
    This will give you what you want...

  • CASE statement in Calculated column

    Hi Frzz,
    I have below requirement in Calculated column with CASE statement. Could some one help me how to achieve this with case statement.
    String  =   0Hello
                    01Hello
                    012Hello
                    0123Hello
    If  1st Character of the string is '0' then  -  0Hello
        1st 2 characters of the String is '01'  -   22Hello
        1st 3 characters of the String is '01'  -   333Hello
        1st 4 characters of the String is '01'  -  4444Hello
    Thank you.
    Best Regards,
    Krishna.

    Hi Krishna ,
    Using IF and MATCH to do that: ( I took one of the conditions you specified )
    IF(match("STRING1",'??0??'),'333Hello',"STRING1")
    Output:
    Regards,
    Krishna Tangudu

  • CASE statement in PL/SQL

    Hi PL/SQL experts,
    I'm going a bit loopy here, so could someone please point out what I'm doing wrong with this case statement:
    Test procedure is:
    CREATE OR REPLACE procedure SCOTT.postcode_validate_2 (input_post_code VARCHAR2) as
    alphabet_string VARCHAR2(52) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxwyz';
    number_string VARCHAR2(10) := '012345789';
    last_part_postcode VARCHAR2(3) := NULL;
    BEGIN
    IF INSTR(input_post_code,' ') = 0
    THEN
    DBMS_OUTPUT.PUT_LINE('We need a space in the postcode please');
    GOTO exit;
    ELSIF LENGTH(SUBSTR(input_post_code,instr(input_post_code,' ')+1)) > 3
    THEN
    DBMS_OUTPUT.PUT_LINE('Last part of postcode can only be 3 characters');
    GOTO exit;
    ELSE
    last_part_postcode := SUBSTR(input_post_code,instr(input_post_code,' ')+1);
    END IF;
    CASE input_post_code
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 2
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(number_string,substr(input_post_code,2,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format A9')
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format A9');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 3
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format AA9')
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format AA9');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 3
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(number_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format A99')
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format A99');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 3
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(number_string,substr(input_post_code,2,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format A9A')
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format A9A');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 4
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0
    AND instr(number_string,substr(input_post_code,4,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format AA99')
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format AA99');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 4
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,4,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format AA9A')
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format AA9A');
    -- GOTO exit;
    -- END IF;
    END;
    -- Check last part of format, should be AA9
    IF (instr(number_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('End part of the postcode is in the correct format, 9AA');
    ELSE
    DBMS_OUTPUT.PUT_LINE('End part of the postcode is in the wrong format!');
    END IF;
    <<exit>>
    DBMS_OUTPUT.PUT_LINE('Please try again');
    END;
    However, I'm getting the following error:
    LINE/COL ERROR
    37/6 PLS-00103: Encountered the symbol "WHEN" when expecting one of
    the following:
    := . ( % ;
    On a second note, can I not have the ELSE structure embedded within the case (currently commented out)?
    Thanks very much in advance.
    Dev

    Fixed code:
    CREATE OR REPLACE procedure postcode_validate_2 (input_post_code VARCHAR2) as
    alphabet_string VARCHAR2(52) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxwyz';
    number_string VARCHAR2(10) := '012345789';
    last_part_postcode VARCHAR2(3) := NULL;
    BEGIN
    IF INSTR(input_post_code,' ') = 0
    THEN
    DBMS_OUTPUT.PUT_LINE('We need a space in the postcode please');
    GOTO exit;
    ELSIF LENGTH(SUBSTR(input_post_code,instr(input_post_code,' ')+1)) > 3
    THEN
    DBMS_OUTPUT.PUT_LINE('Last part of postcode can only be 3 characters');
    GOTO exit;
    ELSE
    last_part_postcode := SUBSTR(input_post_code,instr(input_post_code,' ')+1);
    END IF;
    CASE
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 2
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(number_string,substr(input_post_code,2,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format A9');
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format A9');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 3
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format AA9');
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format AA9');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 3
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(number_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format A99');
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format A99');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 3
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(number_string,substr(input_post_code,2,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format A9A');
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format A9A');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 4
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0
    AND instr(number_string,substr(input_post_code,4,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format AA99');
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format AA99');
    -- GOTO exit;
    -- END IF;
    WHEN (length(substr(input_post_code,1,instr(input_post_code,' ')-1)) = 4
    AND instr(alphabet_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(number_string,substr(input_post_code,3,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,4,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('We have a valid postcode in the format AA9A');
    -- ELSE
    -- DBMS_OUTPUT.PUT_LINE('Sorry but that is an incorrect postcode! Format AA9A');
    -- GOTO exit;
    -- END IF;
    END CASE;
    -- Check last part of format, should be AA9
    IF (instr(number_string,substr(input_post_code,1,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,2,1)) != 0
    AND instr(alphabet_string,substr(input_post_code,3,1)) != 0)
    THEN
    DBMS_OUTPUT.PUT_LINE('End part of the postcode is in the correct format, 9AA');
    ELSE
    DBMS_OUTPUT.PUT_LINE('End part of the postcode is in the wrong format!');
    END IF;
    <<exit>>
    DBMS_OUTPUT.PUT_LINE('Please try again');
    END;
    /As VG2 pointed out you were missing some semicolons.
    Also, CASE input_post_code was replaced with just CASE since you are doing a searched case.
    Also, END at the end of the case statement was replaced with END CASE.

Maybe you are looking for

  • After upgrading to Mavericks Compressor 4 crashes in FCPX

    After upgrading to Mavericks, Compressor 4 crashes in FCPCX, I can't share projects

  • How to make table in java application?

    I am using visual cafe tool for creating the GUI interface, but i don't konw how to construct a table for my game. thank u

  • Jar files are not read from HDD

    Hi, we are facing a problem while trying to read jar files from Hard disk using CVM. we could able to read the file and the number of bytes read exactely matches with the file size. but while trying to use JNI (*env)->FindClass it is returns 0. Some

  • A strange problem in smart form?

    Hi,    I met a strange problem in my smart form. When I click "Check" button in each window of each page, system said "Window (my window name) does not fit onto page(height)". Even I create a new page and a new window in it, it still said this error

  • Hr tag change colour

    hello I am trying to change my horizontal line to orange. i created a CSS tag style (hr) witth the type colour FF6600 (orange), in dreamweaver it works but previewing in safari and firefox the line remaims grey. i am going about this the wrong way? a