Case statement with building xml
Select() XMLType.GetClobVal
XMLElement ("variable"
XMLAttributes (vcInternationalDate?" as "type")
XMLAgg (XMLElement ("item",
CASE WHEN THE TEMPO IS NOT NULL THEN
, XMLElement ("utc", TO_CHAR (TIME,' dd/MM/YYYY HH24:MI:SS)) END))
, XMLElement ("timezone_offSet", ZONE SCHEDULE)
)
)
)
)
like 'CREATIONDATE '.
of twgenericosdb. TEST
WHERE ID = 1
The query above without the case statement producing the result to follow:
< type variable = "vcInternationalDate [:]" >
< item >
< utc > 2009-12-20 15:00 < / utc >
< timezone_offSet > 3600000 < / timezone_offSet >
< / point >
< / variable >
I'm looking for is a way in the case where the time utc is null statement do not tag the utc, utc is NULL the query returns the following result
< type variable = "vcInternationalDate [:]" >
< item >
< utc > < / utc >
< timezone_offSet > 3600000 < / timezone_offSet >
< / point >
< / variable >
I'm trying to use the instruction box to return utc of the tag in the case of the UTC is NULL, but I get the error ORA-00917: Missing comma.
Can someone help me?
Thank you very much.
Try
SELECT XMLTYPE.GetClobVal
(XMLELEMENT
("variable",
XMLAttributes('vcInternationalDate[]' AS "type"),
XMLAGG(XMLELEMENT("item",
CASE
WHEN TEMPO IS NOT NULL
THEN XMLELEMENT("utc", TO_CHAR(TIME, 'dd/MM/yyyy HH24:MI:SS'))
END),
XMLELEMENT("timezone_offSet", TIMEZONE)))) AS "CREATIONDATE"
FROM twgenericosdb.TEST
WHERE ID = 1
You can replace the CASE with NVL2
SELECT XMLTYPE.GetClobVal
(XMLELEMENT("variable",
XMLAttributes('vcInternationalDate[]' AS "type"),
XMLAGG(XMLELEMENT("item",
NVL2(TEMPO,
XMLELEMENT("utc", TO_CHAR(TIME, 'dd/MM/yyyy HH24:MI:SS')),
NULL),
XMLELEMENT("timezone_offSet", TIMEZONE))))) AS "CREATIONDATE"
FROM twgenericosdb.TEST
WHERE ID = 1
URS
Edited by: metzguar the 06.05.2010 15:04
Tags: Database
Similar Questions
-
Case statement with a select &; date in
Hello everyone,
This is my first discussion, so please bare with me.
I am trying to write a case statement with a select statement that compares the dates.
When I write an instruction box with a select statement in it compares everything but dates it works fine. Once the date is there, he collapses.
Here is a super simple example of what I'm trying to do, "b.in_serv_dt" is a date
Select unit_no,
case when ((sélectionnez b.in_serv_dt de b unit_dept_comp_main où a.unit_id = b.unit_id et b.in_serv_dt) > = 1 January 2012 "") then "everybody wins."
When ((sélectionnez b.in_serv_dt dans l'unit_dept_comp_main b où a.unit_id = b.unit_id et b.in_serv_dt) < = 1 January 2012 "") then "Nobody wins".
end
of ottawa_unitmain_v one
Any help would be greatly appreciated
Thank you very much
Hello
your statement of formatting:
Select unit_no
case when ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
and b.in_serv_dt
") > = JANUARY 1, 2012"
) and then "everybody wins."
When ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
and b.in_serv_dt
)<=>=>
) and then "no winner".
end
of ottawa_unitmain_v oneI see "partial conditions": <... and="" b.in_serv_dt="">> that have no meaning.
I guess it's a kind of "typo" and I ignore them.
If the statement is:
Select unit_no
case when ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
") > = JANUARY 1, 2012"
) and then "everybody wins."
When ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
)<=>=>
) and then "no winner".
end
of ottawa_unitmain_v oneI guess that the "b select" retrieve one line, through the design of database (forced...)
As already written: be careful with data types: avoid "implicit conversions" (when you compare different data types, Oracle has convert the data type of the other side, a side example: "mystring = mynumber" is transformed into 'TO_NUMBER (mystring) = mynumber', or 'mydate = mystring' translates mydate = TO_DATE (mystring,
) ")
Even better: use explicit conversions, use explicit formats when necessary.
Best: use no conversion on columns from the constants, but use the correct data type for the constant.With this in mind:
Select unit_no
case when ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
) > DATE = ' 2012-01-01'
) and then "everybody wins."
When ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
)<= date="">=>
) and then "no winner".
end
of ottawa_unitmain_v one
But note that b.in_serv_dt EQUAL to 1 January 2012 (at 00:00:00) is OK for both WHEN the conditions; then the a "win."Now: the subselect statement is identical in the 2 options of the case... You could work differently: (I add the "ELSE" in case one line as NULL in_serv_dt;) I guess that an INNER JOIN is OK, maybe you need a LEFT OUTER JOIN (if some lines of A have no corresponding row in B)
SELECT a.unit_no
, CASE WHEN b.in_serv_dt > = DATE '' 2012-01-01
THEN "everyone wins"
WHEN b.in_serv_dt< date="">
While "Nobody wins".
ELSE ' who knows... ". »
END who_wins
Of ottawa_unitmain_v one
INNER JOIN unit_dept_comp_main b
ON a.unit_id = b.unit_id
;Best regards
Bruno Vroman
-
Eclipse Blackberry plug-in: "run as" problem with build.xml
Hello
I use windows 7 (32 bit), Eclipse 3.5 with the blackberry plugin.
I created a very simple "helloworld" "TestBuild" blackberry project that uses build.xml to build. Here's buildRIM desciption I used in build.xml
jdkhome = "C:\Program Files\Java\jdk1.6.0_20"
DESTDIR = 'out '.
output = "TestBuild.
quiet = "false" >
title = "TestBuild" vendor = 'abc '.
version = "Version = 1.0" description = "My Test Build1"
arguments = "" systemmodule = 'false' "
runonstartup = "false" startuptier = "7".
"RibbonPosition ="0"icon ="... /res/img/TestBuild.png ">
By right click on build.xml, when I "Debug As"-> remote Java Application, everything works fine.
However when I do "run as"--> Blackberry app man goes well and called the Simulator, but without the built application.
In the end, I get this error:
Packaging project TestBuild C:\eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25\components\bin\rapc.exe -quiet codename=deliverables\Standard\5.0.0\TestBuild deliverables\Standard\5.0.0\TestBuild.rapc -sourceroot=C:\Users\Shikha\workspace\TestBuild\src;C:\Users\Shikha\workspace\TestBuild\res -import=C:\eclipse\plugins\net.rim.ejde.componentpack5.0.0_5.0.0.25components\lib\net_rim_api.jar; C:\Users\Shikha\workspace\TestBuild\lib \bb-ant-tools.jar;C:\Users\Shikha\workspace\TestBuild\build.xml C:\Users\Shikha\workspace\TestBuild\bin I/O Error: error in opening zip file: C:\Users\Shikha\workspace\TestBuild\build.xml Packaging project TestBuild failed (took 1.327 seconds)
Please help me!
Hey thanks for your reply. Yes, indeed, I had added build.xml to build the access road. Thus, even when I have not used build.xml for building application, it still existed in the way of the construction and has caused the problem.
works fine now.
Thank you!
-
Hi all.
I use a case statement to represent the values for different regions in a command prompt. I'm having some difficulties, with the values in the case statement. Here is an example of a simplified and shortened my code version.
CASE
WHEN 'Region '. "" Region name "="A"THEN"AMERICA ".
WHEN 'Region '. "" Region name "= 'B' THEN 'CHINA '.
WHEN 'Region '. "" Region name "= 'C' THEN 'EUROPE '.
WHEN 'Region '. "' Name of the region ' = 'A' AND 'B' AND 'C' THEN 'GLOBAL '.
END
My error when I use it in my statement. The formula is accepted, however, all the values are displayed in my guest except 'GLOBAL '.
How can I be able to assign a "GLOBAL"value in my guest? ".
Jagadekara I think that you do not get the point. Any given row retrieved from a data source cannot have all three at one point values!
AJ was trying to tell you, is that your CASE logic has no sense at all.
-
Help in the CASE statement with amount
Hello Experts
I amw Group on
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
I'm unable to solve this Case statement.
My requirement is that if the value of the attribute is greater than 50, then add 1 to the sum for attribute 4 the sum should be 4
WITH T AS
(
Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 writ_per Union double all the
Select MATH_CONV_SCR 70, MATH_PERC 48, writ_conv_scr 66, 67 writ_per Union double all the
Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 double writ_per
)
(
Select)
CASE
WHEN MATH_CONV_SCR > 50 THEN 1
WHEN MATH_PERC > 50 THEN 1
WHEN WRIT_CONV_SCR > 50 THEN 1
WHEN WRIT_PER > 50 THEN 1
TOTAL END)
T
)
The expected answer is
4
3
4
for the respective folders
Please give me the solution
Thank you
RBHello
Rb2000rb65 wrote:
Hello ExpertsI amw Group on
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production...
Thanks for posting the version and sample data; It is very useful.
... Select)
CASE
WHEN MATH_CONV_SCR > 50 THEN 1
WHEN MATH_PERC > 50 THEN 1
WHEN WRIT_CONV_SCR > 50 THEN 1
WHEN WRIT_PER > 50 THEN 1
TOTAL END)
TDon't forget that the WHEN of a CASE expression clauses are mutually exclusive. If none of them are evaluated to TRUE, then all of the following are not even tried.
)
The expected answer is
4
3
4
for the respective foldersPlease give me the solution
Here's one way:
SELECT CASE WHEN math_conv_scr > 50 THEN 1 ELSE 0 END + CASE WHEN math_perc > 50 THEN 1 ELSE 0 END + CASE WHEN writ_conv_scr > 50 THEN 1 ELSE 0 END + CASE WHEN writ_per > 50 THEN 1 ELSE 0 END AS total FROM t;
-
jdev 11.1.1.6
I have a request for which I created the Application Ant build file (when searching for the task of packing include (deploy uses OJ)).
When I try to run the file with default ant deploy option that I have two files to deploy the file:
1. ojdeploy-construction
2 ojdeploy-statuslog
and deploy ear of bot file created in the folder.
Exception message get however following in the file statuslog:
<? XML version = "1.0"? >
< ojdeploy-Journal >
< deploy task >
< target >
profile <>AIMSAdmin < / profile >
workspace <>/C:/JDeveloper/mywork/AIMS_Admin/AIMSAdmin.jws < / workspace >
< project > ViewController.jpr < / project >
/C:/JDeveloper/mywork/AIMS_Admin/deploy/AIMSAdmin.ear < fichier_resultat > < / fichier_resultat >
< / target >
< exception msg = "== ERROR: no module j2ee detected in the Archives of the EAR." Abandoned deployment. == ">"
<! [CDATA]
oracle.jdeveloper.deploy.VetoableDeployException: == ERROR: no module j2ee detected in the Archives of the EAR. Abandoned deployment. ==
at oracle.jdevimpl.deploy.ear.EarDeployerListener.willDeploy(EarDeployerListener.java:113)
at oracle.jdevimpl.deploy.fwk.ListenerSupport.fireWillDeploy(ListenerSupport.java:198)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:88)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:217)
at oracle.jdevimpl.deploy.common.ModulePackagerImpl.deployProfiles(ModulePackagerImpl.java:86)
at oracle.jdeveloper.deploy.common.ModulePackager.deployProfiles(ModulePackager.java:63)
at oracle.jdeveloper.deploy.common.ModulePackager.deployImpl(ModulePackager.java:52)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
to oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl$ 1.run(DeploymentManagerImpl.java:315)
[]] >
< / exception >
< status exitcode = "4" > FAILED < / status >
< / deploy task >
< deploy task >
< target >
profile <>AIMS_ADMIN1 < / profile >
workspace <>/C:/JDeveloper/mywork/AIMS_Admin/AIMSAdmin.jws < / workspace >
< project > ViewController.jpr < / project >
/C:/JDeveloper/mywork/AIMS_Admin/deploy/AIMSAdmin.ear < fichier_resultat > < / fichier_resultat >
< / target >
< exception msg = "== ERROR: no module j2ee detected in the Archives of the EAR." Abandoned deployment. == ">"
<! [CDATA]
oracle.jdeveloper.deploy.VetoableDeployException: == ERROR: no module j2ee detected in the Archives of the EAR. Abandoned deployment. ==
at oracle.jdevimpl.deploy.ear.EarDeployerListener.willDeploy(EarDeployerListener.java:113)
at oracle.jdevimpl.deploy.fwk.ListenerSupport.fireWillDeploy(ListenerSupport.java:198)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:88)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:217)
at oracle.jdevimpl.deploy.common.ModulePackagerImpl.deployProfiles(ModulePackagerImpl.java:86)
at oracle.jdeveloper.deploy.common.ModulePackager.deployProfiles(ModulePackager.java:63)
at oracle.jdeveloper.deploy.common.ModulePackager.deployImpl(ModulePackager.java:52)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:457)
to oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl$ 1.run(DeploymentManagerImpl.java:315)
[]] >
< / exception >
< status exitcode = "4" > FAILED < / status >
< / deploy task >
< Summary >
< - > 2014 start time - 06 - 02 10:56:25 EDT < / time >
< end of time > 2014-06-02 10:56:34 EDT < / end times >
< total-tasks > 2 < / total-tasks >
< chess > 2 < / failures >
< status exitcode = "4" > FAILED < / status >
< / Summary >
< / ojdeploy-log >
the ear could be empty... profile for deployment goto properties and verify application modules ee Assembly.
-
Case statement with several ATHENS
Try to see if the following is possible:
-Case when regexp_like (code1, ' 123') or code1 = "456"
then "Category1".
Where regexp_like (code1, ' 123')
then "Category2".
Another null
end category
Then, of course, that no record being updated with the title of Category2 as criteria code1 already was met.
I am trying to create 2 files for each instance of regexp_like (code1, ' 123'). One record with "Category1" and one with "Category2".
Thank you
I thought that too, but for this:
I am trying to create 2 files for each instance of regexp_like (code1, ' 123')
Looks like a job for the union of all the...
-
Case statement with endorsement instr
Hi here is my code:
This works perfectly. I now need to add another factor Debt_Review. The option is Debt_Review 0 or 1, where 1 means Y and 0 implies N.Update table_1 SET Financial_Review = ( case when instr(Judgement||Liquidation||under_admin,'Y') > 0 then 'Y' else 'N' end)
I essentially seeks to Debt_review in the update above statement. If the judgment or Liquidation or under_admin Y or Debt_Review is 1 then Financial_Review = O n else.
Thanks in advance!
Banner:
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - ProductionHello
Use this...
UPDATE table_1 SET financial_review = (CASE WHEN ( INSTR (judgement || liquidation || under_admin, 'Y') > 0 OR debt_review = 1 ) THEN 'Y' ELSE 'N' END );
I hope this helps...
Thank you
Prakash P -
Case statement with multiple queries to the THEN clause
Y at - it a syntax something like:
Case
When A = 1
Then B: = 2 and C: = 3
When A = 2
Then B: = 4 and C: = 5
Else B: = 6 and C: = 7
End case;
where clause can then have multiple assignments?
Also, how to mark entries as code on this forum?
TIA,
Extreme FarleyYou can simplify a bit:
SQL> declare 2 a number := 0; 3 b number := 0; 4 c number := 0; 5 begin 6 7 Case A 8 WHEN 1 Then 9 B := 2; 10 C := 3; 11 WHEN 2 Then 12 B := 4; 13 C := 5; 14 Else 15 B := 6; 16 C := 7; 17 End Case; 18 dbms_output.put_line('A=' || a); 19 dbms_output.put_line('B=' || b); 20 dbms_output.put_line('C=' || c); 21 end; 22 / A=0 B=6 C=7 PL/SQL procedure successfully completed.
-
A CASE statement with additional where clause
Hi all
I need assistance in which this obligation clause
Table:-balance_table
Columns:-balance_type, balance_amount, balance_month, budget_name
balance_type column had given 'Real' OR 'Budget '.
Now I am trying to extract data such as: if: entered_month is Mar-2009 then before and including Mar-2009 will show real balance sheet Date and after Mar-2009 will show budget data.
It works fine, I need to add a condition more restrict the budget name, there are several budget_name in the table for balance_type = 'Budget '.
SELECT SUM (balance_amount), balance_type, balance_month
OF balance_table
WHERE balance_type =
(CASE
WHEN balance_month < =: entered_month
THEN 'real '.
ANOTHER 'Budget '.
END
)
AND budget_name = 'BUDGET1.
Balance_type GROUP, balance_month
Stated above is erroneous because ' AND budget_name = ' BUDGET1 "clause restricts the set of data."
Please help in contrcuting where clause 1) to sort the data according to Budget/actual and 2) for specific budgets, so budget_type = Budget
Thank you
BobinThat should do it.
SELECT SUM (balance_amount), balance_type, balance_month FROM balance_table WHERE (balance_type = 'Actual' and balance_month <= :entered_month ) or (balance_type = 'Budget' and balance_month > :entered_month and budget_name = :entered_budget_name ) GROUP BY balance_type, balance_month ORDER BY 2
See you soon
Sarma. -
Case mix with Nested ifs statement
Hello I need to mix a case statement with a few nested ifs, but I get an error I do not know how to start or complete the case statement. I've shortened the statement FOR readability
Here is the code:
< tt >
BEGIN
FOR events IN (SELECT EBA_CA_EVENTS. EVENT_NAME, EBA_CA_EVENTS. EVENT_ID,...)
LOOP
If the events. TYPE_ID <>(32230291965131516245569156552736940921) AND to_date (SYSDATE) = ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT1)
THEN
Dbms_output.put_line ('adjustments of the SEND E-MAIL Alert 1 "criteria);
on the other
If the events. TYPE_ID = (32230291965131516245569156552736940921) and nvl(events.COMPLETED_MAIL_SENT,0) <>room ')
THEN
Dbms_output.put_line ('SEND EMAIL FILLED WITH TERRY');
UPDATE EBA_CA_EVENTS set COMPLETED_MAIL_SENT = piece ') where ROW_KEY = events. ROW_KEY;
on the other
If the events. TYPE_ID <>(32230291965131516245569156552736940921) AND to_date (SYSDATE) = ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT2)
THEN
Dbms_output.put_line (' fits the criteria 2nd SEND E-MAIL alert 2 "");
on the other
If the events. TYPE_ID <>(32230291965131516245569156552736940921) AND to_date (SYSDATE) = ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT3)
THEN
Dbms_output.put_line ('fits the 3rd criteria SENDING E-MAIL Alert 3 ");
end if; -4
end if; -3
end if; -2
end if; -1
CASE
Events WHEN. EVENT_NOT2 is null
THEN
If to_date (SYSDATE) > ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT1) AND nvl (events. ALERT1_SENT, 0) part <>')
THEN
Dbms_output.put_line ('send e-mail if day part 1');
UPDATE EBA_CA_EVENTS set ALERT1_SENT = piece ') where ROW_KEY = events. ROW_KEY;
end if;
END
other cases
Events WHEN. EVENT_NOT2 is NOT NULL
THEN
If to_date (SYSDATE) > ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT1) AND nvl (events. ALERT1_SENT, 0) part <>') AND to_date (SYSDATE) < ((to_date (to_char (events. ((EVENT_DUE_DATE, "DD-MON-YYYY HH24:MI:SS"), "HH24:MI:SS MON-DD-YYYY"))-events. EVENT_NOT2)
THEN
Dbms_output.put_line ('If day spent game 2 with the value');
UPDATE EBA_CA_EVENTS set ALERT1_SENT = piece ') where ROW_KEY = events. ROW_KEY;
end if;
END
END LOOP;
END
< /tt >
The error occurs towards the end of the case statement-
I also tried this the 'else' deletion before the case and a few other variations, I can't just not perfect the code however, any help would be appreciated, thanks
BTW, I can't use IF... Logical I already tried, then once a particular branch occurs then the else statements are ignored.
You had an extra 'END' where he shouldn't have been and were not an 'END' where TI EXPECTED have been.
This is your modified code (I had to fill out the... that my trainer Toad worked properly)
BEGIN FOR EVENTS IN ( SELECT eba_ca_events.event_name, eba_ca_events.event_id FROM
) LOOP IF( EVENTS.type_id <> (32230291965131516245569156552736940921) AND TO_DATE(SYSDATE) = ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS') - EVENTS.event_not1)) ) THEN DBMS_OUTPUT.PUT_LINE('Criteria fits SEND EMAIL Alert 1'); ELSE IF( EVENTS.type_id = (32230291965131516245569156552736940921) AND NVL(EVENTS.completed_mail_sent, 0) <> ('S') ) THEN DBMS_OUTPUT.PUT_LINE('SEND COMPLETED EMAIL TO TERRY'); UPDATE eba_ca_events SET completed_mail_sent = ('S') WHERE row_key = EVENTS.row_key; ELSE IF( EVENTS.type_id <> (32230291965131516245569156552736940921) AND TO_DATE(SYSDATE) = ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not2) ) THEN DBMS_OUTPUT.PUT_LINE('2nd Criteria fits SEND EMAIL Alert 2'); ELSE IF( EVENTS.type_id <> (32230291965131516245569156552736940921) AND TO_DATE(SYSDATE) = ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not3) ) THEN DBMS_OUTPUT.PUT_LINE('3rd Criteria fits SEND EMAIL Alert 3'); END IF; -- 4 END IF; -- 3 END IF; -- 2 END IF; -- 1 CASE WHEN EVENTS.event_not2 IS NULL THEN IF( TO_DATE(SYSDATE) > ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not1) AND NVL(EVENTS.alert1_sent, 0) <> ('S') ) THEN DBMS_OUTPUT.PUT_LINE(' send email if date past part 1'); UPDATE eba_ca_events SET alert1_sent = ('S') WHERE row_key = EVENTS.row_key; END IF; ELSE CASE WHEN EVENTS.event_not2 IS NOT NULL THEN IF( TO_DATE(SYSDATE) > ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not1) AND NVL(EVENTS.alert1_sent, 0) <> ('S') AND TO_DATE(SYSDATE) < ((TO_DATE(TO_CHAR(EVENTS.event_due_date, 'YYYY-MON-DD HH24:MI:SS'), 'YYYY-MON-DD HH24:MI:SS')) - EVENTS.event_not2) ) THEN DBMS_OUTPUT.PUT_LINE('if date past part 2 with value'); UPDATE eba_ca_events SET alert1_sent = ('S') WHERE row_key = EVENTS.row_key; END IF; END CASE; END CASE; END LOOP; END; I hope this helps.
-
Case statement for aging buckets
OBIEE 11 g. I am trying to create a case statement with aging buckets. Tried in the frontend and the RPD, but on the first bucket made its appearance. (1-30 days old). The other 3 buckets do not appear.
30 - 60 days old
60 - 90 days old
90 - 120 days old
There are dates in the database who meet the criteria for the other 3 buckets. This is the case statement.
-
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)
-
I have problem with value NULL when the use CASE statement please help this question
I have problem with value NULL when the use CASE statement please help this question
Table: digital_val
SNO cl C2
1 San1 11
2 22 San2
Actual result: expected to A B
A B 11 22
11 NULL
22 NULL
query:
Select case when c1 = "san1" then c2,.
case If c1 = "san2" then c2 B
of digital_val
I'm more curious why, when you select 2 rows, you expect a result of row?
WITH digital_val
AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)
UNION ALL
2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)
SELECT CASE WHEN c1 is "San1" THEN END AS A c2.
CASE WHEN c1 = "San2" THEN END AS B c2
OF digital_val;
With no other input, if you select 2 rows, you get 2 rows. One of the other solutions use a max function, but is this really what you want, does not specify?
-
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.
Maybe you are looking for
-
HP TouchSmart 520-1050 &; latest games PC MOH and COD BlackOps II
I got this system since December last and really liked even if my biggest headache is THE lock up or break running Win7 64 bit. What turned me this system and I've never turned away from any HP system in almost 30 years in the past two weeks. I order
-
8570w HP EliteBook mobile workstation. Starting stalls.
My company uses HP laptops, and that the warranty is up, we change our laptops. My last two phones were EliteBook mobile workstations. Both have the same problem. My current EliteBook is a 8570w. Two laptops at home and at work, the appropriate docki
-
HP OfficeJet G85: 10 Windows messed up my printer
I've updated to Windows 10 and now my printer prints half a page, then gets an error and stops. I ran the resolution of problems and he stated that the printer was plugged into a "USB 3.0' and plug it into a"USB 2.0 ". It's the same USB port, it's al
-
How can I correct an error in scripts
whenever I try to print a map, I get an error code of scripts
-
BlackBerry 8320 T-Mobile of Smartphones-no Service and no Bluetooth
3 months 8320 - old just started 'no service' came out baterry, reset it etc - still the same problem. Bluetooth disabled - regardles of what I always disabled. Released battery while your phone and reset the bluetooth on that and then just sits ther