REG:- SELECT STATEMENT IN IF CONDITION.
HI FRIENDS,
CAN V USE SELECT STATEMENT IN IF CONDITION LIKE....
IF (SELECT COUNT(EMPID) FROM EMPLOPYEE) > 1 THEN
UPDATE STATEMENT;
END IF;
PLEASE HELP.
--RAJNISH
Hi,
1. Hit the Caps Lock key hard in your key board.
2. Put your code between tags for better readability.
3. When you have a where clause, why do you want to go for if clause? as in
[code]
update <your_table> set <your_col> = <your_new_val>
where (select count(empid) from employee) > 1
[/code]
is logically equivalent to your
[code]
if (select count(empid) from employee) > 1 then
update statement;
end if;
[/code]
-Arun
Similar Messages
-
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 -
hi i have a problem.
i want to extract records from three fields in a table using select statement.after extraction.
if there is no records in the three fields i had to give another condition.can any body provide code for thisHI,
try with this
select field1 field1 field 1
from <tablename>
into itab1
where
condition1...
now u check for
if sy-subrc ne 0. OR itab1[] is initial.
select field1 field1 field 1
from <tablename>
into itab1
where
condition1...
condition2...
endif.
If i am not clear ... reply back
Santhosh -
Select statement with if condition in cursors
Create procedure test (t1 in varchar2 ,t2 out varchar2)
IS
BEGIN
IF t1 = 'E'
select ENO INTO t2 from emp ;
elsif t1 = 'D'
select DNO INTO t2 from dept ;
end if;
end
how do i write this using cursorsi think i have to go for two cursors Intially i have written like the below codeThis requirement merely made me think of a pure SQL solution - something interesting...
As I mentioned, you likely should be using ref cursors as typically this requirement extends to a client that wants to make a call to Oracle without needing to know SQL or table names, pass parameters, and get a dynamic "+result set+" in response.
In Oracle. this is done using ref cursors. The code will look something like this"
{code}
create or replace procedure FooProc( someVar1 varchar2, someVar2 number, curResult OUT sys_refcursor ) is
begin
case
when someVar1 = someValueA then
open curResult for select * from emp;
when someVar1 = someValueB then
open curResult for select * from emp where empid = someVar2;
.. etc ..
end case;
end;
{code}
This is pretty straight forward stuff - and well explained with examples in the Oracle® Database PL/SQL User's Guide and Reference (http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref139)
You procedure it a tad different in output parameters (and not what one typically would get in a production system), but the concept is the same. If the SQL projection is the same for each cursor, you can use a ref cursor as above - and then simply code a single fetch to get the row's columns, close the cursor, and then return that column values as output parameters.
Edited by: Billy Verreynne to fix the broken Jive s/w that does not understand how to parse a link and show it correctly.. (am getting more and more peeved at the crappiness factor of the new forum s/w) -
Select statement for ms-access
hi, can u tell me how to write select statement with the condition. if the condition satisfies, insert values given in the front panel. if it doews not,it should not modify the old values to new values given.
its very urgent.
Thanks in Advance
Regards
Soundaryaduplicate post -- continue here
-
Select statement in if/else condition
Hi i need to write a select statement in the if condition in pl/sql how can i write this
example :
if field_name not in (select statement) then
Is this type of if condition is possible in pl/sql?
thanks in advance for help.Qwerty wrote:
here pick a job example salesman for ename ward, now i want to compare this job that is "salesman" with all the jobs which are before it. that is clerk in line 1 and salesman in line 2Define "before it". There is no order in relational tables. Only ORDER BY means ordered sets. Therefore there is no before/after without ORDER BY. Assuming ORDER BY empno, job count of same job title before empno:
select ename,
job,
count(*) over(partition by job order by empno) - 1 same_job_count_before_empno
from emp
ENAME JOB SAME_JOB_COUNT_BEFORE_EMPNO
SCOTT ANALYST 0
FORD ANALYST 1
SMITH CLERK 0
ADAMS CLERK 1
JAMES CLERK 2
MILLER CLERK 3
JONES MANAGER 0
BLAKE MANAGER 1
CLARK MANAGER 2
KING PRESIDENT 0
ALLEN SALESMAN 0
ENAME JOB SAME_JOB_COUNT_BEFORE_EMPNO
WARD SALESMAN 1
MARTIN SALESMAN 2
TURNER SALESMAN 3
14 rows selected.To find job count of same job title as Ward has before Ward (by empno):
SELECT same_job_count_before_empno
FROM (
select ename,
count(*) over(partition by job order by empno) - 1 same_job_count_before_empno
from emp
WHERE ename = 'WARD'
SAME_JOB_COUNT_BEFORE_EMPNO
1SY. -
1 Conditional report based on 3 select lists/ 3 different select statements
I have made 1 report based on the three select lists. The report is displayed in the center of the page. The user needs to fill them in order, the select lists are:
Selectlist:
1. P1_LOVPG - Null is allowed, but is only appearing at top with a label of Productgroup
2. P1_LOVSG - Null is allowed, but is only appearing at top with a label of Subgroup
3. P1_LOVMA - Null is allowed, but is only appearing at top with a label of Manufacturer
LOVPG contains a distinct collect of the ProductGroups
QUERY LOV = select distinct pg from X
LOVSG contains a distinct collect of the SubGroups inside the selected PG.list
QUERY LOV = select distinct sg from X where pg = :P1_LOVPG
LOVMA contains a distinct collect of the Manufacturers inside the selected SG.lst
QUERY LOV = select distinct ma from X where sg = :P_LOVSG
Based on the the selected items the user would see the following:
Table X
PG SG MA ART
A-----X----M---1
A-----X----N---2
A-----Y----M---3
A-----X----M---4
B-----X----M---5
B-----Y----N---6
B-----Z----O---7
Seletion 1 PG = A -> selects PG A in select list result, User sees:
Report A
PG SG MA ART
A-----X----M---1
A-----X----N---2
A-----Y----M---3
A-----X----M---4
Query would be: select * from X where PG = :P1_LOVPG
Selection 2, user still sees the above, can only select from the SG select list NULL, X, Y. User needs to choose between X or Y value. He picks X, he sees:
Report B
PG SG MA ART
A-----X----M---1
A-----X----N---2
A-----X----M---4
Query would be: select * from X where PG = :P1_LOVPG and SG = :P_LOVSG
Selection 3, user still sees selection 2 on his screen, can only select from the MA list bewteen NULL, M or N, user needs to choose between M or N. He picks M, he sees:
Report C
PG SG MA ART
A-----X----M---1
A-----X----M---4
Query would be: select * from X where PG = :P1_LOVPG and SG = :P_LOVSG
As you can see the query changes as the user goes deeper into the structure. It is a simple if then else system where the quey changes. How do I set this up in htmldb?
(I've read something about Oracle's SQL and it's decode function, but can they be used with changing select statements?)are you sure your data meets the JOIN conditions?
You can make a quick check.. only example...
select single * from KONP into ls_konp
where knumh = P_knumh.
if sy-subrc eq 0.
select * from from A905 into table lt_a905 where
kappl in so_kappl
and kschl in so_kschl
and VKORG in so_vkorg
and vtweg in so_vtweg
and kondm in so_kondm
and wkreg in so_wkreg
and knumh = ls_konp-knumh.
if sy-subrc eq 0.
select * from A919 into table lt_a919
for all entries in lt_a905
where kappl = lt_a905-kappl
and kschl = lt_905-kschl
and knumh = lt_905-knumh.
endif.
endif. -
Field symbols as Table name and in where condition in a select statement
Hello All,
I have a scenario where I need to get user input on table name and old field value and new field value. Then based on user input, I need to select the record from the database. The column name for all the tables in question is different in the database, however there data type is the same and have same values.
I am not able to use a field symbol for comparing the old field value to fetch the relevant record in my where clause.
I cannnot loop through the entire table as it has 10 millilon records, please advice on how to add the where clause as field symbol as the table name is also dynamically assigned.
Here is my code:
DATA: TAB LIKE SY-TNAME,
TAB_COMP1 LIKE X031L-FIELDNAME,
TAB_COMP2 LIKE X031L-FIELDNAME,
NO_OF_FLD TYPE N.
DATA: BEGIN OF BUFFER,
ALIGNMENT TYPE F,
C(8000) TYPE C,
END OF BUFFER.
FIELD-SYMBOLS: <WA> TYPE ANY,
<COMP1> TYPE ANY,
<COMP2> TYPE ANY.
GET TABLE NAME GIVEN BY USER IN LOCAL VARIABLE
TAB = TAB_NAME.
CREATE FIELD NAME BASED ON THE TABLE NAME ENTERED.
CASE TAB_NAME.
WHEN 'OIUH_RV_GL'.
KEY FIELD
TAB_COMP1 = 'GL_GL_SYS_NO'.
NO_OF_FLD = 1.
WHEN 'OIUH_RV_OPSL'.
KEY FIELD
TAB_COMP1 = 'OPSL_GL_SYS_NO'.
NO_OF_FLD = 1.
WHEN 'OIUH_RV_OTAX'.
NOT THE ONLY KEY FIELD
TAB_COMP1 = 'OTAX_GL_SYS_NO'.
TAB_COMP2 = 'OTAX_TAX_POS_NO'.
NO_OF_FLD = 2.
WHEN 'OIUH_RV_GTAX'.
NOT THE ONLY KEY FIELD
TAB_COMP1 = 'GTAX_GL_SYS_NO'.
TAB_COMP2 = 'GTAX_TAX_POS_NO'.
NO_OF_FLD = 2.
WHEN OTHERS.
EXIT.
ENDCASE.
SET FIELD SYMBOL WITH APPROPRIATE TYPE TO BUFFER AREA.
ASSIGN BUFFER TO <WA> CASTING TYPE (TAB).
How to add where clause and remove the if condition in the select -- endselect
SELECT * FROM (TAB) INTO <WA>.
ASSIGN COMPONENT TAB_COMP1 OF STRUCTURE <WA> TO <COMP1>.
IF NO_OF_FLD = 2.
ASSIGN COMPONENT TAB_COMP2 OF STRUCTURE <WA> TO <COMP2>.
ENDIF.
IF <COMP1> = OLD_SYS_NO.
code for updating table would come here
WRITE: 'MATCH FOUND'.
EXIT.
ENDIF.
ENDSELECT.
Please advice. Thanks much.
Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:33 PM
Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:34 PM
Edited by: Shipra Jhunjhunwala on Jul 22, 2009 1:35 PM1. Create single column table for holding field name depending on the table entered.
2. Take input from user: for e.g. table_name
3. Using case load single column table with required fields
for e.g.
CASE TAB_NAME.
WHEN 'OIUH_RV_GL'.
Append 'GL_GL_SYS_NO' to KEY_FIELD --> KEY_FIELD is the single line internal table as mentioned in step 1.
WHEN 'OIUH_RV_OPSL'.
Append 'OPSL_GL_SYS_NO'.
WHEN 'OIUH_RV_OTAX'.
Append 'OTAX_GL_SYS_NO' to KEY_FIELD.
APPEND 'OTAX_TAX_POS_NO' to KEY_FIELD.
WHEN 'OIUH_RV_GTAX'.
Append 'GTAX_GL_SYS_NO' to KEY_FIELD.
APPEND 'OTAX_TAX_POS_NO' to KEY_FIELD.
WHEN OTHERS.
EXIT.
ENDCASE.
Now depending on the table name you have required column ready
4. Create dynamic internal table using following sudo code
Fill the fieldcatlog using the single column field table and DD03L table, See what all columns from DD03L you want to fill in field catlog table
loop at internal table with all the fields.
move it to field catalog.
append field catalog.
endloop.
5. Pass this field catalog table to static method create_dynamic_table method
DATA table TYPE REF TO DATA. --> data object for holding handle to dynamic internal table.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = fieldcatalog_tab
importing
ep_table = table.
6. Now assign table reference to field symbol of type table.
ASSIGN table->* to <field-tab>.
7. Also create work area <field-wa> using refrence of table.
create data object wa LIKE LINE OF <field-tab>.
ASSIGN wa->* to <field-wa>.
8. Also define field symbol for field name.
for e.g. <field_name>
4. Dynamic internal table is ready
5. Now execute the select statement as follows:
SELECT (KEY_FIELD)
INTO <ITAB> --> created dynamically above
FROM (TABLE_NAME)
WHERE (WHERE). --> WHERE is single line internal table having line type of CHAR72. So for every old value there will be one line
Where condition is same as like we give in static way only difference in this case it will stored in internal table line wise.
In this case you need to append all your where condition line by line in to WHERE.
5. To fill this dynamic internal table using ASSIGN COMPONENT <Comp_number> OF STRUCTURE <field-wa> TO <field-name>
So in this case if first field of structure STRUCT1 is user_id then sudo-code will be
loop at internal table containing list of fields into field_wa --> single column field table
ASSIGN COMPONENT field_wa OF STRUCTURE <field-wa> TO <field>. "Here field_wa is wa area for single column internal table holding all the fieldnames.
Now <field-name> points to user_id field. Move some value into it as nornally we do with variables.
Move <your_new_value> to <field-name>. --> Assign new value
or
<field-name> = <your_new_value>.
Endloop.
6. After completing all the fields one row will be ready in <field_wa>.
APPEND <field_wa> to <field_tab>.
Hope this helps you.
Thanks,
Augustin. -
Dynamic where condition in Select statement
Hi,
I have 10 fields on selection-screeen. In which ever field the user enters single values or ranges,i should pick that field dynamically and pass that field along with value range to Where condition of Select statement.How can i achieve this? Please help.
Regards
K Srinivassee the following example:
data : begin of itab occurs 0,
matnr like mara-matnr,
end of itab.
ypes: begin of ty_s_clause.
types: line(72) type c.
types: end of ty_s_clause.
data : begin of gt_condtab occurs 0.
include structure hrcond.
data : end of gt_condtab.
FIELD-SYMBOLS <fs_wherecond> TYPE ty_s_clause.
data:
gt_where_clauses type standard table of ty_s_clause
with default key.
gt_condtab-field = 'MATNR'.
gt_condtab-opera = 'EQ'.
gt_condtab-low = '000000000000000111'.
append gt_condtab.
clear gt_condtab.
call function 'RH_DYNAMIC_WHERE_BUILD'
exporting
dbtable = space " can be empty
tables
condtab = gt_condtab
where_clause = gt_where_clauses
exceptions
empty_condtab = 01
no_db_field = 02
unknown_db = 03
wrong_condition = 04.
select matnr from mara into table itab where (gt_where_clauses). -
Checking conditions in SELECT statement
Hi All,
I am relative new to ABAP and I would like to ask a question about checking conditions in SELECT statement in the "WHERE" part.
There are two checkboxes at the selection screen and each should disable one of conditions (marked with two stars) in the SELECT mentioned below.
My question is, whether there exists an option how to solve this problem without using solution like:
IF checkobx1.
SELECT (without one condition)
ELSEIF checkbox2.
SELECT(without other condition).
ELSE.
SELECT (with both conditions)
SELECT qprueflos qherkunft qaufnr qsa_aufnr qmatnr qwerkvorg
qpastrterm qpaendterm
qverid qobjnr vobjnr AS objnr_fa vauart
FROM qals AS q INNER JOIN vkaufk AS v
ON qaufnr = vaufnr
INTO CORRESPONDING FIELDS OF TABLE gt_qals
WHERE q~prueflos IN s_pruefl
AND q~stat35 EQ space
AND q~werk EQ loswk
AND q~herkunft IN s_herk
AND q~offennlzmk EQ 0
AND q~offen_lzmk EQ 0
AND q~pastrterm IN s_startt
AND q~paendterm LE s_endt
AND v~auart IN s_auart. "('ZCPA', 'ZCPK', 'ZCBA').Hi,
With this, I think u can directly read into WHERE clause
IF checkbox1.
v_where = '& BETWEEN ''&'' AND ''&'' '.
REPLACE '&' WITH key_field INTO v_where.
REPLACE '&' WITH field_LOW INTO v_where.
REPLACE '&' WITH field_HIGH INTO v_where.
CONDENSE v_where.
ELSEIF checkbox2.
v_where = '& BETWEEN ''&'' AND ''&'' '.
REPLACE '&' WITH key_field INTO v_where.
REPLACE '&' WITH field_LOW INTO v_where.
REPLACE '&' WITH field_HIGH INTO v_where.
CONDENSE v_where.
ENDIF.
select * into corresponding fields of table ITAB
from (table_name)
where (v_where).
In this key_field is your fieldname in the where clause and field_low, field_high are range of values.
If i write static query it looks like this
RANGES: MATNR1 FOR MARA-MATNR.
MATNR1-LOW = MATNR_LOW.
MATNR1-HIGH = MATNR_HIGH.
MATNR1-SIGN = 'I'.
MATNR1-OPTION = 'BT'.
APPEND MATNR1.
select * into corresponding fields of table itab
from mara where matnr BETWEEN 'M100' AND 'M200'.
Hope it helps u
thanks\
Mahesh
Edited by: Mahesh Reddy on Jan 30, 2009 11:23 AM -
How to speed a select statement with the NOT EXISTS where condition ?
Hi all,
I created a view : create or replace view view_name as select * from table_1,table_2 where join_condition and some conditions.
Now I have added in the view "where" clause two NOT EXISTS conditions based on one another different table respectively.
Before I added these two conditions the response time was fast ; but after I added these two conditions then the response time deteriorated.
So how to optimize the select statement ? Hints and so on ...
Thank you very much indeed
Message was edited by:
andrianiainaJust run the script :
SQL> explain plan for select * from dual;
Explained.
SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | | | |
| 1 | TABLE ACCESS FULL | DUAL | | | |
Note: rule based optimization
9 rows selected.
SQL>Nicolas. -
Please help - NE where condition in SELECT statement
Dear experts,
I am posting a section of my codes here for your review on performance tuning.
In my second select statement, I used a "NE" where condition. I read somewhere in this forum that using "NE" where condition is not a good decision for improving codes' performance. What alternatives can I have to achieve the same purpose? May I use "NOT IN" here instead? Or do I use a LOOP for this (a rather manual way)?
Just to let you all know that I still consider myself quite inexperienced in ABAP - please also let me know how I can better improvise my programming techniques in the posted codes here too.
I will be most glad to provide you with further information if needed - just let me know.
Many THANKS in advance!
IF p_noncis = 'X'. " Non CIS category of spend selected
" zfi_cis_mat_grp is a bespoke table that stores all CIS MATKL
" and it has two fields only - MANDT and MATKL
SELECT * FROM zfi_cis_mat_grp
INTO TABLE gt_cis_mat_grp.
IF gt_cis_mat_grp IS NOT INITIAL.
SELECT ebeln
ebelp
matkl
FROM ekpo
INTO TABLE gt_ekpo
FOR ALL ENTRIES IN gt_cis_mat_grp
WHERE matkl NE gt_cis_mat_grp-matkl. " NE where condition - is this OK?
ENDIF.
IF gt_ekpo IS NOT INITIAL.
IF s_sakto IS NOT INITIAL.
SELECT ebeln
ebelp
sakto
FROM ekkn
INTO TABLE gt_ekkn
FOR ALL ENTRIES IN gt_ekpo
WHERE ebeln = gt_ekpo-ebeln AND
ebelp = gt_ekpo-ebelp AND
sakto IN s_sakto.
IF gt_ekkn IS NOT INITIAL.
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
FOR ALL ENTRIES IN gt_ekkn
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr AND
ebeln = gt_ekkn-ebeln AND
ebelp = gt_ekkn-ebelp AND
qsskz NE ''.
ENDIF.
ELSE.
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
FOR ALL ENTRIES IN gt_ekpo
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr AND
ebeln = gt_ekpo-ebeln AND
ebelp = gt_ekpo-ebelp AND
qsskz NE ''.
ENDIF.
ENDIF.
ELSE. " Complete list of category of spend selected
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr AND
qsskz NE ''.
ENDIF.Hi,
If you want to remove th NE option then try this way..
SELECT bukrs
lifnr
belnr
budat
cpudt
xblnr
ebeln
ebelp
zfbdt
zterm
zlspr
FROM bsik
INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs AND
lifnr IN s_lifnr AND
budat IN s_budat AND
cpudt IN s_cpudt AND
xblnr IN s_xblnr .
IF SY-SUBRC EQ 0.
Delete gt_bsik where qsskz EQ ' '.
ENDIF. -
Where condition with optional fields in select statement
Hi,
In a function module I have to fetch data based on 7 fields out of which 6 are optional.
If we won't enter values for optional fields it will take default values as zeroes .
So this is not fetching data. But for some fields some values has zero values.
How to solve this condition?
Regards,
maha.Hi,
For those import parameters for which its mentioned as optional, use like condition in the where clause of select statement in the function module.
try like this,
concatenate pfield2 '%' into pfield2.
concatenate pfield3 '%' into pfield3.
concatenate pfield4 '%' into pfield4.
concatenate pfield5 '%' into pfield5.
concatenate pfield6 '%' into pfield6.
concatenate pfield7 '%' into pfield7.
select *
from db table
into itab
where field1 = pfield1 and
field2 like pfield2 and
field3 like pfield3 and
field7 like pfield7.
Now even if the optional fields are blank, data will be selected
Regards,
Vik -
Where condition problem in select statement.
Hi,
I am trying to write select statement as below
SELECT objectclas objectid FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE ltab_chgdocu
WHERE objectclas IN ('STUE' , 'STUE_V')
AND ( TCODE eq 'CS01u2019 or tcode eq u2019CS02u2019 or tcode eq 'C201' or tcode eq 'C202' ) .
But I am getting the error like "literals that takes up more than one line or not permitted"
Please let me know whats wrong and correct me .
Thanks,
Vinay.Hi Vinay,
Declare constants
constants : c_stue type CDOBJECTCL value 'STUE',
c_stue_v type CDOBJECTCL value 'STUE_V',
c_cs01 type sy-tcode value 'CS01',
c_cs02 type sy-tcode value 'CS02',
c_C201 type sy-tcode value 'C201',
c_C202 type sy-tcode value 'C202'.
And replace your hardcoded values with these constants in your select query.
SELECT objectclas objectid FROM cdhdr INTO CORRESPONDING FIELDS OF TABLE it_tab
WHERE objectclas IN (c_STUE , c_STUE_V)
AND ( TCODE eq c_CS01
or tcode eq c_CS02
or tcode eq c_C201
or tcode eq c_C202 ).
Thanks & Regards
- Always Leaner -
Conditional Mysql select statement
HI Folks
can anyone point me in the right direction with a MySQL statement.
I will try to layout my thinking here:
I have a form with three inputs area, name and search. I am trying to write a Mysql select statement that selects records from a single table if they match the criteria. Easy for two variables but I'm lost after that.
1. The form includes these three inputs:
area - drop down menu (Any as default)
name - drop down menu (Any as default)
search box - text area (Blank as default)
2. The form submits to itself leaving me with these three variables
$search=$_GET['search']
$area=$_GET['area']
$name=$_GET['area']
SELECT * FROM database WHERE database.description LIKE '%$search%' AND database.area LIKE '$area' AND database.name LIKE '$name'
3. This is where I get confused. How do I get the SQL to Select everything correctly. I have tried using PHP if/else code to fix it but I end up running around in circles with six different Select statements and haven't yet got that to work.
So I have come to the conclusion that there must be an easier way. I see search forms with dozens of search criteria on websites every day an d I only have 3 - so it can't be this complicated. Right?
I know I need to start from the beginning again but can anyone let me know how to approach it before I begin?
Cheers
DaveTypically, I would build the where clause dynamically, based upon the values in your form. If the form field contains 'Any', leave it out of the where clause. So you can test each field value and either append or not to the end of the where clause.
Maybe you are looking for
-
HP 8620 printer two sided printing reverses pages
Is there a way to change the order that this printer prints double sided prints? It prints last page first, so if it is 3 pages pages 2 & 3 are one page and page 1 is just one-sided. Need this to be reversed. Can you do this in the Mac driver? Lisa
-
Bug in writing Integer Data in Hex in Write Spreadsheet File
It appears that Write to Spreadsheet File forces all data to I64. Try writing an I16 or I32 array with a negative number. Format specification to 4x, 8x or whatever is ignored and you get a full completent of 16 bytes with a lot of FF's at the beginn
-
Am having problem bringing up mpls l2vpn between asr9k and 7609 router . Below is my config. The interfaces are up, the vc working, but can't ping across. AS9K interface GigabitEthernet0/2/0/6.609 l2transport encapsulation dot1q 609 rewrite ingress t
-
Can numbers consume an external data source?
What I am wondering is if I can say 'point' Numbers to a datasource and query the data?
-
Dear Gurus, How do we define "optional reporting points"?? What is the t-code to do the same. Regrds, Pradeep