Error creating view with CASE -- WHEN statement in SQL*Plus
I am using Oracle 8i 8.1.7
I have an Oracle view which uses CASE...WHEN statements.
The view compiles fine in DBA studio.
Using TOAD I saved the view as an *.sql file.
However, when I try to create the view in SQL*Plus I get the following error:
SP2-0734: unknown command beginning "CASE WHEN ..." - rest of line ignored.
According to the documentation CASE -- WHEN has been implemented since since Oracle 8i rel. 2 (8.1.6)
Well I'm using 8.1.6.3 and CASE and DECODE both work for me:
SQL> create or replace view v_accs as select account_name, txn,
2 decode(credit, 0, 'DB', 'CR') t_type
3 from accs;
View created.
SQL> select * from v_accs;
ACCOUNT_NA TXN T_
APC 1 DB
ABC 2 DB
HJJ 3 DB
HJH 4 CR
HJK 5 CR
APC 6 DB
APC 7 DB
ABC 8 DB
ABC 9 DB
HJJ 10 DB
HJJ 11 DB
HJH 12 DB
HJH 13 DB
HJK 14 DB
HJK 15 CR
15 rows selected.
SQL> create or replace view v_accs as select account_name, txn,
2 case when credit = 0 then 'DB' else 'CR'end as t_type
3* from accs
View created.
SQL> select * from v_accs;
ACCOUNT_NA TXN T_
APC 1 DB
ABC 2 DB
HJJ 3 DB
HJH 4 CR
HJK 5 CR
APC 6 DB
APC 7 DB
ABC 8 DB
ABC 9 DB
HJJ 10 DB
HJJ 11 DB
HJH 12 DB
HJH 13 DB
HJK 14 DB
HJK 15 CR
15 rows selected.
SQL>
rgds, APC
Similar Messages
-
Problem with case when statement, when doing an insert.
Hi there, I have written the following coding, that has got an issue, due to not being allowed null values to be inserted into a column on a table.
,Case
WHENCL.LocationISNOTNULLANDCL.[Floor]ISNOTNULLANDCL.RoomISNULLTHEN
(SELECTTop1
FL.FloorIDFROMPMIS.dbo.ConsentLocationF
JOINtbBuildingBONB.BuildingNumber=F.LocationCOLLATELatin1_General_CI_AS
JOINtbFloorFLONFL.BuildingID=B.BuildingID
WHEREF.Location=CL.LocationANDFL.FloorName=CL.[Floor]COLLATELatin1_General_CI_AS)
WHENCL.LocationISNOTNULLANDCL.[Floor]ISNOTNULLANDCL.RoomISNOTNULLTHEN
(SELECTTop1
R.RoomIDFROMPMIS.dbo.ConsentLocationF
JOINtbBuildingBONB.BuildingNumber=F.LocationCOLLATELatin1_General_CI_AS
JOINtbFloorFLONFL.BuildingID=B.BuildingID
JOINtbRoomRONR.FloorID=FL.FloorID
WHEREF.Location=CL.LocationANDFL.FloorName=CL.[Floor]COLLATELatin1_General_CI_ASANDR.RoomNumber=CL.RoomCOLLATELatin1_General_CI_AS)
ENDasParentID
I have written this case when statement above to find a ParentID. I have got the case when statement to work individually, e.g. I get the correct records back. However when I put it into a insert statement, as I want this ParentID to go
into a column in a table I get an error with the following message.
Cannot insert the value NULL into column 'ParentID', table 'K2_Master_4_Test.dbo.tbConsentLink'; column does not allow nulls. INSERT fails.
Can someone point me in the right direction, as to what I need to do to get this case when statement working? Also no I cannot change the structure of the table to allow for null values either. So I need to modifiy this one.The error is valid because your table column has 'not null' constraint and when your case expression does not satisfy either of the 'when' conditions, it is returning NULL to the insert statement.
you can get around this by defining a generic value. Simple Example
select case when <<Column>>=1 then 'First' When <<Column>>=2 then 'Second' Else 'Last' End
In this case, when column value is not 1 or 2, it will insert 'Last'.
So, you have to do something like this...i.e add ELSE condition to your case..
Hope it Helps!! -
Error creating view with tables of other user
I am creating of view containing two tables of another user. I
am a dba-user.
The statement looks like this:
CREATE VIEW TEST
(SELECT ...
FROM DWH.TABLE_A A, DWH.TABLE_B B
WHERE A.ID = B.ID)
I get an error-message (ORA-00942: Table or view not found).
When I create the view as user DWH, everything went OK. I don't
think it has something to do with privileges since I am the dba-
user.
How can I create a view using other users tables?Hi
To create view on table of another user you need to have select
privilege grant directly to you - not to role granted to you. In
your case you can select tables because you have granted dba
role and it has select any table prvivilege, but you havent
directly granted this rights without role.
Regards -
We are trying to create a view in Service Manager 2012 R2 using the class
System.WorkItem.Incident.View.SLAProjectionType
so we can pick up the SLA status (breached/warning) while also picking up the assigned to user, incident id, etc.
When we use the criteria of
Work Item has service level instance information [Service Level Instance Information] status equals breached.
We get the following error.... Any ideas what we are doing wrong?
An exception was thrown while processing GetProjectionsByCriteria for session ID uuid:d83a3f7b-d938-4b35-9343-54c4268cf91c;id=1197.
Exception message: Microsoft.EnterpriseManagement.Common.RelationshipPathElement
Full Exception: Microsoft.EnterpriseManagement.Common.InvalidObjectCriteriaException: Microsoft.EnterpriseManagement.Common.RelationshipPathElement
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.PickFromCandidates(List`1 candidates, RelationshipPathElement relPathElement)
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.ProcessPropertyPath(SeedPathElement seedPathElement, Int32 compositeNodeId, Nullable`1 lcid)
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.ProcessValueExpression(ValueExpressionValueBaseType valueExpression, Nullable`1 targetCompositeNode, Nullable`1 criteriaOperaor)
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.ProcessSimpleExpression(SimpleCriteriaType simpleCriteriaType, Nullable`1 targetCompositeNode)
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.ProcessExpression(BasicExpressionType basicExpression, Nullable`1 targetCompositeNode)
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.ProcessExpression(BasicExpressionType basicExpression, Nullable`1 targetCompositeNode)
at Microsoft.EnterpriseManagement.DataAccessLayer.ExpressionParser.Process(ExpressionType expression)
at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureHelper.ApplyInstanceQueryOptionsToCompositeQuery(CompositeQuery queryRequest, QueryDefinition queryDefinition, String overrideCriteria, Pair`2[] parametersAndValues, InstanceQueryOptions
instanceQueryOptions, IList`1 seedIds, DatabaseConnection databaseConnection, String& criteriaXml)
at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureHelper.ExecuteQueryForProjection(Guid typeProjectionId, DatabaseConnection databaseConnection, Pair`2[] parametersAndValues, IList`1 seedIds, InstanceQueryOptions instanceQueryOptions,
String overrideCriteria, IList`1& compositeResults, IList`1& compositeResultTrimmed, IList`1& changedSeedIdList, Int32& totalResultCount, Boolean& resultSetLarge, String& criteria)
at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureImplementation.ExecuteQueryForProjection(Guid typeProjectionId, Pair`2[] parametersAndValues, IList`1 seedIds, InstanceQueryOptions instanceQueryOptions, IList`1& compositeResults,
IList`1& compositeResultTrimmed, IList`1& changedSeedIdList, Int32& totalResultCount)
at Microsoft.EnterpriseManagement.ServiceDataLayer.DataAccessFeatureImplementation.ExecuteQueryForProjection(Guid seedTypeId, IList`1 seedIds, InstanceQueryOptions instanceQueryOptions, IList`1& compositeResult, IList`1& compositeResultTrimmed,
IList`1& changedSeedIdList, Int32& totalResultCount)
at Microsoft.EnterpriseManagement.ServiceDataLayer.EntityObjectsService.GetProjectionsByCriteria(Guid typeProjectionId, InstanceQueryOptions instanceQueryOptions)
also in the console we get this error.
Date: 10/10/2014 11:45:13 PM
Application: Service Manager Console
Application Version: 7.5.3079.0
Severity: Error
Message: An error occurred while loading the items.
Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportException: The Full adapter threw an exception. See the FullUpdate property to see the exception.
at Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportAdapter.DoAction(DataQueryBase query, IList`1 dataSources, IDictionary`2 parameters, IList`1 inputs, String outputCollectionName)
at Microsoft.EnterpriseManagement.UI.DataModel.QueryQueue.StartExecuteQuery(Object sender, ConsoleJobEventArgs e)
at Microsoft.EnterpriseManagement.ServiceManager.UI.Console.ConsoleJobExceptionHandler.ExecuteJob(IComponent component, EventHandler`1 job, Object sender, ConsoleJobEventArgs args)
Thanks LanceFull Exception: Microsoft.EnterpriseManagement.Common.InvalidObjectCriteriaException:
Your criteria is invalid, somehow. Consider using
Advanced view Editor (or
the free version) to check your criteria XML against the out-of-the-box SLA views. -
Creating view containing case statements received error ORA-22992
We have a create view referencing table through dblink. The select statement in the create view has case statements, when running the Select statement alone, results are return. However, when executing the create view, it returns:
SQL Error: ORA-22992: cannot use LOB locators selected from remote tables
22992. 00000 - "cannot use LOB locators selected from remote tables"
*Cause: A remote LOB column cannot be referenced.
*Action: Remove references to LOBs in remote tables.
One of the source table has LOB column but not in the select statement. The strange thing is when removing the case statement from the select, create view works fine. Can anybody tell me what caused the error and how to fix it?
Create View Snippet:
CREATE OR REPLACE VIEW "ABC"."XYZ" (....
AS SELECT
CASE
WHEN A.OUTAGE =1
THEN 'Y'
ELSE 'N'
END AS OUTAGE,
FROM
TABLEA@XXXX A
LEFT JOIN TABLEB@XXXX B
ON
A.LOC =B.LO
AND A.SITE =B.SITE
WHERE
A.CLASS ='CUSTOMER'
AND A.PLUSSISGIS =1;What is your 4 digit Oracle version?
Try rewriting the query to not use ANSI SQL92 joins. I found a link where this solved a problem similar to yours.
DBLink problem ORA-22992
>
But, look at this curious thing: I re-write the query as follows:
SELECT A.ID, A.ID_REF, A.EVENDATE, B.DESCRIPTION
FROM A@ORCL A, B@ORCL B
WHERE A.ID_REF = B.ID_REF;
and it works fine... It seems like Oracle don't like the ANSI SQL92...
>
Several similar links by googling: 'SQL Error: ORA-22992'
http://www.dbuggr.com/smallwei/solution-error-ora-22992-lob-locators-selected-remote-tabl/
>
Fixing ORA-22992 “cannot use LOB locators selected from remote tables” error
You have migrated your Oracle 9i database to 10g and a distributed statement which worked fine in 9i now is getting error ORA-22992 “cannot use LOB locators selected from remote tables”. Even though the related remote table(s) does not contain any LOB column datatype.
FIX:
There is a bug on 9i,10g, and 11g that is related to this error. It is being fixed in 11.2. It can also be backported for previous 9i, 10g and 11g releases under the latest patchsets.
You may also do a workaround as follow:
Modify the affected SQL by adding the TO_CHAR function. For example:
-- Original SQL:
SELECT NVL2('a', 'b','c' ) FROM dual@remote_db;
-- Modified SQL:
SELECT TO_CHAR(NVL2('a','b','c')) FROM dual@remote_db;
>
See if that helps. -
Using case when statement in the select query to create physical table
Hello,
I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
I have a physical table based on a select table with one column.
SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
I also have a customer table.
In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
EXECUTION
When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
everything works as expected. YE!!
Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
FROM DUAL
Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
If anyone has any explanation to this error and how we can achieve the same, please help.
Thanks.Hello,
Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
Here is what I am trying to do. the select query of the physical table is as follows.
SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
Thanks. -
How to create nested case when statement in OBIEE 11g?
Hi All,
I need to create a formula using nested case when statement. The formula to be created is below:
=If([AWRV]<0; "<0";
If([AWRV]=0; "0";
If([AWRV]<=15; ">0 and <=15";
If([AWRV]<=25; ">15 and <=25";
If([AWRV]<=50; ">25 and <=50";
If([AWRV]<=75; ">50 and <=75";
If([AWRV]<=100; ">75 and <=100";
If([AWRV]<=200; ">100 and <=200";
If([AWRV]<=500; ">200 and <=500";
If([AWRV]<=1000; ">500 and <=1000";
If([AWRV]<=5000; ">1000 and <=5000";
If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
Thanks in advance,
ThenmozhiHoney26 wrote:
Hi All,
I need to create a formula using nested case when statement. The formula to be created is below:
=If([AWRV]<0; "<0";
If([AWRV]=0; "0";
If([AWRV]<=15; ">0 and <=15";
If([AWRV]<=25; ">15 and <=25";
If([AWRV]<=50; ">25 and <=50";
If([AWRV]<=75; ">50 and <=75";
If([AWRV]<=100; ">75 and <=100";
If([AWRV]<=200; ">100 and <=200";
If([AWRV]<=500; ">200 and <=500";
If([AWRV]<=1000; ">500 and <=1000";
If([AWRV]<=5000; ">1000 and <=5000";
If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
Thanks in advance,
ThenmozhiTry the below:
CASE WHEN "Fact - Open Chargeback"."Sub Chbk Amt" < 0 THEN ' <0'
WHEN "Fact - Open Chargeback"."Sub Chbk Amt" = 0 THEN '0'
WHEN "Fact - Open Chargeback"."Sub Chbk Amt" BETWEEN 0 AND 15 THEN '>0 AND <=15'
END
Hope this helps. -
Case when statement not working
hi there, I am trying to work out how to get my case statement to work.
I have got the following code.
select pthproto.pthdbo.cnarole.tpkcnarole, pthproto.pthdbo.cnaidta.formataddr as formataddr, cnaidta.dateeffect as maxdate, isnull(cast (pthproto.pthdbo.cnaaddr.prefix1key as varchar (50)),'') + ' ' + isnull(cast (pthproto.pthdbo.cnaaddr.prefix2key
as varchar (50)),'')+ ' ' + isnull(cast (pthproto.pthdbo.cnaaddr.prefix3key as varchar (50)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.houseidkey as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component1
as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component2 as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component3 as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component4
as varchar (100)),'') + ' ' + isnull (cast (pthproto.pthdbo.cnaaddr.component5 as varchar (100)),'') as mailaddress, row_number() over(partition by pthproto.pthdbo.cnarole.tpkcnarole order by cnaidta.dateeffect desc) as rn into #address from pthproto.pthdbo.cnarole
inner join pthproto.pthdbo.cnaidty on cnarole.tfkcnaidty =cnaidty.tpkcnaidty inner join pthproto.pthdbo.cnaidta on cnaidty.tpkcnaidty = cnaidta.tfkcnaidty inner join pthproto.pthdbo.cnaaddr on cnaidta.tfkcnaaddr = cnaaddr.tpkcnaaddr order by cnaidta.dateeffect
select *, case when mailaddress is not null then mailaddress else formataddr end as test from #address where tpkcnarole = '18306695'
The case when statement is struggling with how i have created the column mailaddress. As it does seem to understand when it is null. In the example I have got there is no value in any of the columns to create
the mailaddress. Hence why I am referencing it from elsewhere. Due to having a way on the system where it picks up data from 2 different places. The mailaddress is always correct if there is one, hence why
trying to reference that one first. So how do i change this case when statement to work ?It's ok I have fixed my own problem
when
(mailaddress
is
null
or mailaddress
=
then formataddr
else mailaddress
end
as test
case -
How to use case when statements in ODI
I need to put conditional logic before DVM look up in ODI. In the expression editor I put the following statement:-
CASE WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS' THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME=EBIZ_CELL.CELL_DATA
WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC' THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)=EBIZ_CELL.CELL_DATA
END
It did not work,
Under Operators ->All Executions, found the error:-
905 : 42000 : java.sql.SQLException: ORA-00905: missing keyword
The description in Session Task contained:-
select
C1_JOURNAL_TEMPL
from APPS.POC_JOURNAL_TEMP_SOURCE_TBL POC_JOURNAL_TEMP_SOURCE_TBL, APPS.C$_0POC_JOURNAL_TEMP_TARGET_TB
where
(1=1)
And (CASE
WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS'
THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME=C2_CELL_DATA
WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC'
THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)=C2_CELL_DATA
END)
Checked the above code in PL/SQL Developer but it gave errors.
In PL/SQL developer tried to check a simple query using case-when but even that is giving errors in the case-when portion.
The query is as follows:-
select phase_code, accounting_period, sum(eff_cc) as BD_Eff_QTD
from prj_detail
where
case POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
when 'EXT'
then
1
when 'RAC'
then
2
when 'XXX'
then
3
else
end
I would like to know what is wrong with the above code.
Please let me know what is the correct way of using case-when in PL/SQL as well as in ODI.Your ODI case statement and PL/SQL Case statement both looks confusing.
You are writing case statement under where clause which is not a good practise. If you want to implement logic like-
select a,b,c from <table>
where
when cond^n^ 1 then do 1
when cond^n^ 2 then do 2
then better you seperate your query for each filter and do a union, in other words-
select a,b,c from <table>
where cond^n^ 1
union
select a,b,c from <table>
where cond^n^ 2
If you are writing case staement to retrieve a value/column (EBIZ_CELL.CELL_DATA) then no need to include it under filter.
ODI case for column EBIZ_CELL.CELL_DATA will be:
CASE
WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='RCS'
THEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
WHEN POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME='FDC'
THEN CONCAT(POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME,POC_JOURNAL_TEMP_SOURCE_TBL.BOOK_CODE)
END
Pl/SQL query-
select phase_code, accounting_period,
case POC_JOURNAL_TEMP_SOURCE_TBL.APPLICATION_NAME
when 'EXT'then 1
when 'RAC' then 2
when 'XXX' then 3
else 'default value' --- (if no else needed then can also remove else part)
end,
sum(eff_cc) as BD_Eff_QTD
from prj_detail
Suggested as per what is understood, hope it helps.
Edited by: 939451 on Jul 5, 2012 12:47 AM
Edited by: 939451 on Jul 5, 2012 12:48 AM -
ERROR creating table with dynamic SQL :-(
Hi friends,
I have a problem when I try to create a table using dynamic SQL.
(Env.: Forms 6i, WinXP, Oracle 9i)
I only want to create a table, insert data and drop the table.
I have a user with the correct privileges (At least ....I think so), because I can to make the three actions in SQL*PLUS (CREATE TABLE, INSERT .. and DROP TABLE).
I want to do the same in Forms using dynamic SQL...
I've made a package with 3 procedures:
1st to create the table, 2nd to insert data , 3rd to drop the table.
Only the 1st fails with the error ORA-01031 (insufficient privileges).
Here it is:
PROCEDURE PRO_DM_CreaTabla(pe_nombre_tabla VARCHAR2) IS
id_cursor INTEGER;
ls_sentencia VARCHAR2(500);
v_dummy integer;
BEGIN
id_cursor := DBMS_SQL.OPEN_CURSOR;
ls_sentencia := 'CREATE TABLE '||pe_nombre_tabla||' ( campo1 VARCHAR2(100), campo2 VARCHAR2(100), campo3 VARCHAR2(100),campo4 VARCHAR2(100))';
DBMS_SQL.PARSE(id_cursor, ls_sentencia, dbms_sql.NATIVE);
v_dummy := dbms_sql.execute(id_cursor);
DBMS_SQL.CLOSE_CURSOR(id_cursor);
END;
The DROP_table procedure is exactly the same as this (with the difference of the 'CREATE' sentence, where I have a DROP sentence)... then.. why the DROP procedure works?... and.. why this CREATE procedure doesn't work?
Any ideas?
Thanks a lot.
Jose.From a different thread, Jose wrote:
V_INSERT:='INSERT INTO TMP_TABLE(field1,field3,field3,field4) VALUES (1,2,3,4)';
Forms_DDL(V_INSERT);
commit;First, try your statement in SQL Plus:
INSERT INTO TMP_TABLE(field1,field3,field3,field4) VALUES (1,2,3,4);
Then if that works, try doing this right after the Forms_DDL(V_INSERT);
If not form_success then
Message(' Insert has failed');
Raise form_trigger_failure;
Else
Forms_DDL('COMMIT');
End if; -
Obiee nested case when statements
Hi Obiee Experts, I need to retrieve amounts for 'last september' so i created a column using this case statement: case when MONTH(CURRENT_DATE) <= 9 then (YEAR(CURRENT_DATE) -1) * 100 + 9 END -- now i want to retrieve the amount for last september using another case statemnt but i get a syntax err message, when i use: CASE WHEN (case when MONTH (CURRENT_DATE) <= 9 then (YEAR(CURRENT_DATE) -1) * 100 + 9 END) THEN "Fact123"."Net Obligation Amount" END ---- Any ideas how to resolve? I will be forever grateful - cheers, Elena
Honey26 wrote:
Hi All,
I need to create a formula using nested case when statement. The formula to be created is below:
=If([AWRV]<0; "<0";
If([AWRV]=0; "0";
If([AWRV]<=15; ">0 and <=15";
If([AWRV]<=25; ">15 and <=25";
If([AWRV]<=50; ">25 and <=50";
If([AWRV]<=75; ">50 and <=75";
If([AWRV]<=100; ">75 and <=100";
If([AWRV]<=200; ">100 and <=200";
If([AWRV]<=500; ">200 and <=500";
If([AWRV]<=1000; ">500 and <=1000";
If([AWRV]<=5000; ">1000 and <=5000";
If([AWRV]<=10000; ">5000 and <=10000"; ">10000"))))))))))))
How to recreate using Nested case when? I tried in many different ways but it is displaying syntax error in obiee11g. This is very critical. Can anybody shed light on this issue pls?
Thanks in advance,
ThenmozhiTry the below:
CASE WHEN "Fact - Open Chargeback"."Sub Chbk Amt" < 0 THEN ' <0'
WHEN "Fact - Open Chargeback"."Sub Chbk Amt" = 0 THEN '0'
WHEN "Fact - Open Chargeback"."Sub Chbk Amt" BETWEEN 0 AND 15 THEN '>0 AND <=15'
END
Hope this helps. -
Using case when statement or decode stament in where clause
hi gems..
i have a problem in the following query..
i am trying to use case when statement in the where clause of a select query.
select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
cr.salary as salary
from customer_details cr
where (case when '>' = '>' then 'cr.salary > 5000'
when '>' = '<' then 'cr.salary < 5000'
when '>' = '=' then 'cr.salary = 5000'
else null
end);
the expression in the when clause of the case-when statement will come from UI and depending on the choice i need to make the where clause.
thats why for running the query, i have put '>' in that place.
so the original query will look like this(for your reference):
select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
cr.salary as salary
from customer_details cr
where (case when variable = '>' then 'cr.salary > 5000'
when variable = '<' then 'cr.salary < 5000'
when variable = '=' then 'cr.salary = 5000'
else null
end);
so, in actual case,if the user selects '>' then the filter will be "where cr.salary > 5000"
if the user selects '<' then the filter will be "where cr.salary < 5000"
if the user selects '=' then the filter will be "where cr.salary = 5000"
but i am getting the error "ORA 00920:invalid relational operator"
please help..thanks in advance..Hi,
select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
cr.salary as salary
from customer_details cr
where ( v_variable = 'bigger'
and cr.salary > 5000
or ( v_variable = 'less'
and cr.salary < 5000
or ( v_variable = 'eq'
and cr.salary = 5000
)Edited by: user6806750 on 22.12.2011 14:56
For some reason I can't write in sql '<', '>', '=' -
"IN" operator in Case When statement
Hi
When I'm trying to use "IN" operator in the "Case When" statement , the following error is being displayed : " [nQSError: 27002] Near <In>: Syntax error [nQSError: 26012] " .
Please let me know wether we can use "IN" oprerator in the Case When statement.
Thanks.Hi
Below is the code in which I'm trying to use "IN" operator in the CASE WHEN statement :
CASE WHEN Month=1 then Year IN (2009,2010) else 0 end
Above - (Year and month are of integer datatype, hence i did not use single quotes)
Thanks -
Using more than one case when statement
Hi there,
I have a question on using case when statements.
Currently I have a table where it shows me mulitple dates.
Order Saledate TransferDate StartDate Enddate GetDate
I have created a where statement to show me records against the transferdate dependant if it appears within the date range of the year, or if it appears within the startdate and today's date.
(lpatran.trandate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate() end))
However on some of the records the transfer date is null, and so they want to use the saledate as the date to use.
So I created
(case when Lpatran.trandate is not null then (Lpatran.trandate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate()))
else (lpatran.saledate between targets.startdate
and (case when targets.enddate < getdate() then targets.enddate else getdate())) end )
However it gives me an incorrect syntax near the word ‘between ‘
Is there a simple fix for this or does sql not allow me to do this?I have created a new column called transferdate and done a case when statement
CASE
WHEN lpatran.trandate
IS
NULL
THEN lpatran.saledate
ELSE lpatran.trandate
END
AS Transferdate,
Then created a temptable and did a select * from temptable. Created a where statement from transferdate, which does work and gives me the correct data.
TransferDate between startdate
and(case
when enddate
<
getdate()
then enddate
else
getdate()
end))
However I wanted to know if there was a way of obtaining the same data without having to use the temptable ? -
Is Prompted (Case When Statement)
I created a column in an answers report and used a CASE WHEN statement as the formula. I set this column to an Is Prompted filter. But when i try to run the report from the dashboard prompt, it just ignores this filter. What am i doing wrong?
Hello,
Prompt also should contain the same case when condition in it's fx so that.. when you say is prompted on that code in answers, prompt value will be effected in the answers.
Else assign a presentation variable to the prompt (if it's drop - down controlled), and use that presentation variable in the filter section of your request...
Hope you get it..
Maybe you are looking for
-
When restarting my computer the screen is freezing on the apple and spinning icon. It never finishes booting. Anyone know how to fix this?
-
Seagate Portable Hard Drive - Documents Not Opening?
Hi guys! I am using a new Seagate GoFlex Portable HD (500GB) and up until 5 minutes ago, no problems were to be had! NOW whenever I try to open ANY old Office For Mac 2010 file, I'm told I can't (for a variety of reasons)! The funny thing is that whe
-
How read just a part of a binary file?
I want to read only a part of a big binary file. I have made a piece of labview code that works well, but every time I try to read only a part of the file, I have an error. I try to search where I have make a mistake in the code, but dont find. Just
-
Photoshop Elements 10 prints are misaligned using hp photosmart 7510
I have Photoshop Elements 10 and when I print a photo using HP Photosmart 7510 the picture is misaligned on the paper. If I print from Windows Photo Gallery the picture is align perfectly. This is a brand new printer.
-
MDS_LOAD_COCKPIT error
Hello All, We are in SRM 7.0 one client sceanrio on ECC 6.0. When manually replicating new products created in ECC to SRM using the transaction MDS_LOAD_COCKPIT, I am getting an error " Assign a base category". I was able to replicate all the existin