Case in Select Statement - Ramya
Hi All,
Could any body help me out ,how to use the CASE in select Statement
Thanks in Advance
here is an example:
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2975 1000 20
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> select empno,
2 ename,
3 job,
4 case when job = 'PRESIDENT' then 1
5 when job = 'MANAGER' then 2
6 when job = 'SUPERVISOR' then 3
7 else 4
8 end rank
9 from emp;
EMPNO ENAME JOB RANK
7566 JONES MANAGER 2
7902 FORD ANALYST 4
7839 KING PRESIDENT 1
7698 BLAKE MANAGER 2
7782 CLARK MANAGER 2
7369 SMITH CLERK 4
7499 ALLEN SALESMAN 4
7521 WARD SALESMAN 4
7654 MARTIN SALESMAN 4
7788 SCOTT ANALYST 4
7844 TURNER SALESMAN 4
7876 ADAMS CLERK 4
7900 JAMES CLERK 4
7934 MILLER CLERK 4
14 rows selected.
SQL>
Similar Messages
-
Use of Case in Select statement
Hi All,
Can anyone tell me whats wrong im doing in the following select statement. I am selecting most this fields from Global Temperory Table and few from normal DB tables.
select h.Taskid,h.Flowid,fd.DESCRIPTION Flowname,h.Stepid, sd.DESCRIPTION Stepname,h.Lockby,ud.USERNAME,h.Status,case Date_initiated when (Currval.Testid = Nextval.Testid) Then Date_initiated := NULL Else Date_initiated := Date_initiated End case,case UserTime When ((Currval-1).Testid IS NULL or Currval.Testid <> (Currval-1).Testid) Then UserTime := StartTime When (Currval.Testid = (Currval-1).Testid or Currval.Testid <> Nextval.Testid or Nextval.Testid IS NULL) Then UserTime = (Currval-1).Endtime End case,case StartTime When(Currval.Stepid = Nextval.Stepid or Currval.Stepid=9999) Then StartTime := NULL Else StartTime := StartTime End case,h.EndTime,h.LockTime,h.Drawer,h.FileNo,h.DocType from GlobalTempTest h inner join USERDEFINITION ud on h.Lockby=ud.USERID inner join FLOWDEFINITION fd on h.Flowid=fd.FLOWID inner join STEPDEFINITION sd on (h.Stepid=sd.STEPID and h.Flowid=sd.FLOWID)
Hope so get some response soon.
Thanks in AdvanceYou have to rewrite your code like this:
CASE WHEN (Currval.Testid = Nextval.Testid) THEN NULL
ELSE Date_initiated
END New_Date_initiatedCurrval/Nextval as shown in your example will not work. Please explain what you mean by previous value comparison.
C. -
Switch case in select statement
I have got the following message, while executing the SQL Query. Appreciate any help pointing what is wrong...
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'CASE'.
SELECT TOP 1 UP.DATAID, UP.START_TIME, datediff(day, UP.START_TIME, getutcdate()) as DayGap
CASE DayGap
WHEN 0
THEN 'SAME DAY'
WHEN > 0
THEN 'new record'
ELSE 'other'
END as FinalRe
FROM MTP.USERPROGRESS as UP
where UP.MDATAID = 575 AND UP.LSTATUS = 2
tried the following also, but no luck
SELECT TOP 1 DATAID, START_TIME, datediff(day, START_TIME, getutcdate() as DayGap
SWITCH((datediff(day, START_TIME, getutcdate()) = 0)'ITSZERO', (datediff(day, START_TIME, getutcdate()) > 0)'GT1', TRUE, 'n')
FROM MTP.USERPROGRESS
where MDATAID = 575 AND LSTATUS = 2SELECT TOP 1 UP.DATAID, UP.START_TIME, datediff(day, UP.START_TIME, getutcdate()) as DayGap,
CASE when DayGap =0
THEN 'SAME DAY'
WHEN DayGap > 0
THEN 'new record'
ELSE 'other'
END as FinalRe
FROM MTP.USERPROGRESS as UP
where UP.MDATAID = 575 AND UP.LSTATUS = 2
-Prashanth -
Hello,
in Oracle8 I've the following problem:
The statement
SELECT ''' | ''||' || 'rpad'
|| '(''' || column_name
|| ''',' ||
(CASE WHEN (data_type = 'VARCHAR2' AND
data_length > 50) THEN
to_number('50')
WHEN (data_type = 'CHAR' AND
data_length > 50) THEN
to_number('50')
WHEN (data_type = 'CLOB' AND
data_length > 50) THEN
to_number('50')
WHEN (data_type = 'DATE' AND
data_length != 19) THEN
to_number('19')
ELSE
data_length
END )
|| ', '' '')||' AS column_name
FROM dba_tab_columns
WHERE
table_name = upper('DBA_TABLES') AND
owner = upper('SYS')
ORDER BY column_id;
works fine but defining the same statement as a cursor in a PL/SQL Procedure, I got a
Error: PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
( - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>
The same procedure can be compiled in Oracle9i without errors.
Does anybody know if there are any restrictions using CASE statements in a PL/SQL CURSOR in Oracle8?
Thanks
PatricHi,
I am encountering the same problem.
Can u suggest the decode statement used instead of case
for this select clause which uses the CASE statement ?
SELECT
CASE
WHEN S.cmpy_num = S.cpty_borg_num THEN
''OURS''
ELSE
''THEIRS''
END AS SDIOwner,
From TABLE -
Case sensitivity select statement without using native sql
please help me ,
i have a selection screen as select-options : s_vbeln, s_kunnr(mandt),s_matnr and
p_name as a parameter (type name1) which is case sensitive in sap abap database and i want to get
output from these fields in an alv.[vbeln,kunnr,name1,audat,auart,matnr,kwmeng,netwr]
How to do it? Can any one give me solution please.[i have to handle case sensitivity plz give me solution]this is my code : but its not working as i expected plz tell me where did i went wrong...
type-pools slis.
tables : vbak , vbap.
select-options : s_vbeln for vbak-vbeln,
s_kunnr for vbak-kunnr,
s_matnr for vbap-matnr.
parameters p_name1 type NAME1_GP.
ranges r_name for kna1-name1.
types : begin of ty_vbak,
vbeln type vbeln_va,
audat type audat,
auart type auart,
kunnr type kunnr,
end of ty_vbak,
begin of ty_vbap,
vbeln type vbeln_va,
matnr type matnr,
netwr type netwr_ap,
kwmeng type kwmeng,
end of ty_vbap,
begin of ty_kna1,
kunnr type kunnr,
name1 type name1,
end of ty_kna1,
begin of ty_final,
vbeln type vbeln_va,
audat type audat,
auart type auart,
matnr type matnr,
netwr type netwr_ap,
kwmeng type kwmeng,
kunnr type kunnr,
name1 type name1,
end of ty_final.
data : t_vbak type standard table of ty_vbak initial size 1,
t_vbap type standard table of ty_vbap initial size 1,
t_kna1 type standard table of ty_kna1 initial size 1.
data : t_final type standard table of ty_final initial size 1,
w_final type ty_final,
w_vbap type ty_vbap,
w_kna1 type ty_kna1,
w_vbak type ty_vbak.
data : t_fcat type slis_t_fieldcat_alv,
w_fcat type slis_fieldcat_alv.
DATA T_FINAL2 TYPE STANDARD TABLE OF TY_FINAL INITIAL SIZE 1.
data v_name1 type name1.
if p_name1 is not initial.
r_name-sign = 'I'.
r_name-option = 'EQ'.
if p_name1 ca '*'.
r_name-option = 'CP'.
endif.
r_name-low = p_name1.
append r_name.
endif.
start-of-selection.
select vbeln audat auart kunnr from vbak
into table t_vbak
where vbeln in s_vbeln and
kunnr in s_kunnr.
if sy-subrc <> 0.
message 'plz enter a valid entry' type 'I'.
leave list-processing.
endif.
if t_vbak[] is not initial.
select vbeln matnr netwr kwmeng from vbap
into table t_vbap
for all entries in t_vbak
where vbeln = t_vbak-vbeln and
matnr in s_matnr.
if sy-subrc <> 0.
message 'no rec found' type 'I'.
leave list-processing.
endif.
select kunnr name1 from kna1
into table t_kna1
for all entries in t_vbak
where kunnr = t_vbak-kunnr.
if sy-subrc = 0.
sort t_kna1 by kunnr.
endif.
endif.
end-of-selection.
loop at t_vbap into w_vbap.
read table t_vbak into w_vbak with key vbeln = w_vbap-vbeln binary search.
read table t_kna1 into w_kna1 with key kunnr = w_vbak-kunnr binary search.
w_final-vbeln = w_vbak-vbeln.
w_final-audat = w_vbak-audat.
w_final-auart = w_vbak-auart.
w_final-matnr = w_vbap-matnr.
w_final-netwr = w_vbap-netwr.
w_final-kwmeng = w_vbap-kwmeng.
w_final-kunnr = w_kna1-kunnr.
w_final-name1 = w_kna1-name1.
append w_final to t_final.
endloop.
delete t_final where name1 not in r_name.
perform sub_fill_fcat using 'VBELN' 'SALE ORDER NUM'.
perform sub_fill_fcat using 'KUNNR' 'CUSTOMER NUMBER'.
perform sub_fill_fcat using 'NAME1' 'NAME OF A CUST'.
perform sub_fill_fcat using 'AUDAT' 'SALE ORDER DATE'.
perform sub_fill_fcat using 'AUART' 'SALE DOC TYPE'.
perform sub_fill_fcat using 'MATNR' 'MATERIAL NUM'.
perform sub_fill_fcat using 'KWMENG' 'QUANTITY'.
perform sub_fill_fcat using 'NETWR' 'PRICE'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = T_FCAT
TABLES
T_OUTTAB = T_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
*& Form SUB_FILL_FCAT
* text
* -->P_0389 text
* -->P_0390 text
FORM SUB_FILL_FCAT USING P_FNAM P_TEXT.
clear w_fcat.
w_fcat-fieldname = p_fnam.
w_fcat-seltext_m = p_text.
append w_fcat to t_fcat.
ENDFORM. -
Hi friends, can any one give me the possible select statement which are used in Report query with some code examples
Hi,
SELECT
Syntax
SELECT result
FROM source
INTO|APPENDING target
[[FOR ALL ENTRIES IN itab] WHERE sql_cond]
Effect
SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
E.g.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT c~carrname p~connid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON p~carrid = c~carrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON f~carrid = p~carrid
AND f~connid = p~connid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Jogdand M B -
Case or decode in select statement for comparison
Hi,
How can I do a comparison
like
if sal < 50, output 1.1 * comm
if sal > 50 and < = 100 output 1.2 * comm
else output comm
in a single select statement.
I tried using case and decode but I am not sure how to use it in comparison operations.
Please helpuse the 'case' construct:
SELECT
NORMAL_FIELD
, (CASE
WHEN (SAL < 50) THEN 1.1 * COMM
WHEN (SAL > 50) AND (SAL <= 100) THEN 1.2 * COMM
ELSE COMM
END
) AS CALCULATED_COMM
FROM
TB_xxxx
WHERE xxxx
hope this helps -
Case sensitive statement in the select-statement
Hi All,
i have a table in the abap-dictionary filled with names...when i try to select them with the select-statement with condition:
table-name_column like 'some_name'
I have encountered some problems...the inquiry is case-sensitive. What i want to do is to read the value from the abap-dictionary table uppercase or lowercase and compare it with the needed value also translated in uppercase or lowercase.
The only idea i have is to select all values of the dictionary table into an internal table and to translate the values there in uppercase or lowercase and then to loop trough it. But this approach would cost a lot of performance.
Do someone has an other proposal?check...
Select statement
It would be difficult , because it is based on how data is stored in the data base , now consider the scenario of the system i am using , we can material description as 'test' or 'TEST' , 'Test' .
If in your system there are only stored in either caps or small the you can perform the select twice .
But i myself dont find it to be such a good solution , but you can give it a try
There is one more solution specific to material description ,and that is in the table MAKT there is a field MAKTG , which stored the description in uppercase , so for this you can first convert the description to uppercase and then perform select on this field -
Case sensitve in selection statement
Hi All
I like to write a select statement which is able to get the values irrespective of case sesitive
ie
select * from table_name where column_name like('%sun%')
selection of columns should happen even the column name is '%SUN%' or '%Sun%' ie '%sun%' should not be case sensitive....Can anyone suggest me query for this
Note: the query needs to work in oracel server. Also changing the session ie alter session set NLS_SORT=BINARY_CI ;
alter session set NLS_COMP=LINGUISTIC; cannot be done.
So please help me to get the selection purely through query
With thanks and regards
AnoopUse LOWER or UPPER,
so, for example:
lower(column_name) like '%sun%'
-- OR
upper(column_name) like '%SUN%' -
If statement in select statement alias
I have the following select statement. It has the alias Survivors, Deaths and "All Cases". Is it posible to use :P_LANGUAGE variable to say that -- IF :P_LANGUAGE = FRENCH THEN alias are Survivants for survivors, Décès for Deaths, Tous_les_cas for All Cases. Please advise
SELECT ALL T_NTR_MULTIBAR.CAT, T_NTR_MULTIBAR.NUM_CASES_LEFTBAR AS Survivors,
T_NTR_MULTIBAR.NUM_CASES_MIDDLEBAR AS Deaths, T_NTR_MULTIBAR.NUM_CASES_RIGHTBAR AS "All Cases"
FROM T_NTR_MULTIBAR
WHERE INSTANCE_NUM = :P_INSTANCENUM
order by ORDERSYou may not be able to add this condition inside the SQL Statement. But you can add this condition outside the statement, if you're using PL/SQL...
IF :p_language = french THEN
SELECT ALL t_ntr_multibar.cat,
t_ntr_multibar.num_cases_leftbar AS survivors,
t_ntr_multibar.num_cases_middlebar AS deaths,
t_ntr_multibar.num_cases_rightbar AS "All Cases"
ELSE
END IF; -
How to get all values from an interval using select statement
Hi,
Is it possible to write a select statement that returns all values from an interval? Interval boundaries are variable.
something like this:
select (for x in 1,1024 loop x end loop) from dual
(this, of course, doesn't work)
The result in this example should be 1024 rows of numbers from 1 to 1024. These numbers are parameters, so it is not possible to create a table with predefined values.
Thanks in advance for your help,
Mia.For your simple case, with a lower boundary of 1, you can use:
SELECT rownum
FROM all_objects
WHERE rownum <= 1024For a set of number between say 50 - 100, you can use something like:
SELECT rownum + (50 - 1)
FROM all_objects
WHERE rownum <= (100 - 50 + 1)Note, that all_objects was used only because it generally has a lot of rows. Any table with at least the number of rows in your range will work.
TTFN
John -
Left joins : Case or if statement
Hi
I want to know if one can build in a case or if statement into a left join. I want to multiply a value with -1 if the condition is met.I think it is not possible in SELECT statement...but you can do the below to resolve it.
add a field for FKART in your internal table.
TYPES: BEGIN OF tab ,
kunag LIKE vbrk-kunag,
fkdat like vbrk-fkdat,
matnr LIKE vbrp-matnr,
werks LIKE vbrp-werks,
fkart like vbrk-fkart,
volum LIKE vbrp-volum,
END OF tab.
DATA: wa_outtab TYPE table of tab WITH HEADER LINE.
SELECT akunag afkdat
bmatnr bwerks a~fkart
SUM( b~volum )
INTO table wa_outtab
FROM vbrk AS a
INNER JOIN vbrp AS b
ON avbeln = bvbeln
WHERE
avbeln = bvbeln
AND ( afkart LIKE 'F2' OR afkart LIKE 'RE' )
GROUP BY akunag afkdat bmatnr bwerks a~fkart.
sort wa_outtab.
Loop at wa_outtab.
if wa_outtab-fkart = 'RE'.
lpos = lpos + wa_outtab-volum.
else.
lneg = lneg + wa_outtab-volum.
endif.
at end of werks.
lvaule = lpos - lneg.
lpos = lneg = 0.
endat.
endloop. -
Using if logic in the where clause of a select statement
I have a select clause. And in the select clause there is a variable all_off_trt that can be 'Y' or 'N'.
In the where clause I want to make it so that if a form variable is checked and all_off_trt is 'Y' then
exclude it else if the form variable isn't checked then select it no matter what all_off_trt is.
Is there any way to include either and if statement or a case statement within the where clause to acheive this? If not is there another way of doing it?
Basically I am looking for a case statement like this
case
when all_off_trt = 'Y' and mail_para.code = 'Y' then false
else true
end
Message was edited by:
Tugnutt7Ok, so that really doesn't solve my problem. I have 3 different fields that I need to do that with. Each combining in a select statement to print an email list, as well as other thing limiting the where clause.
This is currently what I have, tested and working 100%.
cursor email_cur is
select unique p.email,s.all_off_trt,s.all_deceased,s.no_enroll
from participant p, trialcom t, ethics s
where p.status='A'
and p.surname=t.surname
and p.initials=t.initials
and s.trial_cd = t.tricom
and s.centre = t.centre
and p.email is not null
and (t.centre in (select code from mail_parameters where user_name=user and mail_para='CENTRE')
or 'XX' in (select code from mail_parameters where user_name=user and mail_para='CENTRE'))
and (t.tricom in (select code from mail_parameters where user_name=user and mail_para='TRIAL')
or 'XX' in (select code from mail_parameters where user_name=user and mail_para='TRIAL'))
and (t.role in (select code from mail_parameters where user_name=user and mail_para='ROLE')
or 'XX' in (select code from mail_parameters where user_name=user and mail_para='ROLE'))
and (p.country in (select code from mail_parameters where user_name=user and mail_para='COUNTRY')
or 'XX' in (select code from mail_parameters where user_name=user and mail_para='COUNTRY'))
and (t.represent in (select code from mail_parameters where user_name=user and mail_para='REPRESENT')
or 'XX' in (select code from mail_parameters where user_name=user and mail_para='REPRESENT'));
This is in a program unit that runs when a button is clicked. At the end of that I need to add on the 3 case statements that help further narrow down the selection of emails to be printed. Then it prints the emails selected from this statement into a file. So it has to be done right in the select statement. The three table variables are the all_off_trt, all_deceased, and no_enroll. The form has 3 checkboxes. One for each, that when checked (giving the variable associated with the checkboxes a value of 'Y') excludes all emails that have a 'Y' in the coresponding table variable. -
Select statement in a function does Full Table Scan
All,
I have been coding a stored procedure that writes 38K rows in less than a minute. If I add another column which requires call to a package and 4 functions within that package, it runs for about 4 hours. I have confirmed that due to problems in one of the functions, the code does full table scans. The package and all of its functions were written by other contractors who have been long gone.
Please note that case_number_in (VARCHAR2) and effective_date_in (DATE) are parameters sent to the problem function and I have verified through TOAD’s debugger that their values are correct.
Table named ps2_benefit_register has over 40 million rows but case_number is an index for that table.
Table named ps1_case_fs has more than 20 million rows but also uses case_number as an index.
Select #1 – causes full table scan runs and writes 38K rows in a couple of hours.
{case}
SELECT max(a2.application_date)
INTO l_app_date
FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
WHERE a2.case_number = case_number_in and
a1.case_number = a2.case_number and
a2.application_date <= effective_date_in and
a1.DOCUMENT_TYPE = 'F';
{case}
Select #2 – runs – hard coding values makes the code to write the same 38K rows in a few minutes.
{case}
SELECT max(a2.application_date)
INTO l_app_date
FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
WHERE a2.case_number = 'A006438' and
a1.case_number = a2.case_number and
a2.application_date <= '01-Apr-2009' and
a1.DOCUMENT_TYPE = 'F';
{case}
Why using the values in the passed parameter in the first select statement causes full table scan?
Thank you for your help,
Seyed
Edited by: user11117178 on Jul 30, 2009 6:22 AM
Edited by: user11117178 on Jul 30, 2009 6:23 AM
Edited by: user11117178 on Jul 30, 2009 6:24 AMHello Dan,
Thank you for your input. The function is not determinsitic, therefore, I am providing you with the explain plan. By version number, if you are refering to the Database version, we are running 10g.
PLAN_TABLE_OUTPUT
Plan hash value: 2132048964
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 324K| 33M| 3138 (5)| 00:00:38 | | |
|* 1 | HASH JOIN | | 324K| 33M| 3138 (5)| 00:00:38 | | |
| 2 | BITMAP CONVERSION TO ROWIDS | | 3 | 9 | 1 (0)| 00:00:01 | | |
|* 3 | BITMAP INDEX FAST FULL SCAN| IDX_PS2_ACTION_TYPES | | | | | | |
| 4 | PARTITION RANGE ITERATOR | | 866K| 87M| 3121 (4)| 00:00:38 | 154 | 158 |
| 5 | TABLE ACCESS FULL | PS2_FS_TRANSACTION_FACT | 866K| 87M| 3121 (4)| 00:00:38 | 154 | 158 |
Predicate Information (identified by operation id):
1 - access("AL1"."ACTION_TYPE_ID"="AL2"."ACTION_TYPE_ID")
3 - filter("AL2"."ACTION_TYPE"='1' OR "AL2"."ACTION_TYPE"='2' OR "AL2"."ACTION_TYPE"='S')
Thank you very much,
Seyed -
Using Select statement in IF condition?
hi all,
Can i use select statement in IF COndition in pl sql ?
eg like- if( select 1 from ASD) then
end if;There is no way to do any kind of select statement inside if conditions.
Why don't test simple cases like this first?
An example to show it.
SQL> begin
2 if exists (select 1 from dual) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if exists (select 1 from dual) then
ERRORE alla riga 2:
ORA-06550: line 2, column 5:
PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL
statement only
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
SQL> begin
2 if ( (select count(*) from dual) > 0 ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( (select count(*) from dual) > 0 ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternativ
ORA-06550: line 2, column 33:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
. , @ ; for <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus order partition start subpartition union where connect
SQL> begin
2 if ( 0 in (select count(*) from dual) ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( 0 in (select count(*) from dual) ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 12:
PLS-00405: subquery not allowed in this context
ORA-06550: line 2, column 2:
PL/SQL: Statement ignoredBye Alessandro
Maybe you are looking for
-
How do I Wipe the Hard Drive?
I want to get rid of an old iMac CRT that I have had since 2000 and need to make sure I wipe the hard drive clean of any personal information, etc. Are there any tried and tested methods to do this, short of removing it and destroying it with a hamme
-
HTTP Error 400 on Tomcat 5.0.28 and JAAS
Hi I have this problem every time I send an Authentication Request using JAAS. I've a login form and, after I send my request, LoginModule starts to process it. The problem is that, viewing the tomcat log output, the authentication goes well, but Tom
-
I have been using itunes on my computer for a long time and i just purchased an Ipad, but it itunes will not recognize it. how do i do that?
-
Mail keeps switching default account back
I understand that the way to choose your default mail account in Mail, is to drag the default mail saccount in the left pane, to the top of the list of mail accounts. So this is what I do. But often Mail decided to switch them, and put another one at
-
How can I convert a PDF file in my computer into a word document?
How Can I convert a PDF file in my computer into a Word Document?