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.
Tags: HP Tablets
Similar Questions
-
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:
Description of the table: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;
(Number of lines: approx. > amount 600 000 000)
Explain PlanName 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)
Published by: Chaitanya on June 9, 2011 02:44SQL> 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:47When 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? -
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;
- BEGIN
- INSERT
- IN 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: specification user.table.column, table.column or invalid column ORA-06550: line 3, column 1: PL/SQL: statement ignored
- BEGIN
- INSERT
- IN DAD_ASSESSMENT_REQUEST
- (tenure_id
- client_id
- (CASE
- WHEN (: P10101_MEASURE_OPTION = 'SPACE') 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
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. '
-
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:52CASE
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?
THXziekc wrote:
HelloI'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 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.
Published by: 893185 on November 29, 2011 23:53stmt := '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;
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;--------------------
-
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
-
How to use a "Case" statement in the negative
I am pulling data in the form:
SELECT
group_num,
co_id,
pr_id,
Co_id CASE
WHEN '5N' THEN ON 'YES '.
WHEN NOT '5N' THEN 'NO '.
END AS prod_type
FROM table1
I want to get a 'YES' result when co_id is '5N' and all co_id who are not '5N' a value of 'NO '...
I get an error "Missing Expression" and its pointing to the line 'IS NOT', so I obviously don't have the correct syntax.
Any help would be appreciated...
Published by: user12296489 on November 10, 2010 11:22Hello
You're right: CASE can't compare NULL in the same way, it compares the values. My mistake.
I think that the searched CASE expression is what is needed here:
CASE WHEN co_id = '5N' THEN 'YES' WHEN co_id != '5N' THEN 'NO' END AS prod_type
If co_id is NULL, it returns null.
-
case statement and the problem posed by the...
Hello..
Here is the code I use in my pl/sql anonymous block:
I want to do something like this: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;
If it's Sunday, leave this part of the labour code:
can you tell me the correct syntax of the code? where did I did mystake?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;
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;
-
Join the results of a case statement
Hello everyone;
I can't with a query where I use a case statement to create a new column and attempt to reach an additional table on the resulting column. I am fairly new to this and learn by trial and error, so if you think that it looks a little ugly or ineffective, I won't be offended. It is used on my interface based on the web of companies, while I am not able to answer some basic questions such as the version of db.
My need to use the case statement is the result of some strange methods and somewhat contradictory in order to link the product subcodes (sku, fcsku, fnsku), to a product code parent (ProdID). In this case, the inventory is stored in the first table with one of the few types of premises SKUs, however the dimensional data only links to the ProdID. I'm trying to instruction box allows to send the parent a second table (ProdID) code if the sku is there, or a third table if it is found on this table. The main reason (in this case) I have to this ProdID is I can join the dimensional data of a fourth table.
My current query:
SELECT / * + USE_HASH (dbin, sku, xProdID, msr) * /.
dbin.snapshot_date, dbin.bin_id, dbin. ISBN,
CASE WHEN sku. ProdID IS NULL THEN xProdID.ITEM_AUTHORITY_ID
Of ANOTHER sku. ProdID
END ProdIDMaster,
dbin. OWNER, dbin. QUANTITY, dbin. CONTAINER_ID,
MSR. HEIGHT, msr. WIDTH, msr. LENGTH, msr. WEIGHT, msr. DIMENSIONAL_UOM, msr. WEIGHT_UOM,
MSR. HEIGHT * msr. WIDTH * msr. LENGTH as a Volume
OF D_BIN_ITEMS dbin
SKU of LEFT JOIN O_FCSKUS ON dbin. ISBN = sku. FCSKU
LEFT JOIN (SELECT * FROM D_FNSKU_ProdID_MAP)
WHERE REGION_ID = 1
AND SNAPSHOT_DAY = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')) xProdID
ON dbin. ISBN = xProdID.FULFILLMENT_NETWORK_SKU
LEFT JOIN (SELECT * FROM D_MP_ProdID_PKG_MEASUREMENTS)
WHERE REGION_ID = 1 AND MARKETPLACE_ID = 1 AND PACKAGE_TYPE_ID = 1) msr
ON ProdIDMaster = msr. ProdID
WHERE dbin. WAREHOUSE_ID = "PHL5."
AND dbin. Snapshot_date = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')
AND dbin.bin_id like '% P-1-R '.
ORDER BY dbin.bin_id;
The error I receive:
Statement 1 is invalid. ORA-00904: "ProdIDMaster": invalid identifier
ProdIDMaster appears only in two places, an alias for the case statement, as well as a side of the join statement. If I simply change the alias name, it has no effect, so I can only assume the question is how I refer to results of the case statement. I also tried to reach the word 'CASE', which returned "1 statement is not valid. "ORA-00904:"The MATTER": invalid identifier.
Any help or advice would be greatly appreciated.
Post edited by: 8ea4344e-80ea-44e7-b8ac-d482be7245a7 I made a mistake when I posted the code. The ProdID_ID shown in the join should have been ProdIDMaster. I need to change this due to the fact that the name of the column used (which is what I based my alias on) may have been considered confidential information. All the other columns names remained unchanged.
Hello
8ea4344e-80EA-44e7-B8AC-d482be7245a7 wrote:
Hello everyone;
I can't with a query where I use a case statement to create a new column and attempt to reach an additional table on the resulting column. I am fairly new to this and learn by trial and error, so if you think that it looks a little ugly or ineffective, I won't be offended. It is used on my interface based on the web of companies, while I am not able to answer some basic questions such as the version of db.
My need to use the case statement is the result of some strange methods and somewhat contradictory in order to link the product subcodes (sku, fcsku, fnsku), to a product code parent (ProdID). In this case, the inventory is stored in the first table with one of the few types of premises SKUs, however the dimensional data only links to the ProdID. I'm trying to instruction box allows to send the parent a second table (ProdID) code if the sku is there, or a third table if it is found on this table. The main reason (in this case) I have to this ProdID is I can join the dimensional data of a fourth table.
My current query:
SELECT / * + USE_HASH (dbin, sku, xProdID, msr) * /.
dbin.snapshot_date, dbin.bin_id, dbin. ISBN,
CASE WHEN sku. ProdID IS NULL THEN xProdID.ITEM_AUTHORITY_ID
Of ANOTHER sku. ProdID
END ProdIDMaster,
dbin. OWNER, dbin. QUANTITY, dbin. CONTAINER_ID,
MSR. HEIGHT, msr. WIDTH, msr. LENGTH, msr. WEIGHT, msr. DIMENSIONAL_UOM, msr. WEIGHT_UOM,
MSR. HEIGHT * msr. WIDTH * msr. LENGTH as a Volume
OF D_BIN_ITEMS dbin
SKU of LEFT JOIN O_FCSKUS ON dbin. ISBN = sku. FCSKU
LEFT JOIN (SELECT * FROM D_FNSKU_ProdID_MAP)
WHERE REGION_ID = 1
AND SNAPSHOT_DAY = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')) xProdID
ON dbin. ISBN = xProdID.FULFILLMENT_NETWORK_SKU
LEFT JOIN (SELECT * FROM D_MP_ProdID_PKG_MEASUREMENTS)
WHERE REGION_ID = 1 AND MARKETPLACE_ID = 1 AND PACKAGE_TYPE_ID = 1) msr
ON ProdIDid_ID = msr. ProdID
WHERE dbin. WAREHOUSE_ID = "PHL5."
AND dbin. Snapshot_date = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')
AND dbin.bin_id like '% P-1-R '.
ORDER BY dbin.bin_id;
The error I receive:
Statement 1 is invalid. ORA-00904: "ProdIDMaster": invalid identifier
ProdIDMaster appears only in two places, an alias for the case statement, as well as a side of the join statement. If I simply change the alias name, it has no effect, so I can only assume the question is how I refer to results of the case statement. I also tried to reach the word 'CASE', which returned "1 statement is not valid. "ORA-00904:"The MATTER": invalid identifier.
Any help or advice would be greatly appreciated.
Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.
Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always say what version of Oracle you are using (for example, 11.2.0.2.0). Use "SELECT * VERSION of $ v;" to get it.
See the FAQ forum: Re: 2. How can I ask a question on the forums?
When you define an alias for column (such as PriodIDMaster) in the SELECT a query clause, you can use the alias in the ORDER byclause in this request, but this is the only place in this same query, where you can use it. If you want to use anywhere, like in a join condition, then calculate the new column in a subquery; then you can use it anywhere you want in a Super request.
I see expression BOX (not the same as a declarationBOX) where when ProdIDMaster is defined, but I do not see where it is used. Are you sure that you posted the code that is causing the problem?
-
Schema export multile using the case statement
Hello
I want several export schema using case statement.
provable I 4 schema test1, test2, test3 test4 for the scheme I created scripts for each of them either 4 scripts but I want only a scripts instead of 4 scripts. Please suggest how to write shell scripts using a case statement (via a parameter name or the schema).
example of diagram of TEST1.
expdp "" system/redhat as sysdba' "dumpfile directory = TEST1.dmp = DUMP_DIR = TEST1.log patterns = TEST1 logfile logfile = TEST1_Export.log
is it possible if you use under case statement (via the name of parameter/schema)
as case 1: TEST1
2: TEST2
3: TEST3
4: TEST4
If I pass the value as TEST1, and TEST1 schema export is made.No, it's easier.
In addition, you can only get the number and then use TEST$ {export_schema} instead.
But in any case you don't have no need 'breaks '. -
Excel and the CASE statement.
Hello Experts,
I use a CASE statement on the column of CHAR type as follows:
CASE WHEN Sales.Ret = 'Y' THEN 'Return' END of OTHER 'new '.
It gives an error: Odbc driver returned an error (SQLExecDirectW).
Whereas, when I use another CASE statement with column Numrical it works perfectly.
CASE WHEN Sales.Amount < END If NOT 100 40 THEN 40
Am I missing an Excel data source definition related to the CHAR data type?
My source is MS Excel 2003 and OBIEE 10.1.3.4.1
Thank you for any comments, help.
~ Ash
PS: the details of the error are the following:*.
Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 16001] ODBC error state: 37000 code:-3100 message: error [Microsoft] [ODBC Excel Driver] syntax (missing operator) in query expression ' case when T46. [Retirement] = "Y" then "known" other "new" end "... [nQSError: 16014] Prepare the SQL statement failed. (HY000)
Publ. SQL: SELECT Sales.Tran_date, saw_0, CASE WHEN Sales.Ret = 'Y' THEN 'Return' ELSE 'New' END saw_1, network. "" Network name "saw_2, Sales.Amount saw_3 FROM P4UD ORDER BY saw_0, saw_1, saw_2Sorry, the button is 'Ask DBMS' (biee 10g)
-
Use the CASE statement in a query of LOV
Hello
I wrote a select statement to be used in my list of values query, and it works fine when I run with SQL Developer. But when I put it in the LOV I get the LOV query is invalid error message. Here's the query I use:
If the CASE statement is the source of the problem?select case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')' else nt.TAXON_NAME end display_species ,case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')' else nt.TAXON_NAME end return_species FROM NBN_TAXON nt WHERE lower(nt.INPUT_CATEGORY) = decode(lower(:P312_TAXON_GROUP_ADD), 'fish', 'fishes', lower(:P312_TAXON_GROUP_ADD)) order by 1;
Hello
Try to remove the colon semi at the end.
See you soon
Ben
-
Case statement "when IN the cursor.
Hi people.
I wonder if it is possible to use the IN within a CASE statement?
I'm trying to see if a parameter is certain dates in another table. I have a cursor declared which points to this date column, and looks like my case statement so
case parameter_date IN certain_dates then if_holiday: = 1 else if_holiday: = 2 end;
It doesn't when I try to compile. And my procedure is listed as invalid.
Thanks for any help :)I have the Case statement without the right to choose?
Only if specify you on literals as follows
in ('WHATEVER', 'DUDE', 'RUG')
You cannot use a variable.
I guess it may be easier if I just use an if statement.
Ah, is this a CASE of PL/SQL rather than a SQL CASE? Not that it makes a lot of difference. In any case, if this world is IF... ELSIF easier than the CASE? I mean, I'm a traditionalist, and I prefer even the syntax of the CASE.
Cheers, APC
blog: http://radiofreetooting.blogspot.com
Maybe you are looking for
-
I just bought this laptop 106553 HTTP://DE.COMPUTERS.TOSHIBA-EUROPE.COM/CGI-BIN/TOSHIBACSG/SELECTED_PRODUCT_OPTION.JSP?SERVICE=DE&PRODUCT_ID= & DISC_MODEL = 0 and I want to order a pack of 100 DVDs of so, but I don't know which are supported by the p
-
S10e - loud beep on AC connect and disconnect!
Hi everyone - first post here! My Lenovo S10e supplied with Suse Linux Enterprise Desktop, and it works now openSUSE 11.1. I love it! But I'm always in the first weeks congested and still working on the kinks. And here's one: Every time I have connec
-
After a night charging, Sansa Fuze + TRAVELS constantly "loading" graphic
I plug it at bedtime and in the morning, I observed the "Electro-lock" icon on the Green battery logo, which indicates a charge complete. I unplug the unit, and, as you know, it goes to icon clover four leaf-color sansa, exploding in the pixelated "S
-
7 Windows vista upgrade problem During the upgrade of vista 64 bit, 7 64 bit process hangs about 2/3 of the way through the last part and I have to reboot that restores Vista. No idea what could be the cause of the crash?
-
I'm sure this has been asked before, but I can't find an answer. Instead of the story of jabber on C:\Users\%username%\AppData\Local\Cisco\Unified Communications\Jabber\CSF\History\*.db is it possible to save on a central server instead. I tried to c