case statement and the problem posed by the...

Hello..

Here is the code I use in my pl/sql anonymous block:
DECLARE

 X555 NUMBER;

 P1_X2 varchar2(10) := to_char(sysdate, 'dd.mm.yyyy');
 
BEGIN

case 

when 
P1_X2 = to_char('sunday') 
then
SELECT COUNT(*) into X555 FROM biwh.ORGANIZ Tbl 
 WHERE SAM_FORMA IN ('16') and IDEN_N_TAR in to_date(/*:*/P1_X2, 'dd.mm.yyyy')-3;

else

SELECT COUNT(*) into X555 FROM biwh.ORGANIZ Tbl 
 WHERE SAM_FORMA IN ('16') and IDEN_N_TAR in to_date(/*:*/P1_X2, 'dd.mm.yyyy')-1;
end case;

dbms_output.put_line(X555);

end; 
I want to do something like this:
If it's Sunday, leave this part of the labour code:
SELECT COUNT(*) into X555 FROM biwh.ORGANIZ Tbl 
 WHERE SAM_FORMA IN ('16') and IDEN_N_TAR in to_date(/*:*/P1_X2, 'dd.mm.yyyy') -3; 
can you tell me the correct syntax of the code? where did I did mystake?

SRY for my English...
 P1_X2 varchar2(10) := to_char(sysdate, 'dd.mm.yyyy');

BEGIN

case 

when
P1_X2 = to_char('sunday') 

In the light of the foregoing, you set P1_X2 to a string value that resembles '05.10.2009' and then try to compare it to a string that looks like "Sunday".

I'd be tempted to define P1_X2 as a DATE, then check against that for example

  p1_x2 DATE := trunc(SYSDATE);

BEGIN

 CASE TO_CHAR(p1_x2,'fmday')
    WHEN 'sunday' THEN
      SELECT COUNT(*)
      INTO   x555
      FROM   biwh.organiz tbl
      WHERE  sam_forma IN ('16')
      AND    iden_n_tar = p1_x2 - 3;

    ELSE

      SELECT COUNT(*)
      INTO   x555
      FROM   biwh.organiz tbl
      WHERE  sam_forma IN ('16')
      AND    iden_n_tar = p1_x2 - 1;
  END CASE;

The above assumes that you store iden_n_tar as a 'date at midnight '.

You could go further and have a single query that moves from the "cause" of the where clause:

      SELECT COUNT(*)
      INTO   x555
      FROM   biwh.organiz tbl
      WHERE  sam_forma IN ('16')
      AND    iden_n_tar = p1_x2 - CASE TO_CHAR(p1_x2,'fmday')
                                                  WHEN 'sunday' THEN 1
                                                  ELSE 3
                                               END;

Tags: Database

Similar Questions

  • ESXi host goes to the State and the virtual machine does not restart on other host does not

    Hi all

    I'm looking for a solution, in which case the host goes to the State and the virtual machine on it does not restart on a different host (they'll just gray) does not not what could be the problem here and how to fix it

    later when the failed host returns upward machines either go to motor off the coast of the State, or they show that under tension

    While the host is down or not responding do not I am able to ping the host ESXi (5.5) and able to ping the default gateway and the DNS servers of the host itself

    Yes AF, the answer to all these questions is Yes, it is a HA and DRS cluster active, I tried restarting mgmt service, we use a shared storage (storage iSCSI HP 3PAR and left hand)

  • Tuning - using the CASE statement in the WHERE clause of the query

    Hi all

    My request has been changed to use a CASE statement in the WHERE clause to examine the data to some columns based on a parameter value. This modified request is made a full table and constantly running scan. Please suggest what can be done to improve its performance:

    Query:
    SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date,
    os.acctnum,
    os.avieworigin_refid,
    COUNT(1) cnt_articleview,
    SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm
    FROM TABLE1 os
    WHERE os.acctnum IS NOT NULL
    AND os.avieworigin_refid IS NOT NULL
    AND os.requestdatetime IS NOT NULL
    AND UPPER(os.success_ind) = 'S'
    
    AND CASE WHEN
    Param_ValueToCheck  = 'FULL' AND get_date_timestamp(os.requestdatetime)  BETWEEN 
    TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    WHEN
    Param_ValueToCheck  = 'INCR' AND os.entry_createddate  BETWEEN 
    TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    END = 1
    AND CASE WHEN
    Param_ValueToCheck  = 'FULL' AND os.entry_CreatedDate BETWEEN 
    TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND
    TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS')
    THEN 1
    WHEN
    Param_ValueToCheck  = 'INCR' THEN 1
    END = 1
    GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;
    Description of the table:
    (Number of lines: approx. > amount 600 000 000)
    Name                           Null     Type       
    ------------------------------ -------- ------------
    ARTICLEID                      NOT NULL NUMBER(20) 
    USERKEY                                 NUMBER(10) 
    AVIEWORIGIN_REFID                       VARCHAR2(10)
    SUCCESS_IND                             VARCHAR2(2)
    ENTRY_CREATEDDATE                       DATE       
    CREATED_BY                              VARCHAR2(10)
    FILENUMBER                              NUMBER(10) 
    LINENUMBER                              NUMBER(10) 
    ACCTNUM                                 VARCHAR2(10)
    AUTOCOMPLETEDTERM                       NUMBER(2)  
    REQUESTDATETIME                         VARCHAR2(19)
    Explain Plan
    SQL> select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 2224314832
    
    ----------------------------------------------------------------------------------------------------------
    | Id  | Operation            | Name              | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    ----------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT     |                   |   590 | 33040 |  2501K  (1)| 08:20:15 |       |       |
    |   1 |  HASH GROUP BY       |                   |   590 | 33040 |  2501K  (1)| 08:20:15 |       |       |
    |   2 |   PARTITION RANGE ALL|                   |   590 | 33040 |  2501K  (1)| 08:20:15 |     1 |1048575|
    |*  3 |    TABLE ACCESS FULL | TABLE1 |   590 | 33040 |  2501K  (1)| 08:20:15 |     1 |1048575|
    ----------------------------------------------------------------------------------------------------------
    
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE  WHEN ('FULL'='FULL' AND
                  "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
                  "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN
                  'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE  WHEN ('FULL'='FULL'
                  AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd
                  hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00',
                  'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE('
                  2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE('
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                  2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND
                  "OS"."AVIEWORIGIN_REFID" IS NOT NULL)
    Published by: Chaitanya on June 9, 2011 02:44

    Published by: Chaitanya on June 9, 2011 02:47

    When it is executed individually, MERGE LOGIC 1 and LOGIC of MERGE 2 take about ten for a daterange of 30 days data.

    BUT FULL is to get the scores of APR - JUN, INCR becomes partitions for MAY so not both 30 days.
    Are compare us like with like?

  • Select with case statement and a formula of the IIR

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when 'date' < = "date2" then '1' other '0' as end ending

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf ([date] > = [date1], 1, 0)

    [/ code]

    [code]

    ending: IIf ([date] < = [date2], 1, 0)

    [/ code]

    Any advice would be appreciated.

    Hello

    Whenever you have any questions, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.

    If the output depends on what anyone outside the application itself (for example, when it is run) and then include a few different examples and the results you want of each given the same sample data. For example, "if I run on November 19, 2013, while the results should be... because... but if I run between November 21 and November 27, then the results should be... because...". »
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    318f20b8-a3d0-4FB4-bb0f-73785250b7d4 wrote:

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when "date."<= 'date2'="" then="" '1'="" else="" '0'="" end="" as="">

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf([date]>=[date1],1,0)

    [/ code]

    [code]

    ending: IIf ([date]<>

    [/ code]

    Any advice would be appreciated.

    DATE is not a function of Oracle; in fact, it's a terrible name for a column or function, because it blends with the DATE data type.

    In Oracle, the function SYSDATE returns the date and time, according to the clock on the database server.  So, SYSDATE can return a value as November 19, 2013 06:33:15.   If you want to midnight the same day (i.e., November 19, 2013 00:00:00) and then use TRUNC (SYSDATE).

    String literals (for example the string which consists 5 characters d, a, t, e, and 1) go inside the single quotes. Numbers and the names of columns only.

    If you want to include all the columns, more some calculated values, in a SELECT clause, then you must use a name table or alias before the *.  (See select_2 below.  To do this, assign the alias j to display online.)

    Maybe you wanted to say something like:

    Select *-it's select_1

    de)

    Select j. *-it's select_2

    , case when SYSDATE > = date1 then 1 or 0 end as departure

    , case when SYSDATE<= date2="" then="" 1="" else="" 0="" end="" as="">

    de)

    Select *-it's select_3

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    ) j

    )

    ;

    As mentioned in a previous answer, you should be careful about the use of "SELECT *" in production code.

    In select_3, it would be better if you explicitly listed the columns you need.  It can improve efficiency and maintenance.  In this request, queue and the name will be always the same, so you probably don't want to include both of them in the result set, in any case.

    In select_1 and select_2, it is acceptable to use "SELECT *", assuming that select_3 is fixed.

    Moreover, there is no point in using subqueries here.  You can get the same results simply in a single query, without any subqueries.

  • case statement in the dynamics

    I have the following statement in the procedure.
    I need TO CHECK WHEN the USER PASSES in VALUES for P_IN_SERVICE THE CORRESPONDING SELECT STATEMENT SHOULD BE ADDED to the WHERE CLAUSE OF stmt.

    Please see below for p_inservice_date is the input to the procedure parameter.
    When P_IN_SERVICE = "IN_SERVICE", then add the correspondent and the statement.
    The user can move all the value to p_in_service
    The list of p_in_service values are 'IN_SERVICE', 'NOT YET in service', 'All PROJECTS'
    How can I achieve and attached to stmt. and what is the problem with my request.

     stmt          := 'SELECT DISTINCT pta.project_id project_id,
                        pta.project_number project_number,
                        pta.project_name project_name,
                        pta.task_id TASK_ID,
                        pta.Task_number TASK_NUMBER,
                        pta.task_name TASK_NAME,
                        pta.award_id AWARD_ID,
                        pta.award_number AWARD_NUMBER,
                        pta.award_short_name AWARD_SHORT_NAME
                        FROM xxdl.xxdl_cd_pta_all pta
                        WHERE pta.task_id   =pta.top_task_id
                        AND pta.cd_proj_type=''Y'' ';
       IF P_IN_SERVICE IS NOT NULL THEN
        stmt         := stmt || CASE WHEN P_IN_SERVICE = 'IN_SERVICE' THEN ' AND (pta.project_id,pta.task_id,pta .award_id in (SELECT d.project_id,d.task_id,d.award_id
                                                                                                                                FROM xxdl.xxdl_cd_debt_item d,XXDL.xxdl_cd_amortization_status s
                                                                                                                                WHERE d.debt_id = s.debt_id
                                                                                                                                AND   s.active = ''Y''
                                                                                                                               AND   s.amortization_status not in (''CIP'',''NONE'')) '
                                  WHEN P_IN_SERVICE = 'NOT YET IN-SERVICE' THEN ' AND (pta.project_id,pta.task_id,pta .award_id in (SELECT d.project_id,d.task_id,d.award_id
                                                                                                                                FROM xxdl.xxdl_cd_debt_item d,XXDL.xxdl_cd_amortization_status s
                                                                                                                                WHERE d.debt_id = s.debt_id
                                                                                                                                AND   s.active = ''Y''
                                                                                                                               AND   s.amortization_status  in (''CIP'',''NONE'')) '
                                     WHEN P_IN_SERVICE = 'ALL PROJECTS' THEN ' AND (pta.project_id,pta.task_id,pta .award_id in (SELECT d.project_id,d.task_id,d.award_id
                                                                                                                                FROM xxdl.xxdl_cd_debt_item d,XXDL.xxdl_cd_amortization_status s
                                                                                                                                WHERE d.debt_id = s.debt_id
                                                                                                                                AND   s.active = ''Y'''
                             ELSE ' ' END;
                        
      END IF;
    Published by: 893185 on November 29, 2011 23:53

    What is the error message?
    check that it works for me...

    CREATE OR REPLACE PROCEDURE test_proc (P_IN_SERVICE IN VARCHAR2, OUT Varchar2 query)
    AS
    stmt varchar2 (4000);
    Start
    stmt: = "SELECT DISTINCT pta.project_id project,
    PTA.project_number numero_projet,
    PTA. PROJECT_NAME project_name,
    PTA. TASK_ID TASK_ID,
    PTA. Task_number TASK_NUMBER,
    PTA.task_name TASK_NAME,
    PTA.award_id AWARD_ID,
    PTA.award_number AWARD_NUMBER,
    PTA.award_short_name AWARD_SHORT_NAME
    OF xxdl.xxdl_cd_pta_all pta
    WHERE pta.task_id = pta.top_task_id
    AND pta.cd_proj_type = "Y" ';
    IF P_IN_SERVICE IS NOT NULL THEN
    stmt: = stmt. CASE WHEN P_IN_SERVICE = 'IN_SERVICE' THEN ' AND (pta.project_id, pta.task_id, pta .award_id in (SELECT d.project_id, d.task_id, d.award_id
    OF xxdl.xxdl_cd_debt_item d, XXDL.xxdl_cd_amortization_status s
    WHERE d.debt_id = s.debt_id
    AND s.active = "Y"
    AND s.amortization_status not in ("PEAK", "NONE")) '
    WHEN P_IN_SERVICE = 'NOT YET in service' THEN ' AND (pta.project_id, pta.task_id, pta .award_id in (SELECT d.project_id, d.task_id, d.award_id
    OF xxdl.xxdl_cd_debt_item d, XXDL.xxdl_cd_amortization_status s
    WHERE d.debt_id = s.debt_id
    AND s.active = "Y"
    AND s.amortization_status in ("PEAK", "NONE")) '
    WHEN P_IN_SERVICE = 'All THE PROJECTS' THEN "AND (pta.project_id, pta.task_id, pta .award_id in (SELECT d.project_id, d.task_id, d.award_id
    OF xxdl.xxdl_cd_debt_item d, XXDL.xxdl_cd_amortization_status s
    WHERE d.debt_id = s.debt_id
    AND s.active = "Y" '
    ELSE ' ' END;

    END IF;
    dbms_output.put_line (stmt);
    end;

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

  • Preserve the default state and the link using cookies

    Hello

    I don't know where to post this with the re-design of this forum; It has been a while so please forgive me if this is in the wrong g spot.

    I have a very basic link, wrapped in a UL tag.

    I use JQuery to give links a color when they are clicked by performing a function Add/Remove class, the status of the connection is more preserved by cookies so if a user returns to a page; It shows which tab they were viewing.

    The problem is; It is a single page and I want to set a default link or tab; say one. I don't know how to do this.

    That's what I'm looking for to accomplished:

    1. A user accesses the page and the first link is red (default)
    2. If the user clicks another link that the link is active and the first link loses its default status
    3. When the user returns the first link is nolonger by default, that's all that bind the selected user on first visit; This is because this link was Micaela using cookies.
    4. The first link will ONLY maintain the State by default, if the user deletes his cookies or visits to the page for the first time.

    Here's a piece of JQuery, I used to maintain the selected state:

    {$(document) .ready (function ()}

    var idActive = $.cookie ('cookieActive');

    If {(idActive)

    $('#'_+_idActive).addClass ('activeLink');

    }

    $('_ul_li_a').click (function () {}

    ID var = $(this) .attr ('id');

    $("ul_li_a").removeClass ("activeLink");

    $(this) .addClass ("activeLink");

    $('cookieActive', id) .cookie.

    $.cookie('cookieactive', id, {expires: 10000});

    });

    });

    I guess your jQuery works the way you want, and the only problem is how to define the default value.

    In this case, give your default link an ID, such as "default". Then add an else clause of the conditional statement in your jQuery:

    If {(idActive)

    $('#'_+_idActive).addClass ('activeLink');

    } else {}

    $('#default').addClass ('activeLink');

    }

  • 'Find' is case-sensitive and the option does not appear on the search bar

    As I said, it is case sensitive. I looked for an answer and everyone says uncheck case-sensitive on the search bar, but he's not here. I am on a mac with os x 10.9.4 using Firefox 32.0.1.

    I thought about it. I had to restart with disabled addons. I don't know which extension caused the problem, but the change stuck when I re-enabled the addons.

  • Case statement in the process Page

    Request Express 3.2.1.00.11

    I put the following code in an anonymous block (will return no error) for a process Page;

    BEGIN
    INSERT
      INTO DAD_ASSESSMENT_REQUEST
    ( tenure_id
    , client_id
    )
    VALUES
    ( :P10101_TENURE_ID
    , :P10101_CLIENT_ID 
    );
    END;
    

    But when I put a statement case it throws the following error;

    1 error has occurred
    ORA-06550: line 7, column 3: PL/SQL: ORA-01747: invalid user.table.column, table.column, or column specification ORA-06550: line 3, column 1: PL/SQL: SQL Statement ignored
    

    BEGIN
    INSERT
      INTO DAD_ASSESSMENT_REQUEST
    ( tenure_id
    , client_id
    , (CASE 
       WHEN (:P10101_MEASURE_OPTION = 'AREA') THEN estimated_area_ha 
       WHEN (:P10101_MEASURE_OPTION = 'LINE') THEN estimated_length_km 
     END)
    )
    VALUES
    ( :P10101_TENURE_ID
    , :P10101_CLIENT_ID 
    , :P10101_X
    );
    END;
    

    Why is this code not work and it is possible to use a case statement in a Page Apex process

    Concerning

    Ben

    Benton says:

    Request Express 3.2.1.00.11

    I put the following code in an anonymous block (will return no error) for a process Page;

    1. BEGIN
    2. INSERT
    3. IN DAD_ASSESSMENT_REQUEST
    4. (tenure_id
    5. client_id
    6. )
    7. VALUES
    8. (: P10101_TENURE_ID)
    9. ,: P10101_CLIENT_ID
    10. );
    11. END;

    But when I put a statement case it throws the following error;

    1. 1 error has occurred
    2. ORA-06550: line 7, column 3: PL/SQL: ORA-01747: specification user.table.column, table.column or invalid column ORA-06550: line 3, column 1: PL/SQL: statement ignored
    1. BEGIN
    2. INSERT
    3. IN DAD_ASSESSMENT_REQUEST
    4. (tenure_id
    5. client_id
    6. (CASE
    7. WHEN (: P10101_MEASURE_OPTION = 'SPACE') THEN estimated_area_ha
    8. WHEN (: P10101_MEASURE_OPTION = 'LINE') THEN estimated_length_km
    9. END)
    10. )
    11. VALUES
    12. (: P10101_TENURE_ID)
    13. ,: P10101_CLIENT_ID
    14. ,: P10101_X
    15. );
    16. END;

    Why is this code not work and it is possible to use a case statement in a Page Apex process

    Of course, it is possible to use a CASE statement or expression (it is the latter) in a page APEX process. However, it is not possible to use an invalid syntax while doing so. Part of a clause INSERT INTO can contain only static column names.

    In general the SQL expressions (and also the bind variable, another cause frequent errors of syntax) can be used only in

    • the projections of the SELECT queries and subqueries
    • the right side of the disposals in the SET update clause
    • the lists of VALUES of INSERTs
    • WHERE clause predicates

    ReemaPuri wrote:

    Try this

    INSERT

    IN DAD_ASSESSMENT_REQUEST

    (tenure_id

    client_id

    estimated_area_ha

    estimated_length_km

    )

    VALUES

    (: P10101_TENURE_ID)

    ,: P10101_CLIENT_ID

    , (SELECT CASE WHEN: P10101_MEASURE_OPTION = 'SPACE' AND THEN: P10101_X)

    OTHERWISE, NULL END OF DOUBLE)

    , (SELECT CASE WHEN: P10101_MEASURE_OPTION = 'LINE' THEN: P10101_X)

    OTHERWISE, NULL END OF DOUBLE)

    );

    It's a good idea, but it can be simplified, eliminating unnecessary subqueries:

    insert into dad_assessment_request (
        tenure_id
      , client_id
      , estimated_area_ha
      , estimated_length_km)
    values (
        :p10101_tenure_id
      , :p10101_client_id
      , case
          when :p10101_measure_option = 'AREA' then :p10101_x
        end
      , case
          when :p10101_measure_option = 'LINE' then :p10101_x
        end);
    
  • Case statement in the SQL Query prompt dashboard

    Hi Experts,

    I use the following case statement to generate default values in the prompt dashboard based on a condition (the other guest-generated values). Below are two of the query I've tried and the syntax error. I tried all the possibilities (like giving apostrophes, double quotes, don't quote not etc.), but could not understand the question. Don't know what exactly I'm missing here.

    Query 1:

    SELECT

    CASE

    WHEN @{PRType} = monthly THEN 'Participant pay '. "" Amount of PayRate "="15000"

    WHEN @{PRType} = daily THEN 'Participant pay '. "" Amount of PayRate "="650"

    WHEN @{PRType} = hourly THEN 'Participant pay '. "" Amount of PayRate "="1"

    ELSE ' 0'

    END

    OF 'PA-Participant pay. '

    Query 2:

    SELECT

    CASE

    WHEN @{PRType} = monthly THEN "15000"

    WHEN @{PRType} = daily THEN "650"

    @{PRType} = schedule THEN '1'

    ELSE ' 0'

    END

    OF 'PA-Participant pay. '

    This is the query that is generated in the log with error message file.

    1 log message:


    SELECT CASE WHEN Hourly = Monthly THEN "Participant Payroll"."Payrate Amount" = '15000' WHEN Hourly = Daily THEN "Participant Payroll"."Payrate Amount" = '650' WHEN Hourly = Hourly THEN "Participant Payroll"."Payrate Amount" = '1' ELSE '0' END FROM "PA-Participant Payroll"

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>=: Syntax error [nQSError: 26012]. (HY000)



    Comment 2:

    ;CASE WHEN To_Char (Hourly) = 'Hourly' THEN 1 ELSE 0 END 

    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>(): syntax error [nQSError: 26012]. (HY000)

    Sorry, I wasn't clear... you must always put this CASE statement in a valid SQL SELECT statement.

    SELECT

    CASE

    When ' @{PRType}' = 'Monthly' THEN '15000'

    When ' @{PRType}' = 'Daily' THEN '650'

    ELSE '0' END

    OF 'PA-Participant pay. '

  • any case when and the sql clause

    Hello:
    What follows is my sql clause:
    SELECT T.*, b.name
    OF dbtest1 t
    LEFT OUTER JOIN dbtest b ON t.NO = b.empno
    WHERE t.ChineseName like '% "| : ChineseName | ' %' AND b.name like "%" | : name | » %'
    ORDER BY t.ChineseName

    The main problem is that I want to check the b.name if it is null, it can be passed as function NVL, so I try using case when, but it does not work.
    When there are the b.name in where clause, the columns of result will not include data without b.name (or implies the b.name is NULL); And that
    the result data are not entirely accurate.
    is it possible to use the case when it is implemented in the following code snippet:

    -case when b.name is not NULL then b.name like "%" | : name | » %'
    Else b.name = NULL (b.name = b.name does not seem to work on the analysis of data zero)
    end

    Thank you very much.

    962769 wrote:
    The main problem is the table is the form of the cross, and the like clause will filter the
    data without a name. Basically, it should show the empty columns, however, it won't.
    so, when I test the sql code, I fhound Like "%" | b.Name | ' %' will not get the data when the original dbtest1 table data
    has no id corresponding to the BD test. It seems pointless to go the LEFT OUTER JOIN.

    Thank you

    WHERE t.ChineseName like '%'||:ChineseName||'%'
    AND  (
            b.name like '%'||:name||'%'
           or b.empno is null
        )
    
  • Help: How to use the Case statement in the ODI11g Interface?

    Hello
    My basic source I get 'Year' values and I want that these values result code in the interface and after translation want to push on the target system.
    Example:
    Database source, I get value for
    Year
    2010
    2011
    2012

    When I get the year 2010 I want to change the value in "FY10".
    When I get year 2011 I want to change the value in "FY11.
    and even for the year 2012 to "FY12.
    I've tried to make the Case statement, but had no success.
    I don't want to create the lookup table in the source system.
    Any help in this matter.

    Thank you

    Concerning
    Sher

    Published by: Sher Ullah Baig on August 26, 2012 17:52

    CASE
    WHEN source_column = '2010' THEN 'FY10.
    WHEN source_column = '2011' and THEN 'FY11.
    WHEN source_column = '2012' and THEN 'FY12.
    END

  • Case statement in the filter responses

    Hello

    I'm trying to build a query in the replies that filter the returned data based on the number of current month. If the current month is 1 then we want to show every 12 months, we want to show under the current months months. If I use the following:

    Excerpt from WHEN (month of current_date) - CASE = 1 THEN 'calculated monthly values. "" MONTH "> = 1 ELSE 'calculated monthly values. "" MONTH "< extracted (current_date months) END

    I get the error below. Everything works fine until I have add the CASE.

    Error codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Geographical area: 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 occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>= >: syntax error [nQSError: 26012]. (HY000)

    You can use a case statement in a filter? If not, what are the other options, as appropriate?

    THX

    ziekc wrote:
    Hello

    I'm trying to build a query in the replies that filter the returned data based on the number of current month. If the current month is 1 then we want to show every 12 months, we want to show under the current months months. If I use the following:

    Excerpt from WHEN (month of current_date) - CASE = 1 THEN 'calculated monthly values. "" MONTH "> = 1 ELSE 'calculated monthly values. "" MONTH ".< extract="" (month="" from="" current_date)="">

    I get the error below. Everything works fine until I have add the CASE.

    Error codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Geographical area: 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 occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <> =>: syntax error [nQSError: 26012]. (HY000)

    You can use a case statement in a filter? If not, what are the other options, as appropriate?

    THX

    Depending on your needs, when the month is January, you want every 12 months. any other number and you want the month 1 "1 less than the number this month. Yes? Here's what to do:

    In the filter on your date column, click the filter button, convert it to SQL and enter the following:

    MONTH (TableName.date_column) BETWEEN 1 AND CASE WHEN MONTH (CURRENT_DATE) = 1-12 THEN end of MONTH else (CURRENT_DATE)-1

    Here's the logic:

    (a) when the month is January, and then the case statement will give 12 and the filter will be:

    WHERE the MONTH (tablename.date_column) BETWEEN 1 AND 12... .or every 12 months.

    (b) when the current month is any month, say June, then the case statement will give a less than is the number of months, or in this case, 5.

    WHERE the MONTHS (tablename.date_column BETWEEN 1 AND 5 .or every 1 to 5 months (January to may))

    This will give you what you want...

  • CASE statement on the 39gII

    I can't get the CASE statement to work on my 39gII.  Anyone else out there there is a bit of luck?  I keep getting syntax errors.

    It does not in the current official version of Setpbember.

  • Enqueue put States and the

    I'm going through the States of the button in the queue, but it keeps on saying nothing. I do not understand why and have worked on if for days. Why not have the original state?

    What do you mean by 'State '?  Are you talking about what appears in the indicator chain?

    You have a value of timeout associated with the dequeue function.  Another element is not placed in the queue within 50 ms, then the dequeue expires and returns the default value for this cluster are you trying to dequeue which is an empty string.  If you remove the timeout constant or change it to - 1, then the dequeue never expires and the loop is still waiting for the element depending on whether the dequeue actually receives.

  • Case statement in the dynamic JavaScript code

    Dear friends,

    Using the version 4.2.6

    I applied this code in dynamic action to change the color of the intractive report rows of base on the State of the column.

    In my report, I have three columns VIP_GUEST, CANCEL_FLG, APPROVE_FLG.

    If cancel_FLG = "Y", then the color of the line should be red.

    IF VIP_GUEST = 'Y' AND CANCEL_FLG = 'n' then line color should be Orange

    If VIP_GUEST = 'n' AND CANCEL_FLG = 'n' then line color should be green

    How can I set the conditions in the code below. From ways below how to use the above code condtions.

    {$('td[headers="VIP_GUEST"]').each (function ()}
    If ($(this) () .text = ' don't) {}
    $(this) .find ('td').css({"background-color":"#FFFF99"});).closest('tr')
    } ElseIf ($(this) () .text = 'Y') {}
    $(this) .find ('td').css({"background-color":"#EEA196"});).closest('tr')
    } else {}
    $(this) .find ('td').css({"background-color":"#C6EA91"});).closest('tr')
    }
    });

    Hi Maxence,

    CORINE wrote:

    I changed condition in your code, and I have to set a condition more

    IF VIP = 'Y' AND APPROVAL = 'Y', THEN the color should be orange, once again.

    How can I set this condition in the code below.

    Try the following code:

    $('td[headers="CANCEL_FLG"]').each(function() {
          if ( $(this).text() === 'Y' ) {
            $(this).closest('tr').find('td').css({"background-color":"red"});
          } else if ( $(this).text() === 'N' ) {
              var vipflg = $(this).closest('tr').find('td[headers="VIP_GUEST"]').text();
              var aprflg = $(this).closest('tr').find('td[headers="APPROVED_FLG"]').text();
              if ( vipflg === 'Y' && aprflg === 'Y' ) {
              $(this).closest('tr').find('td').css({"background-color":"orange"});
              } else if ( vipflg === 'N' ) {
              $(this).closest('tr').find('td').css({"background-color":"green"});
            }
          }
    });
    

    Kind regards

    Kiran

Maybe you are looking for

  • I am trying to install Windows XP Home Edition on Xp Pro. How do I?

    I am trying to install Windows XP Home Edition on XP Pro. How do I? I load it in the drive, reboot and it won't work.

  • How to use the coupling AC in NO-Scope 5122

    Hello I use no-Scope 5122. Here, I have a problem with the help of AC coupling. The error indicates that valid values are coupling-DC, HF reject. But the manual of 5122 said coupling AC can only be used if the input impedance is set to 1mW. Even afte

  • Windows Server 2012 HyperVisor_Error bugcheck 0 x 00020001 PE R910

    In case someone else runs into this problem.  I recently met a bugcheck HyperVisor_Error 0 x 00020001 on a server PowerEdge R910 after installation of Windows Server 2012 DataCenter Edition, enabling the Hyper-V role and implementation of VMs.  The s

  • Recommendations for VPN authentication

    So, now that Cisco has helped me get the vpn works on my ASA 5525-X I need to use an active administrator for the authentication/grouping of customers for several profiles in anyconnect. My question is what is the simpler and more effective way of se

  • Laptop computer Acer battery level indicator

    I have a notebook Acer Aspire with Windows 8 on it... The battery level indicator turns off before sometimes but to come back after a reboot. Now it appears quite... Is there a permanent solution to this problem?