How to use case to replace the & in select statement
Oracle version : 11.1.0.6.0
RHEL
Hi,
I want to get a list of all expired and locked users but want to replace the "&" with and here is my code but it isn't working.
Please some guidance, thanks.
SQL> select username,
2 case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
3 ELS 'no locked users'
4 end) account_status
5 from dba_users
6 where account_status like 'EXPI%';
case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
ERROR at line 2:
ORA-00907: missing right parenthesis
798188 wrote:
thanks for the comments I corrected the ELSE and 'EPX%' but still same error :
EOH> select username,
2 case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
3 ELSE 'no locked users'
4 end) account_status
5 from dba_users
6 where account_status like 'EXP%';
case (account_status like 'EXP%' then 'EXPIRED AND LOCKED'
ERROR at line 2:
ORA-00907: missing right parenthesisFirst of all, you do not need a CASE statement.
Did you see the where clause of your query??
6 where account_status like 'EXP%';do you realise that your query will always return those records for which value of account_status column starts with 'EXP'?
Why use CASE when it could be simply written like this :
SELECT username,
'EXPIRED AND LOCKED'
FROM dba_users
WHERE account_status LIKE 'EXP%'
Similar Messages
-
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
How to use column name as variable in select statement
hi,
i want to make a sql query where in select statement using variable as a column name. but its not working plz guide me how can i do this.
select :m1 from table1;
regardsHi,
Is this what you want..
SQL> select &m1 from dept;
Enter value for m1: deptno
old 1: select &m1 from dept
new 1: select deptno from dept
DEPTNO
10
20
30
40
SQL> select &m1 from dept;
Enter value for m1: dname
old 1: select &m1 from dept
new 1: select dname from dept
DNAME
ACCOUNTING
RESEARCH
SALES
OPERATIONS
SQL> select &&m1 from dept;
Enter value for m1: loc
old 1: select &&m1 from dept
new 1: select loc from dept
LOC
NEW YORK
DALLAS
CHICAGO
BOSTON
SQL> select &&m1 from dept;
old 1: select &&m1 from dept
new 1: select loc from dept
LOC
NEW YORK
DALLAS
CHICAGO
BOSTONIf you use single '&' then each time you fire the query, It will ask for the new value..
But if you will use double '&&' the value of m1 will be persistent across the session..
Twinkle -
How to use case when function to calculate time ?
Dear All,
May i know how to use case when function to calculate the time ?
for the example , if the First_EP_scan_time is 12.30, then must minus 30 min.
CASE WHEN FIRSTSCAN.EP_SHIFT <> 'R1' AND FIRSTSCAN.EP_SHIFT <> 'R2'
THEN ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF((CASE WHEN SHIFTCAL.EP_SHIFT = 'N1'
THEN CONVERT(VARCHAR(8),DATEADD(DAY,+1,LEFT(FIRSTSCAN.EP_SCAN_DATE ,8)),112) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','')
ELSE LEFT(FIRSTSCAN.EP_SCAN_DATE ,8) + ' ' + REPLACE(CONVERT(VARCHAR(8),DATEADD(HOUR,+0,SHIFTDESC.EP_SHIFT_TIMETO + ':00'),108),':','') END),12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0 - 0.25) AS FLOAT),2)
ELSE ROUND(CAST((DATEDIFF(MINUTE,CAST(STUFF(STUFF(FIRSTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME),CAST(STUFF(STUFF(LASTSCAN.EP_SCAN_DATE,12,0,':'),15,0,':') AS DATETIME)) / 60.0) AS FLOAT),2) END AS OTWORK_HOURDo not use computations in a declarative language. This is SQL and not COBOL.
Use a table of time slots set to one more decimal second of precision than your data. You can now use temporal math to add it to a DATE to TIME(1) get a full DATETIME2(0). Here is the basic skeleton.
CREATE TABLE Timeslots
(slot_start_time TIME(1) NOT NULL PRIMARY KEY,
slot_end_time TIME(1) NOT NULL,
CHECK (start_time < end_time));
INSERT INTO Timeslots --15 min intervals
VALUES ('00:00:00.0', '00:14:59.9'),
('00:15:00.0', '00:29:59.9'),
('00:30:00.0', '00:44:59.9'),
('00:45:00.0', '01:00:59.9'),
('23:45:00.0', '23:59:59.9');
Here is the basic query for rounding down to a time slot.
SELECT CAST (@in_timestamp AS DATE), T.start_time
FROM Timeslots AS T
WHERE CAST (@in_timestamp AS TIME)
BETWEEN T.slot_start_time
AND T.slot_end_time;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How do i find or replace the missing disk image for my HD
How do i find or replace the missing disk image? for my HD ........as it is missing when i try to back up with time machine,
i asked for assistance the other day with time machine
now i have worked out this is the reason i can not back up with TM, due to no disk image in my portable hard drive
I saw a post on youtube where it explains you can copy a your HD disk imag from your time machine back ups enabeling, time machine to back up
But i can not find where the TM Back up driver is situated in my TM Back up's
Some advice would be greatly appreceate as i am rather new to Mackintosh
Thank you
AidenHi again.
Just re-reading your first post, I wonder if you're confusing a disk image backup with Time Machine?
It's certainly possible to create a disc image of your Macintosh HD and copy it to an external drive.
However, as a backup that method has a drawback; you can't boot from a disc image directly. It needs to be mounted on a bootable system before it can be used. So it's not really much use if the internal HD fails, at least as far as allowing you to carry on working while the repair is carried out.
Much better (and simpler) is to clone the whole drive to the external using CarbonCopyCloner or SuperDuper (there are plenty of others, but those appear to be the most popular).
That will give you a bootable backup which can be kept up to date by incremental backups using the same applications.
In the event of total internal HD failure all you need to do is replace the drive then boot from the clone and reverse clone to the internal to get up and running again.
Many of us use both a bootable clone and Time Machine (on seperate drives) as each has it's different uses. -
How to use bind variables in the following query
CREATE OR REPLACE PROCEDURE MMDB.test IS
sel_qtn VARCHAR2 (10);
CURSOR PT_QUANTITY IS select * from mmdb.product_tree WHERE QUANTITY_CHECK ='E'
AND run_id = 100
a PT_QUANTITY%ROWTYPE;
BEGIN
FOR i IN PT_QUANTITY
loop
sel_qtn := i.quanttity-1;
While sel_qtn>=1
loop
insert into mmdb.product_tree (BILLING_ACCOUNT_NO ,S_CODE) values (i.BILLING_ACCOUNT_NO ,i.S_CODE||'E');
sel_qtn :=sel_qtn -1;
End loop;
commit;
end;Don't duplicate threads: How to use bind variables in the following query
-
How to use case function in where clause
Hi,
Suppose a table DEMO has columns
DEMO TABLE
user_id
user_name
location
In this table i have 15 users. but out of 15 users i want to use only 5 users for passing as user_name.
then how to achieve the result
1. when i pass the particular 5 user_name in where clause then i should get all the user_name and for other 10 users it will show only the passing user_name.
how to use case functionDo you mean this ?
SQL> var name varchar2(10)
SQL> exec :name := 'ALLEN'
PL/SQL procedure successfully completed.
SQL> select ename from emp where case when :name in ('SMITH','ALLEN') then ename
2 else :name end = ename;
ENAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
14 rows selected.
SQL> exec :name := 'SMITH'
PL/SQL procedure successfully completed.
SQL> select ename from emp where case when :name in ('SMITH','ALLEN') then ename
2 else :name end = ename;
ENAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
14 rows selected.
SQL> exec :name := 'BLAKE'
PL/SQL procedure successfully completed.
SQL> select ename from emp where case when :name in ('SMITH','ALLEN') then ename
2 else :name end = ename;
ENAME
BLAKERgds. -
How to use CASE statement in WDA
Hi All,
Can any one Please expain me ' How to use CASE statement in Web dynpro ABAP? '
Please give me an example also.
Thanks in Advance !Hi,
The usage of case statement in webdynpro is same as used in general ABAP.
Data: l_id type string.
l_id = wdevent->get_string( 'ID' ).
case l_id.
when 'BTN1'.
when 'BTN2'.
when 'OTHERS'.
endcase.
Regards,
Radhika. -
How to use CASE stmt in Where clause
Hi,
How to use CASE stmt in WHERE clause?. I need the code. Please send me as early as possible..........Hi,
1004977 wrote:
Hi,
How to use CASE stmt in WHERE clause?. There's no difference between how a CASE expression is used in a WHERE clause, and how it is used in any other clause. CASE ... END always returns a single scalar value, and it can be used almost anywere a single scalar expression (such as a column, a literal, a single-row function, a + operation, ...) can be used.
CASE expressions aren't needed in WHERE clauses very much. The reason CASE expressions are so useful is that they allow you to do IF-THEN-ELSE logic anywhere in SQL. The WHERE clause already allows you to do IF-THEN-ELSE logic, usually in a more convenient way.
I need the code.So do the peple who want t help you. Post a query where you'd like to use a CASE expression in the WHERE clause. Post CREATE TABLE and INSERT statements for any tables used unless they are commonly available, such as scott.emp). Also, post the results you want from that sample data, and explain how you get those resuts from that data.
See the forum FAQ {message:id=9360002}
Please send me as early as possible..........As mentioned bfore, that's rude. It's also self-defeating. Nobody will refuse to help you because you don't appear pushy enough, but some people will refuse to help you if you appear too pushy. -
How can I remove or replace the " Java coffee cup " icon ???
I'd like to ask everybody some questions about the " Java coffee cup " icon
doesn't JToolbar be able to pull out of Frame?
but the JToolbar which was pulled out would have a little Java coffee cup icon
just like JOptionPane,JDailog or JFrame.
Is there any solution to remove this icon??
equally....
How can I remove or replace the little Java coffee cup icon of the title in
JDialog or JOptionPane??
Taking JFrame for instance, if I use "this.setIconImage(xxxxxxx);" then I can
change the little Java coffee cup icon.
but it seemed invalid to use it in JDialog.
How can I solve it in JToorbar,JDailog and JOptionPane ???
my e-mail : [email protected]this seems to be to most asked question at least in this forum.... only topped by the question about 'how to make an exe out of java apps' in the Java Programming Forum.
Sorry, but is there anybody who has noticed those useful textboxes where it says 'Search'? I mean before there were computers one had to go to a library, ask somebody or perform extensive research until answers were found. Or one had to buy books only to find out the the other book he though about buying would have been better.
Nowadays, simply type somthing like 'coffe cup' into a place where it is possible to do so and click into a region where it says 'Search' somewhere. Not even necessary to go to a froum like this and swamp it with the one trillionth version of this question, almost any search box might bring an answer (let it be right or not..).
Although I have to admit that this instance is the most prosaic and least understandable one I have seen for long...
Again sorry but I had to say that. -
I bought iMac 27 quad core i7 last June. Last month i have noticed lots of dark patches on the screen and now they are growing more. i bought this from US but now i have moved to Kuwait. How much it cost to replace the screen?
Mac and Mac models are picky about the RAM the Mac needs to see and use.
As you have found out, the 1067 speed RAM will not work in your year and model iMac.
You need the 1333 speed RAM.
If, you can return the RAM for a refund, do it!
If not, try online Mac RAM source and seller Crucial memory. They have a table that matches your Mac to the correct and reliable RAM. You may need to contact them to see whether or not they ship to South Africa, though.
If Crucial dpesn't work out, here's the specs for your year and model iMac that you need to seek out and purchase.
Maximum Memory
32 GB (Actual) 16 GB (Apple)
Memory Slots
4 - 204-pin PC3-10600 (1333 MHz) DDR3 SO-DIMM
Good Luck! -
Any one knows how to use Axis Framework in the SOAP Adapter Modules
How to use Axis Framework in the SOAP Adapter?
How to add custom handler modules?
http://help.sap.com/saphelp_nw04/helpdata/en/45/a4f8bbdfdc0d36e10000000a114a6b/frameset.htm
I went through the above link on help.sap.com. But still could not create a working example.
I have created a wc on some 3ed party app server using apaches axis. I am trying to call that web service from XI using SOAP receiver? I need to add some security related headers to the soap message, SO I am trying to use a handler. I want to know how to configure this handler in SOAP axis adapter module.
Thank you
MoniRavi ,
I am trying exactly the same. Hers is the scenario.
ABAP Proxy --> PI (7.0) SP 12 ---> WebService.
Since This is service is secured, means it is using OASIS web servie securyty user name token,
I am trying to use AXIS adapter. and I want to configure HandlerBean in which I want to use apache wss4j api to add the userNameToken. I am looking for some documentation on this.
I need to add SOAP action element too as I can not configure this one on the communication channel.
Thanks for any inputs in this regard.
Moni -
How to use SQL functions in the queries
hey guys i wanna know how to use SQL functions in the queries is it possible or not .
Hi,
Wat exactly that set values are?
those from sql query?
How to use count():
The COUNT() function returns the number of rows that matches a specified criteria.
SQL COUNT(column_name) Syntax
The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:
SELECT COUNT(column_name) FROM table_name
SQL COUNT(*) Syntax
The COUNT(*) function returns the number of records in a table:
SELECT COUNT(*) FROM table_name
SQL COUNT(DISTINCT column_name) Syntax
The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column:
SELECT COUNT(DISTINCT column_name) FROM table_name
The IN function helps reduce the need to use multiple OR conditions.
The syntax for the IN function is:
SELECT columns
FROM tables
WHERE column1 in (value1, value2, .... value_n); -
In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
1. The report has the following group settings:
Parent Group: SalesTerritoryGroup
Child Group: SalesTerritoryCountry
Child Group: CalendarYear
Details: SalesAmount
2. Add three parameters in the report:
GroupExpand:
Available Values: “Specify values”
Label: Yes Value: Yes
Label: No Value: No
Default Values: “Specify values”
Value: Yes
CountryExpand:
Available Values: “Specify values”
Label: Yes Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
Label: No Value: No
Default Values: “Specify values”
Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
YearExpand:
Available Values: “Specify values”
Label: Yes
Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
Label: No Value: No
Default Values: “Specify values”
Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
=IIF(Parameters!GroupExpand.Value="Yes", False, True)
Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
=IIF(Parameters!CountryExpand.Value="Yes", False, True)
=IIF(Parameters!YearExpand.Value="Yes", False, True)
6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
=IIF(Parameters!GroupExpand.Value="Yes", True, False)
7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
=IIF(Parameters!CountryExpand.Value="Yes", True, False)
=IIF(Parameters!YearExpand.Value="Yes", True, False)
After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
Note:
In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
Applies to
Reporting Services 2008
Reporting Services 2008 R2
Reporting Services 2012In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
1. The report has the following group settings:
Parent Group: SalesTerritoryGroup
Child Group: SalesTerritoryCountry
Child Group: CalendarYear
Details: SalesAmount
2. Add three parameters in the report:
GroupExpand:
Available Values: “Specify values”
Label: Yes Value: Yes
Label: No Value: No
Default Values: “Specify values”
Value: Yes
CountryExpand:
Available Values: “Specify values”
Label: Yes Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
Label: No Value: No
Default Values: “Specify values”
Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
YearExpand:
Available Values: “Specify values”
Label: Yes
Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
Label: No Value: No
Default Values: “Specify values”
Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
=IIF(Parameters!GroupExpand.Value="Yes", False, True)
Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
=IIF(Parameters!CountryExpand.Value="Yes", False, True)
=IIF(Parameters!YearExpand.Value="Yes", False, True)
6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
=IIF(Parameters!GroupExpand.Value="Yes", True, False)
7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
=IIF(Parameters!CountryExpand.Value="Yes", True, False)
=IIF(Parameters!YearExpand.Value="Yes", True, False)
After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
Note:
In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
Applies to
Reporting Services 2008
Reporting Services 2008 R2
Reporting Services 2012 -
I need to program a Hittite Fractional-N Synthesizer Evaluation Kit with a HMC702LP6CE an external YIG oscillator. Not sure how to use Labview to control the PLL.
Here is how to use the PLL. But I don't know of how to interact with that device
http://zone.ni.com/devzone/cda/tut/p/id/3781
And for thouse who don't know what a PLL is a free bonus link is here:
http://digital.ni.com/public.nsf/allkb/07BC8D77D4E9AE258625708B007CE74F?OpenDocument
and a second one on what that device is: http://www.hittite.com/products/view.html/view/HMC702LP6CE
Now we are all caught up to speed.
Sam S
Applications Engineer
National Instruments
Maybe you are looking for
-
How do I swap a symbol on each keyframe of my animation ?
Hello, I have a VERY big animation, with a huge amount of keyframes, and I like to swap a symbol in this animation with another one. If I just use the swap button on the first frame, Flash only swaps the symbol for the first tween, whereas I have hun
-
8/20/2014 - Beta - Flash Player 15.0.0.130
The latest Flash Player 15 beta builds are now available. Beta builds can be downloaded from labs.adobe.com. New Features for Flash Player 15: Relaxing Stage3D Render Target Clear In previous versions of Stage3D, after switching the render texture th
-
Is it possible to control which columns are read-only in a specific row on a treetable?
-
URGENT Check this code for me please
Dear whoeverthisreads, please read and see at the bottom my sourcecode, or whatever I could make of it until (even with help) I failed to see any solution. Please copy, paste and run to see if you can manage to adjust the program to make it work in t
-
Settings Mail Autocheck replaced by Settings Fetch New Data on 3g?
Hi, I was wondering if anyone can confirm that the 3g iPhone no longer has the "Auto-Check" function listed in Settings>Mail (above the Show, Preview etc fields; I don't see "Auto-Check" here like some user guides I have seen have indicated). Assumin