Case Statement Not returning resutlset Varbinary
Declare @val varbinary
set @val = cast('123456789' as varbinary)
select @val as value -- Varbinary Value Result
Declare @check bit
set @check= 1
--THis Case Statement Not returning Result set in Varbinary .
select case @check when 1 then @val else 1 end as value
See the below part from MSDN documentation reg return type
Returns the highest precedence
type from the set of types in result_expressions and
the optional else_result_expression.
http://msdn.microsoft.com/en-IN/library/ms181765.aspx
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Similar Messages
-
Case statement not working in rpd
Hi Gurus,
I am giving case statement for the exchange rate column#1 from original exchange rate column , the data of column is like
0.0
0.0
0.1
0.2
1.2
1.3
1.4
so here i dont want 0.0 instead of that i want 1.0 so whenever in next derived column i will calculate it would be this derived exchange rate#1 * inv amt = desired amt
for the same I used different diff. case statement but still 0.0 is not going , I am giving like
1) CASE WHEN BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" = 0.0 THEN BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" * 1.0 ELSE BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" END
2) CASE WHEN BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" = 0.0 THEN 1.0 ELSE BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" END
nothing is working , result remains same, any quick help would be apprciated
Thanks,Once again, could you write all information, like I described here my example.
When tried the same it works.
TABLE.COLUMN1 is from dimension.
TABLE.COLUMN1 is DOUBLE in the physical layer (in Oracle it is NUMBER(8,2)) and view/data gives:
TABLE.COLUMN1
12.99
0.00
0.20
In the RPD I made new logical columns.
EXPR:
CASE WHEN "Presentation area".TABLE.COLUMN1 = 0.0 THEN 1.0 ELSE "Presentation area".TABLE.COLUMN1 END
EXPR2:
CASE WHEN "Presentation area".TABLE.COLUMN1 = 0 THEN 1 ELSE "Presentation area".TABLE.COLUMN1 END
Test in Answers:
COLUMN1----EXPR----EXPR2
12.99---------12.99----12.99
0.00-------------1.0--------1.0
0.20------------0.20------0.20
I leaved data format on the column properties as default (override default data format not checked).
I don't see where is the problem.
Regards
Goran
http://108obiee.blogspot.com -
CASE Statement not working.
I have following case statement in formula to display a specific image if the value from a column is a certain color:
CASE "Facts"."Indicator" WHEN 'Green' THEN '<img src="res/s_blafp/images/green_image.gif" title="Green" </>' WHEN 'Yellow' THEN '<img src="res/s_blafp/images/yellow_image.gif" title="Yellow" </>' WHEN 'Red' THEN '<img src="res/s_blafp/images/red_image.gif" title="Red" </>' END
So far when I use the case statement it only dislpays the following instead of the actual image.
<img src="res/s_blafp/images/green_image.gif" title="Green" </>'shaolin_obiee wrote:
I have following case statement in formula to display a specific image if the value from a column is a certain color:
CASE "Facts"."Indicator" WHEN 'Green' THEN '<img src="res/s_blafp/images/green_image.gif" title="Green" </>' WHEN 'Yellow' THEN '<img src="res/s_blafp/images/yellow_image.gif" title="Yellow" </>' WHEN 'Red' THEN '<img src="res/s_blafp/images/red_image.gif" title="Red" </>' END
So far when I use the case statement it only dislpays the following instead of the actual image.
<img src="res/s_blafp/images/green_image.gif" title="Green" </>'Take a look at this link:
http://gerardnico.com/wiki/dat/obiee/image -
MDX simple case statement not working?
hi all - any idea what is wrong with this MDX statement? it is returning blank. I am trying to add a calculated measure using the below code but it is not working. thanks for the help.
CASE WHEN [Accounts].[Account Name].CURRENTMEMBER = "Cash" THEN
([Dates].[Hierarchy].currentMember.lastChild, [Measures].[Measures].[Amount]) ENDIf you are checking for the 'Cash' member of the Account Name hierarchy, do you need to do something like this?
CASE WHEN [Accounts].[Account Name].CURRENTMEMBER IS [Accounts].[Account Name].[Cash] THEN([Dates].[Hierarchy].currentMember.lastChild, [Measures].[Measures].[Amount]) END
Regards,
MrHH -
Case statement Not working with Oracle version 10g
Below is code , which works on 11r2 but not on 10g.
declare
v1 VARCHAR2(200);
begin
select version into v1 from DBA_REGISTRY WHERE COMP_NAME LIKE '%Catalog Views%';
CASE
WHEN v1 like '10.2%' THEN
DBMS_OUTPUT.PUT_LINE('it is 10.2');
dbms_streams_auth.grant_admin_privilege('GGADMIN');
WHEN v1 like '11.1%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.1');
dbms_streams_auth.grant_admin_privilege('GGADMIN');
EXECUTE IMMEDIATE 'grant become user to GGADMIN';
WHEN v1 like '11.2.0.3%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.2.0.3');
dbms_goldengate_auth.grant_admin_privilege('GGADMIN');
END CASE;
end;
/I dont know when i run code in 10.2 it still looks for dbms_goldengate_auth
and error out.
dbms_goldengate_auth.grant_admin_privilege('GGADMIN');
ERROR at line 18:
ORA-06550: line 18, column 1:
PLS-00201: identifier 'DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE' must be declared
ORA-06550: line 18, column 1:
PL/SQL: Statement ignoredif I comment dbms_goldengate_auth it returns perfect result.
it is 10.2
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.03Is there any other way around ????
Edited by: 949509 on Jan 27, 2013 6:57 PM949509 wrote:
Can you please tell me How i can execute dynamic sql via execute immediate.In a very simialr was as you did the grant of become user in your code. SOmething like:
declare
v1 VARCHAR2(200);
l_grant_str VARCHAR2(1000);
begin
select version into v1 from DBA_REGISTRY WHERE COMP_NAME LIKE '%Catalog Views%';
CASE
WHEN v1 like '10.2%' THEN
DBMS_OUTPUT.PUT_LINE('it is 10.2');
l_grant_str := 'dbms_streams_auth.grant_admin_privilege(''GGADMIN]'')';
WHEN v1 like '11.1%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.1');
l_grant_str := 'dbms_streams_auth.grant_admin_privilege(''GGADMIN'')';
EXECUTE IMMEDIATE 'grant become user to GGADMIN';
WHEN v1 like '11.2.0.3%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.2.0.3');
l_grant_str := 'dbms_goldengate_auth.grant_admin_privilege(''GGADMIN'')';
END CASE;
execute immediate l_grant_str;
end;John -
SELECT statement not returning NULL records
I have the following SELECT statement:
SELECT *
FROM RPT_DS1_CNT_CAT
WHERE DUPS_SAME <> 'N/A';
I also tried:
SELECT *
FROM RPT_DS1_CNT_CAT
WHERE DUPS_SAME != 'N/A';
Same results - There ARE Null DUPS_SAME values
which are not being selected. I get NO results.
When I execute this, I do get NULL values.
SELECT *
FROM RPT_DS1_CNT_CAT
WHERE DUPS_SAME IS NULL;
How can I ensure that I get all non - 'N/A' records
if it won't pick up the nulls? Is there a function
I can use or a different wording? I do want to use
!= or <> because there may be other values besides
'N/A' such as 'YES' or 'NO' and they may be null or
filled with spaces.The expression
NVL(DUPS_SAME,'') is meaningless. You're saying "If DUPS_SAME is NULL, return the empty string, which is NULL, otherwise return DUPS_SAME." If you're going to use NVL, the string that gets returned if the column is NULL should be non-NULL, i.e.
NVL(DUPS_SAME,'DUPS_SAME was NULL') Your query should, as others have pointed out, either be
SELECT *
FROM rpt_ds1_cnt_cat
WHERE dups_same <> 'N/A' OR dups_same IS NULLor
SELECT *
FROM rpt_ds1_cnt_cat
WHERE NVL(dups_same, 'DUPS_SAME is NULL') <> 'N/A' Either of these return the same results as your query but they're going to be far clearer for whoever needs to maintain the code. There may be performance differences as well if DUPS_SAME is indexed depending on the data distribution...
Justin -
Select statement not returning correct data
I'm working on an application and I'm having a weird problem. The application connects to an Oracle database, pulls out some data, and does something with it. In the process of testing I've already read and dealt with some rows. On those rows the UPDATE_FLAG field was changed to a N so they wouldn't be selected again.
I do want to select those rows again, so with SQLPlus I changed the UPDATE_FLAG back to Y. Now here's the strange part. The same select statement run from SQLPlus is returning thoe row I modified, but my application does not.
Here's the select statement:
SELECT * FROM MY_TABLE WHERE UPDATE_FLAG = 'Y' and USER_ID like 'B%';
When I run this I get a row back called Brian.
In my application I do this:
try
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@server:port:sid", "username", "password");
Statement st = conn.createStatement();
ResultSet rec = st.executeQuery("SELECT * FROM MY_TABLE WHERE UPDATE_FLAG = 'Y' and USER_ID like 'B%'");
System.out.println("SELECT * FROM MY_TABLE WHERE UPDATE_FLAG = 'Y' and USER_ID like 'B%'");
while(rec.next())
System.out.println(rec.getString("USER_ID"));
st.close();
} catch (Exception e)
System.out.println("Error -- " + e.toString());
e.printStackTrace();
}When this runs it doesn't return Brian and there are no exceptions caught. It's like it does not find it.
Assuming I explained this well enough, anyone have any ideas what the problem could be?
Thanks,
JamesI do want to select those rows again, so with SQLPlus I changed the UPDATE_FLAG back to Y. Last time I ran SQLPlus I explicitly had to do a commit after modifications, because it was creating a transaction around the sqlplus session. Of course running a query in that session would work on the modified data rather than the actual data.
-
CLOB with case statement not working getting error
Can anyone help on this
I write this sql
select Case when to_clob(PROPERTY) = 'is_intradesk=Y' then 'Internal' end
from JPM_CP;
Where PROPERTY column is clob column and its giving the error "ORA-00932: inconsistent datatypes: expected - got CLOB"
Is it not possible to use clob columns with case or decode !Its working but it does not fulfill my purpose
In you answer it is looking for position right! means, does the column contain the value('Intradesk=Y' ) or not. means
I am looking for exact match with CLOB column values, that is Clob column(PROPERTY) contains the exact value that value which I am comparing with i.e 'Intradesk=Y'
I need this
select * from table where clob_column = 'value' (exact).
Edited by: sajalkdas on Feb 4, 2011 3:28 PM -
MDX Case Statement not working
Hi have written the following MDX statement to create a new column calledl 'Aon Group' and group the Policy Broker Names into 2 values, either 'Aon' or 'All Other':
WITH Member [Measures].[Aon Group]
as
Case when [Broker].[Policy Broker Name - Big 6].[Policy Broker Name - Big 6].&[Aon] Then "Aon"
Else "All Other"
End
SELECT NON EMPTY
{ [Measures].[Net Premium],[Measures].[Aon Group] }
ON COLUMNS,
NON EMPTY
{ ( [Broker].[Policy Broker Name].[Policy Broker Name].ALLMEMBERS ) }
ON ROWS
FROM [Broker Premium]
Here are my results:
It's giving me #Error and the actual 'Aon' Policy Broker Name is showing 'All Other', which is opposite of what I want.
thanksHi Scott,
Here is a query for your reference.
With Member [Measures].[Test]
As
Case [Product].[Category].CurrentMember.Name
When [Product].[Category].&[1].Name Then "Bike"
Else "Others"
End
Select {[Measures].[Test],[Measures].[Internet Sales Amount]} on columns,
[Product].[Category].[Category].members on rows
from [Adventure Works]
Results
If you have any questions, please feel free to ask.
Regards,
Charlie Liao
TechNet Community Support -
Case statement not working as expected
I get this error having the group by clause: ORA-00979: not a GROUP BY expression
I get this error with out it: ORA-00937: not a single-group group function
If I add sp.PUBLISHER_ID to the group by, my data comes out on separate lines like this:
BT jlloyd ALLEN IVERSON B 0 3 0
BT jlloyd ALLEN IVERSON B 1 0 0
What am I doing wrong?
select distinct office_id,user_id,
nvl(customer, profile_name),
nvl(account, profile_name),
profile_name,
profile_type,
case when sp.PUBLISHER_ID = 503
then count(distinct sp.instance_id)
else 0 end as MR_Reports ,
case when sp.PUBLISHER_ID = 501
then count(distinct sp.instance_id)
else 0 end as QV_Reports,
case when sp.PUBLISHER_ID = 3533
then count(distinct sp.instance_id)
else 0 end as BS_Reports
from vw_profile_info p join SOLD_PUBLISHERS sp
on p.profile_id = sp.profile_id
join SOLD_SEGMENTS ss
on ss.profile_id = sp.PROFILE_ID
and ss.instance_id = sp.instance_id
and ss.BASKET_ID = sp.basket_id
join publishers p
on p.publisher_id = sp.publisher_id
where sp.publisher_id in (501,503,3533)
and sp.PUBLISHED_DATE between to_date('10/01/2005','mm/dd/yyyy') and
to_date('10/31/2005','mm/dd/yyyy')
and profile_name = 'ALLEN IVERSON
group by office_id,user_id,
nvl(customer, profile_name),
nvl(account, profile_name),
profile_name,
profile_typeThere are couple of ways, one of them would be
select office_id,
user_id,
nvl(customer, profile_name),
nvl(account , profile_name),
profile_name,
profile_type,
sum(decode(sp.PUBLISHER_ID, 503, 1, 0) MR_Reports,
sum(decode(sp.PUBLISHER_ID, 501, 1, 0) QV_Reports,
sum(decode(sp.PUBLISHER_ID, 3533, 1, 0) BS_Reports
from vw_profile_info p join SOLD_PUBLISHERS sp
on p.profile_id = sp.profile_id
join SOLD_SEGMENTS ss
on ss.profile_id = sp.PROFILE_ID
and ss.instance_id = sp.instance_id
and ss.BASKET_ID = sp.basket_id
join publishers p
on p.publisher_id = sp.publisher_id
where sp.publisher_id in (501,503,3533)
and sp.PUBLISHED_DATE between to_date('10/01/2005','mm/dd/yyyy') and to_date('10/31/2005','mm/dd/yyyy')
and profile_name = 'ALLEN IVERSON'
group by office_id,
user_id,
nvl(customer, profile_name),
nvl(account , profile_name),
profile_name,
profile_type -
Unable to return a number from CASE statement in plsql
Hello all!
Back in November of last year, I received some assistance from user "jarola" regarding changing the color of a column item in a query based on the resulting value. This discussion yielded;
declare
l_query varchar2(4000) := '';
begin
l_query := '
select i.INVENTORY_ID,
io.ORDER_QUANTITY,
CASE
WHEN i.QUANTITY_AVAILABLE=0
THEN ''<span style="color:red;"> ''|| i.QUANTITY_AVAILABLE ||''</span>''
ELSE to_char(i.QUANTITY_AVAILABLE)
END,
i.QUANTITY_AVAILABLE qty_avail_hold,
i.STRAIN_CODE,
i.STRAIN_NAME,
i.GENOTYPE,
i.AGE,
i.***,
(lower(substr(i.ROOM_NUMBER,1,instr(i.ROOM_NUMBER,''-'',1,1)-1))) ROOM_NUMBER
from SM_INVENTORY i,
SM_INVENTORY_ORDER io
where io.ORDER_ID (+)= :F111_MODIFYING_ORDER
and io.INVENTORY_ID (+)= i.INVENTORY_ID';
return l_query;
end;Problem is, sorting (report attributes for column set to "sort") on column i.QUANTITY_AVAILABLE is broken as even though the data in the table is number(12,0), the CASE statement returns it as alpha. I'm having difficulty getting this CASE statement to return a number as these modifications cause generic compilation errors.
ELSE i.QUANTITY_AVAILABLE
ELSE to_number(i.QUANTITY_AVAILABLE)
Google/sqlplus docs have yielded little. Might anyone offer advice?
Thanks!!!
PaulHello Varad! Thanks for the reply.
Sorry, but I copied some old information in my code example. the CASE statement I'm actually using is;
CASE
WHEN i.QUANTITY_AVAILABLE=0
THEN ''<span style="color:red;"> ''|| i.QUANTITY_AVAILABLE ||''</span>''
ELSE to_char(i.QUANTITY_AVAILABLE)
END AS QUANTITY_AVAILABLESo I'm already returning the result as labeled "QUANTITY_AVAILABLE".
What I did was click on the pencil/paper icon to the left of the alias of my column in the "Column Attributes" pane in "Report Attributes" to get to the "Column Attributes" page and plugged #QUANTITY_AVAILABLE# into the HTML Expression field of the "Column Formatting" pane of the "Column Attributes" page for the "QUANTITY_AVAILABLE" column.
No joy, sort still broken...
Isn't the problem that fundamentally, the CASE statement returns an alpha? I wouldn't expect the sort to ever work until it can return a number (which it appears SQL, used this way, it cannot do).
So, I considered that END AS QUANTITY_AVAILABLE might be the problem as it's named the same as the column, so I changed it (and the HTML Expression entry) to END AS QUANTITY_AVAIL (changed the name).
Sort as alpha still happening.
Any other thoughts? -
T-SQL: SET Statement Using a Case Statement is not returning a value
SQL VER: 2008
Please see the attached screenshot from SSMS. The Set statement below is not returned a value or may be returning a zero value. The AllocPercent field is set to zero in code preceeding this Update Statement:
AllocPercent
=
CASE
WHEN AllocBase
IS
NULL
OR AllocBase
= 0
THEN 0
ELSE PM_Input/AllocBase
END
As you can see by the screen shot from the Select Statement that is displaying the results after the Update Statement is completed, the value of AllocPercent is = 0 even though all the values necessary for it to compute a value > 0 are present in the
table. Incidentally, the values in both the AllocBase and PM_Input fields are the same before the Update Statement is ran, as shown in the Select ran after the Update Statement.
I have ran this type of code several times with never a problem. This seems really simple, but I just can't seem to get it to compute.
Any help would be greatly appreciated.
Regards,
bob sutor
Bob SutorYep--This statement is running in a Stored Procedure and inside its own block statement.
I did get a response that suggested I change the SET statement as follows, that worked:
AllocPercent
= CASE WHEN AllocBase IS NULL OR AllocBase = 0 THEN 0.00 ELSE cast(PM_Input*1.0/AllocBase*1.0
as decimal(6,2)) END
Your response did get me thinking which was great! I appreciate your help.
Regards,
...bob sutor
Bob Sutor -
SUM(CASE WHEN statement is not returning proper result.
Hi Folks,
I'm an end-user on OBIEE 11g creating a custom analysis. I'm trying to SUM a particular case statement: SUM(CASE WHEN "MyMeasureColumn.Here" LIKE '%~25~%' OR "MyMeasureColumn.Here" LIKE '%~26~%' OR "MyMeasureColumn.Here" LIKE '%~27~%' OR "MyMeasureColumn.Here" LIKE '%~28~%' THEN 1 ELSE 0 END)
The result should be about 6,700 however I am getting only 1,900. Any ideas?>
Ive done a manual validation of the statement (in excel) and know its near 6700. I think it has something to do with the type of data it is?
>
Well there are only three possibilities that I can think of.
1. The data in Excel is different than the data in Oracle
2. The 'manual validation' is different than what the query that you are using does
3. Both #1 and #2
You are the only one with access to the data.
You are the only one that has any idea what your 'manual validation' was.
If necessary you will need to use the brute force 'divide and conquer' method.
Use a small amount of data and compare your 'manual validation to your query results. If they are not the same figure out why.
If they are the same then repeat the process with another set of the data. -
SQL CASE statement in XML template- End tag does not match start tag 'group
Hi All,
I am developing a report that has the SQL CASE statement in the query. I am trying to load this into RTF with report wizard and it gives me below error
oracle.xml.parser.v2.XMLParseException: End tag does not match start tag 'group'
Does XML publisher support CASE statement?
My query is something like this
SELECT customercode,
SUM(CASE WHEN invoicedate >= current date - 30 days
THEN balanceforward ELSE 0 END) AS "0-30",
SUM(CASE WHEN invoicedate BETWEEN current date - 60 days
AND current date - 31 days
THEN balanceforward ELSE 0 END) AS "31-60",
SUM(CASE WHEN invoicedate < current date - 60 days
THEN balanceforward ELSE 0 END) AS "61>",
SUM(balanceforward) AS total_outstanding
FROM MyTable
GROUP BY customercode
ORDER BY total_outstanding DESC
Please advice if the CASE statement or the double quotes are causing this error
Thanks,
PPI got this to work in the XML but the data is returning zeros for all the case statements. When I run this in toad I get results for all the case conditions but when ran in XML the data displayed is all zeros. I am not sure what I am missing. Can someone shed some light on this please
Thanks!
PP -
CASE not found while executing CASE statement on Submit Form
Hi to all APEX users and developers.
I have several APEX applications and they are all working well, but recently I got one strange exception when I try to submit page:
Session: Fetch session header information
...metadata, fetch page info
...Validate item page affinity.
...Validate hidden_protected items.
Add error onto error stack
...Error data:
......message: Error processing request.
......additional_info: ORA-06592: CASE not found while executing CASE statement
......display_location: ON_ERROR_PAGE
......is_internal_error: true
......apex_error_code: APEX.UNHANDLED_ERROR
......ora_sqlcode: -6592
......ora_sqlerrm: ORA-06592: CASE not found while executing CASE statement
.....error_backtrace: ORA-06512: at "APEX_040100.WWV_FLOW", line 9273
......component.type: APEX_APPLICATION_AUTH
......component.id: 41350431648668800
......component.name: MNRFR
...Show Error on Error Page
......Performing rollback
Processes - point: AFTER_ERROR_HEADER
Processes - point: BEFORE_ERROR_FOOTER
End Page Processinga
Page has more than 120 items (most of them are hidden), so my first thought is that page has problem with posting so many items, but APEX error message doesn't hel me at all. Any help would be very appreciated :)
AlmirHi Almir,
actually it is the 100 page item limit. See (http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/limits.htm)
I also had a look into the source code and the code at the position where the error gets raised only supports 100 page items.
Can you have a look into the generated HTML code and look if you have a page items which is mapped to p_t101 or a higher number ?
I will file a bug to show a better error message.
Regards
Patrick
My Blog: http://www.inside-oracle-apex.com
APEX Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf
Maybe you are looking for
-
Error while saving PO in me21n
Dear all when i creating PO i am giving some vendor code ,name , but this details is getting changed after saving PO . showing some other vendor code ,name and date and finally throwing error "express document update was terminated received from au
-
Checking balances with asset register and Trial balance
Hi , Need to develop a report for checking balance with asset register and Trial balance. Now asset balances and TB is not matching. We need report at Plant level. pls suggest Regards
-
My D7560 printer has low color ink levels, but full black ink levels and will not allow any "black only" printing jobs. An error message appears and states to shut down and restart the printer. When following those directions, the same message appea
-
How can I get reader 11 to read out loud?
-
What happened to the service in southeast georgia?
I live between Statesboro and Savannah in Georgia. Within the last 2 weeks our signal strength has gone down to nothing (multiple phones so it's not a phone issue). We have nearly "full bars" prior to that. Now it's good to get 1.