String operations in SELECT WHERE clause
Hi,
PARAMETERS: P_MAKTX TYPE MAKT-MAKTX.
Lets say the user inputs "Pump". I want the program to search the text "pump" in all makt-maktx and display the result.
Could someone tell me how to write the select statement.
SELECT * from MAKT into table IT_MAKT where MAKTX ??? P_MAKTX.
Please advise.
Regards,
Shobhit
Try this....
This is an example for using the parameter. You could use a select-option instead.
report zrich_0001
no standard page heading.
data: imakt type table of makt with header line.
parameters: p_maktx type makt-maktx.
ranges: r_maktx for imakt-maktx.
r_maktx-sign = 'I'.
r_maktx-option = 'CP'.
concatenate '*' p_maktx '*' into r_maktx-low.
condense r_maktx-low.
append r_maktx.
select * into corresponding fields of table imakt
from makt
where maktx in r_maktx
and spras = sy-langu.
loop at imakt.
write:/ imakt-matnr, imakt-maktx.
endloop.
Regards,
Rich Heilman
Similar Messages
-
How to validate string parameter in subprogram where clause.
Hi All,
I m using forms6i, I have receive one string parameter from some other Form. I want to check this parameter value in my subprograms where clause (Particularly IN clause).
For Example the parameter name : P_PARA1 and its value 'AA','BB','CC'
my code like this..
select ....
from <tab name>
wehre ....
and column_name in(:parameter.para1)*
plz help me hw can i handle this situation.I Did't get any error value, but the in where clause :parameter value added '' quotes at runtime.
For example
declare
cursor c1 is (p_p1 IN VARCHAR2) IS
select ...
from ...
where <columnname> IN (p_p1);
begin
open C1(:PARAMETER.P_para1);
now i have checked the selection query while running form in SQL Monitor, below like that
select ..
from ...
where <columnname> IN ('''AA'','''BB'');
hw its added the extra ' quote.. -
Hi,
I'm working with Oracle JDeveloper 9.0.5.2 with ADF.
I have a data page in FindMode. Into the jsp related to this data page, I have some attributes where I could set some values before executing a query on a view object.
My question is:
Is it exist a way, at run time, to capture the select string including the WHERE clause just indicated in the jsp page ?
For example:
if, into the text box related to "Attribute1", I indicate "abc" and, into the text box related to "Attribute2", I indicate "5", how can I get the WHERE string "Attribute1 LIKE 'abc' AND Attribute2 = 5" ?
Thanks in advance.
Kind Regards.
MassimoDear Brenden Anstey,
thanks for your prompt reply.
But, unfortunately, your suggestion does not resolve my problem.
I'll try to explain better what I want:
I have a Struts Data Page. The related jsp page is in the Find mode because I have to use it to insert some values for some attributes and just after to choose a submit button in order to execute a query from a view object that respects the values above inserted.
1) Into my jsp I have the following attributes:
- âAttribute1â (type: VARCHAR2)
- âAttribute2â (type: NUMBER)
2) I insert the following values:
- âstring1â for âAttribute1â
- â123â for âAttribute2â
3) Then, I choose the submit button to excute the query on the view object.
Now, I need to know what is the SQL string that ADF builds at run time to excute the query and to get a records data set from a view object. In the above example, the SQL string should be:
SELECT * FROM ViewObjectName WHERE Attribute1 LIKE âstring1â AND Attribute2 = 123
I think it should be possible to obtain this, because if, for example, I indicate âaâ for the numeric attribute âAttribute2â, it appears a jsp with an error message like this:
JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM ViewObjectName WHERE ( ( (Attribute2 = a) ) )
So, it means that the SQL string has to be been registred somewhere.
Could anyone help me ????
Thanks in advance
Best Regards.
Massimo -
Using OR operator in the WHERE clause in Oracle BI
Hi, i am using Oracle BI EE 10.1.3.3.3.
I construct the simple report in BI Answers on the Accounts presentation layer, and use the following filter clause:
"WHERE (AccountNum BETWEEN '441' and '473') OR (БалСчет1Порядка BETWEEN '501' and '519')"
Then i look in the cursor cache and find the real query which is going to database, and it's "where" clause now is:
"where ( (T45172.BA >= '441' or T45172.BA >= '501') and
(T45172.BA >= '441' or T45172.BA <= '519') and
(T45172.BA >= '501' or T45172.BA <= '473') and
(T45172.BA <= '473' or T45172.BA <= '519') ) "
Why BI create so many expressions instead of the source 2 expressions?
How can i force BI to use the source expressions?I have the same settings too.
I post the following query in the Administration web interface, and set the maximum logging level (7):
SELECT "Plan Account"."Balance Account" saw_0
FROM "Plan Account"
WHERE ("Plan Account"."Balance Account" between '441' and '473')
OR ("Plan Account"."Balance Account" between '501' and '519')
ORDER BY saw_0
And got the following BI execution plan:
RqList <<5619441>> [for database 0:0,0] distinct D1.c1 as c1 [for database 3023:44913,46]
Child Nodes (RqJoinSpec): <<5619450>> [for database 3023:44913:DB,46]
RqList <<5619277>> [for database 3023:44913:DB,46]
D1.c1 as c1 GB [for database 3023:44913,46]
Child Nodes (RqJoinSpec): <<5619360>> [for database 3023:44913:DB,46]
RqList <<5619284>> [for database 3023:44913:DB,46]
Dim - Plan Account.BA as c1 GB [for database 3023:44913,46]
Child Nodes (RqJoinSpec): <<5619350>> [for database 3023:44913:DB,46]
TB_PLAN_ACCOUNT T45172
DetailFilter: (not Dim - Plan Account.BA < '441' or not Dim - Plan Account.BA < '501') and (not Dim - Plan Account.BA < '441' or not '519' < Dim - Plan Account.BA) and (not Dim - Plan Account.BA < '501' or not '473' < Dim - Plan Account.BA) and (not '473' < Dim - Plan Account.BA or not '519' < Dim - Plan Account.BA) [for database 0:0]
) as D1
) as D1
OrderBy: c1 asc [for database 0:0,0]
and following query sent to database:
-------------------- Sending query to database named DB (id: <<5619277>>):
select distinct D1.c1 as c1
from
(select distinct T45172.BA as c1
from
TB_PLAN_ACCOUNT T45172 /* Dim - Plan Account */
where ( (T45172.BA >= '441' or T45172.BA >= '501') and (T45172.BA >= '441' or T45172.BA <= '519') and (T45172.BA >= '501' or T45172.BA <= '473') and (T45172.BA <= '473' or T45172.BA <= '519') )
) D1
So, i got the same bad where clause...
What can you advice? -
Whats the alternate for left join with using IN operator in the where claus
My senario...
Select t1.f1, t1.f2, t2.f3
From t1, t2
Where ...
t1.f1> (+) IN t2.f1
...alternate query..
Select t1.f1, t1.f2, t2.f3
From t1, t2
Where ...
(t1.f1> IN t2.f1 or 1=1)
...will the alternate query satisfy the above senario..?I'm not quite sure I've understood what the OP's question is, but will ANSI syntax deal with it?
SQL> ed
Wrote file afiedt.buf
1 with a as (select 1 as num, 2 as data from dual union all
2 select 2 as num, 3 as data from dual union all
3 select 3 as num, 4 as data from dual),
4 b as (select 1 as num, 5 as data from dual union all
5 select 3 as num, 7 as data from dual)
6 -- END OF TEST DATA
7 select a.num, a.data, b.data
8* from a LEFT OUTER JOIN b ON (a.num = b.num AND b.num IN (3))
SQL> /
NUM DATA DATA
3 4 7
1 2
2 3
SQL> -
How to pass the parameter in the where clause of the select statement
Hi All,
Iam getting one of the value from the Input otd and using this value i need to query one of the tables in oracle database and selected the table using the oracle eway otd like shown below .
otdRISKBLOCK_1.getRISKBLOCK().select() .
where clause in side the select takes a string parameter as Iam getting the string parameter from the input otd and passing this to where clause by creating a string literal after deployment it is giving an error saying "ORA-00920: invalid relational operator".
can any one throw some input on this .
Thanks in Advance
SrikanthYou will see this error if the search condition was entered with an invalid or missing relational operator.
You need to include a valid relational operator such as
=, !=, ^=, <>, >, <, >=, <=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition. in the sql statement.
Can you throw some more light on how are you designing your project? -
SQL Strings in Where Clause - single quotes issue
All,
Im having issues related to SQL String literals when trying to deploy to flash. The complication works fine but I then get a message (see below) stating that a ; is missing. The SQL query and the iview runs fine when we use numeric values or do not apply a where clause on the table.
I am using Visual Composer that has been packaged with NW2004sSP7_Preview
VC & Flex Version: 645.7.0.3
The Error message is get is;
Error in executing a process for Flex compilation, Error 1033: ';' expected
(C:usrsapJ2EJC01j2eeclusterserver0GUIMachine_Business_Packagestest_48731FLEX_COMPILATION_FOLEDRAADCN.mxml:269)
Error 1205: The statement 'Test' is incomplete.
(C:usrsapJ2EJC01j2eeclusterserver0GUIMachine_Business_Packagestest_48731FLEX_COMPILATION_FOLEDRAADCN.mxml:269)
Failed to compile AADCN.mxml
When I goto the deployment file it has the below line;
<i>'<Request type="EXECUTE_RELATIONAL" system="BI_JDBC" system_type="SAP_BI_JDBC" maxrows="500" templateid="BIR_SQL"><Objects type="INPUT" shape="OBJ" role="INPUT"><Object type="INPUT_FIELD" id="SQL_STATEMENT" appName="SQL" mapped="0" value=""/></Objects><Objects type="OUTPUT" shape="SET" role="OUTPUT"><Object type="OUTPUT_FIELD" id="name" appName="name"/></Objects><Objects id="1" type="TEMPLATE_PARAMETER"><Object id="2" type="SQL" value="select name from pub.srcompany where name ='Test Company'"/></Objects></Request>';</i>
It seems that the parser for the flash deployment is prematurely finishing the parse when it hits the single quotation in the SQL string!
We had a similar error where if we had a carriage return in the SQL (e.g. between the from & the where clause) then the deployment parser was stating that the line finished prematurely. In the deployment file the carriage return forced a new line thus making the message incomplete. Removing the carriage return resolve that issue
The SQL Preview in the SQL Editor within VC works fine with the string literals in the where clause.
The functionality compiles & deploys in web dynpro however it does not return the results to the table
Questions
1:> Has anyone successfully used flash with string literals in the SQL where clause or had seen this issue in the past?
2:> Is there a setting to get the SQL working on Web dynpro for the information to be returned that I may have missed?
Any assistance would be greatly appreciated.
Best Regards,
Ian.Hey,
I have worked with SQL Editor a lot. Here's a how to guide I put together on it:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6339e7d4-0a01-0010-1c98-db00e52e989a
Let me know if that helps...
Prakash -
Where clause as a Paramter?
So i am using a view for my report and my question is can i have a where clause parameter
select * from vw_rpt_inv_report
where=@where?
The reason i want to use that is when my report is executed my view has 28 columns right so a user should be able to use any column from my report as a parameter.
Does that make any sense ?
I did some research and i found this as a solution :
declare @whereclause nvarchar(1000)
set @whereclause= 'select * from vw_rpt_inv_standard_format'
select i.*, L.COMPANYNAME, L.LOCATIONNAME, L.ADDRESSLINE2, L.CITY, L.STATE, L.COUNTRY, L.ZIPCODE
FROM VW_RPT_INV_STANDARD_FORMAT I
JOIN LOCATION L ON L.LOCATIONID=I.LOCATIONID
WHERE ' + @whereclause '
When i try to run the report i get an error
ORA-06550: line 1, column 9:
PLS-00103: Encountered the symbol "@" when expecting one of the following:
begin function package pragma procedure subtype type use
<an identifier> <a double-quoted delimited-identifier> form
current cursor
The symbol "@" was ignored.
ORA-06550: line 1, column 36:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= ; not null default character
I am using ORACLE AS my Database for creating reports on MS SSRS 2008.
Can anyone help me ?Okay i am brand new to this so i am totally lost.
What i am trying to do is i have a view which is my dataset right
select * from vw_inv_report.
once my report is done its deployed on a webservice.
I have a report built on a query and I want to be able to send a parameter (@theWhere) that is a string which is a where clause (WORKORDERNUMBER LIKE '1563514%') and locationid in(63) these strings can vary depending on what columns the user selects and what operators they want to use. Generation of proper SQL for the where clause has been verified, I just need to be able to pass these, is there any way to do this...see example query below and how I was planning on using the @theWhere variable...
So can i use
declare @where nvarchar(1000)
declare @clause nvarchar(5000)
set @where= '(WORKORDERNUMBER LIKE '1563514%') and locationid in(63) '
set @clause =
'select i.*, L.COMPANYNAME, L.LOCATIONNAME, L.ADDRESSLINE2, L.CITY, L.STATE, L.COUNTRY, L.ZIPCODE
FROM VW_RPT_INV_STANDARD_FORMAT I
JOIN LOCATION L ON L.LOCATIONID=I.LOCATIONID
WHERE ' + @whereclause
EXEC
@clause
becuase when i run it i get this error now
ORA-06550: line 1, column 9:
PLS-00103: Encountered the symbol "@" when expecting one of the following:
begin function package pragma procedure subtype type use
<an identifier> <a double-quoted delimited-identifier> form
current cursor -
can you give me an example with operator Like in Where clause.
I need to do something like this:
Select Column from Table where Column like "request.getParameter("value")
Thanks.Thanks, but I need to compare using "like " and "% Value %"
How about synatx in this case:
Select column1, column2 from table where column1 like '%request.getparameter("value1")%' or
column2 like '%request.getparameter("value2")%' and ... -
Dynamic itab with Dynamic Where clause
Hi, Dear All,
Can someone provide a code extract for Dynamic where clause, i had already done with dynamic itab for a given set of fields, and i need to add where clause dynamically for a given field for a given range of values.
select (i_fields) into table <dyn_table>
from (p_table)
where (v_where).
In the above except the where clause, everything is done. Please help me.
with best regards
MaheshHi,
here is the code extract for your reference.Pl. correct me.
with regards
REPORT Z_DYN_ITAB .
TYPE-POOLS: SLIS.
DATA:NAME(100) TYPE C.
TYPES: BEGIN OF ITAB_TYPE,
WORD(20),
END OF ITAB_TYPE.
DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH HEADER LINE.
DATA: vg_fields(255) TYPE c,
i_fields LIKE TABLE OF vg_fields.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat,
ls_layout TYPE slis_layout_alv.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data.
data: dy_line type ref to data,
xfc type lvc_s_fcat.
DATA: v_where TYPE string, " Variable for storing where clause.
v_dynamic(18) TYPE c, "variable to store select option datatype
o_field TYPE REF TO cx_root," object to catch exception
text TYPE string. "string variable to store exception text.
CONSTANTS: c_var(15) TYPE c VALUE ' IN S_RANGE'.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001',
p_name(100) type c,
p_field(10) TYPE c. " Parameter to capture field name.
SELECT-OPTIONS: s_range FOR v_dynamic. " Select-option for range.
selection-screen end of block b1.
start-of-selection.
NAME = p_name.
SPLIT NAME AT ',' INTO TABLE ITAB.
LOOP AT ITAB.
is_fcat-fieldname = itab-word.
is_fcat-tabname = p_table.
APPEND is_fcat to it_fcat.
ENDLOOP.
LOOP AT it_fcat INTO is_fcat.
is_fieldcat-fieldname = is_fcat-fieldname.
is_fieldcat-tabname = is_fcat-tabname.
APPEND is_fieldcat TO it_fieldcat.
CONCATENATE is_fieldcat-tabname is_fieldcat-fieldname INTO
vg_fields SEPARATED BY '~'.
APPEND vg_fields TO i_fields.
ENDLOOP.
perform create_dynamic_itab.
perform get_data.
Create dynamic internal table and assign to FS
form create_dynamic_itab.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fieldcat
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
Select Data from table.
CONCATENATE p_field c_var INTO v_where.
TRY.
select (i_fields) into table <dyn_table>
from (p_table)
where (v_where).
if sy-dbcnt = 0.
write : text-t02.
endif.
*Write out data from table.
Loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
Exception Catching.
CATCH cx_root INTO o_field.
text = o_field->get_text( ).
Calling Function to give information message regarding Exception
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = text-t03
txt1 = text
txt2 = text-t04.
TXT3 = ' '
TXT4 = ' '
LEAVE TO LIST-PROCESSING.
ENDTRY.
endform. -
Programmatically setting UI Hints for runtime named where clause params
Hi,
At runtime, I've added some named where clause parameters to my view object instance, set the where clause and then executed the query. Then, when navigating to the target page, where a af:query panel is shown and a af:table shows the filtered results, I see the bind variables I've just created appearing in the search area as mandatory fields.
My question is: how can I hide those runtime bind variables?
Thanks
JDeveloper 11.1.1.3.0I do want where clauses to be created at runtime instead of design time to improve DB performance
whereClause += "AND DEPARTMENT_ID = " + departmentId;Marge -
What you are doing is a recipe for POOR performance, not good performance. String concatenation in a where clause with no bind variables... ugh! Poor performance + poor security (you are now susceptible to SQL injection attacks).
I suggest that you do this at design time (where possible) and have a read of the documentation about view criteria.
And please, no matter what approach you use, PLEASE PLEASE PLEASE start using bind variables and not just jamming strings together to make your where clause, otherwise you are heading straight for disaster. I cannot stress this enough.
John -
How to use string operation in where clause of select query
Hello All,
I just want to know how can i write a restriction in select query saying retrive data only begins with name "DE*".
Explaination: If my table has records and names starts with character then i want to write a query to fetch all the records in which names starts with DE*.
Thanks in advance for your quick reply...
Dev.Hi
In the where clause you need to write like
WHERE NAME LIKE 'DE%'
Regards
Sudheer -
Offset operation in select statements where clause
dear experts,
if i use offset operation in select query , syntactically giving
me a warning message.
how to avoid warning message
without using another internal table populated with only jtab+0(10).
ex:
select field1 field2
into table itab
from ztable1
for all entries in jtab
where field = jtab+0(10).
thanks in advance.No need to populate another internal table...
when populating jtab from database select ur field twice
structure for jtab..
types: begin of ty_jtab,
field type ...
field1 type char10,
end of ty_jtab.
populate the field twice..
select ...
field
field
into table jtab
Now u can use the field field1 in the next select
select field1 field2
into table itab
from ztable1
for all entries in jtab
where field = jtab-field1. -
Generating HANA where clause for select options having CP as the operator
Hi All
I am trying to generate where clause in HANA sql from the select options range table .
I tried using the function modules RSDS_RANGE_TO_WHERE and RH_DYNAMIC_WHERE_BUILD .
They are working for most of the cases . But , when the range table has entries like
Fieldname sign opt low high
VBELN I/E CP *4*
Both of them fail to generate the right result .
Could you suggest any other function modules , which take care of all such cases like include single values , exclude single values , incluse and excluse ranges , patterns etc .
Thanks and Best Regards
VarshaHi Karthik,
this is the api, I have done,
create or replace
FUNCTION get_where_clause_for_emp_req (
emp_id IN NUMBER,
salary IN NUMBER,
job IN VARCHAR2,
dept IN NUMBER
RETURN VARCHAR2
IS
l_where_clause VARCHAR2 (2000);
BEGIN
IF ( (emp_id IS NULL)
AND (salary IS NULL)
AND (job IS NULL)
AND (deptIS NULL)
THEN
RETURN NULL;
ELSE
l_where_clause := 'WHERE ';
END IF;
IF (emp_id IS NOT NULL)
THEN
l_where_clause :=
l_where_clause || ' emp_id =' || emp_id || '';
END IF;
IF ((emp_id IS NOT NULL) AND (salary IS NOT NULL))
THEN
l_where_clause :=
l_where_clause || ' AND salary= ' || salary;
ELSIF (salary IS NOT NULL)
THEN
l_where_clause := l_where_clause || ' salary= ' || salary;
END IF;
IF (((salary IS NOT NULL) AND (dept IS NOT NULL)) OR ((emp_id IS NOT NULL) AND (salary IS NULL) AND (dept IS NOT NULL)))
THEN
l_where_clause := l_where_clause || ' AND dept= ' || dept;
ELSIF (status_i IS NOT NULL)
THEN
l_where_clause := l_where_clause || ' dept= ' || dept;
END IF;
l_where_clause := l_where_clause || ' ;';
RETURN l_where_clause;
END;I have done for three parameters, i need to include two more input parameters for this function, so I see going forward my testing cases will increases,
so am looking for the best solution
Thanks
Edited by: NSK2KSN on Jul 7, 2010 3:11 PM -
AND and OR operations in WHERE clause
Hello, Dear Oracle professionals.
In WHERE clause when I use AND or OR operations, is there any way of working ORACLE server to select rows?
For example
WHERE con1 and con2 and con3 and con4 and con5OR
WHERE con1 or con2 or con3 or con4 or con5How oracle checks this conditions ? From the begining to the end ? in order ?
May be I should put some more probable TRUE condition to the end(or to the begin).
Whant to know how oracle thinks.
Thanks in advance.Hi,
Khayyam wrote:
Hello, Dear Oracle professionals.
In WHERE clause when I use AND or OR operations, is there any way of working ORACLE server to select rows?
For example
WHERE con1 and con2 and con3 and con4 and con5OR
WHERE con1 or con2 or con3 or con4 or con5How oracle checks this conditions ? From the begining to the end ? in order ?It evalauates the one that is likely to make the most difference first. In the case of AND, that means the condition that is least likely to be true (as far as the optimizer can predict).
May be I should put some more probable TRUE condition to the end(or to the begin).It doesn't matter to the optimizer. Do whatever you find easier to read and debug.
In ancient times, using the rule-based optimizer, order did matter, but there's no reason to be using the rule-based optimizer now. Oracle 11 doesn't even have the option.
By the way, be careful not to mix AND and OR without parentheses. That is, never say:
WHERE x AND y OR z -- ***** No! Wrong! ******Instead say
WHERE (x AND y) OR z or
WHERE x AND (y OR z) depending on what you want. If you don't use partentheses, then there are rules about how the expresssion is evaluated, but it's a waste of your time to learn them.
Maybe you are looking for
-
anyone got any ideas how i can resolve this issue, i have the latest windows 8.1 and itunes will not open , ive removed and reinstalled to no avail
-
Got some questions concerning iMovie 8: 1. When I try to trash "rejected clips", a dialogue box says I can't, and that I don't have enough disk space! I did empty the trash, as the instructions said. I am using an external hard drive to hold the sour
-
Where can I get a list of available selection for certain dict type?
Where can I get a list of available selection for certain dict type in code? For instance, when I use SE16 to view VBFA table, I am presented with many filter criteria. One of them would be "VBTYP_N". When I click on the square next to the option,
-
Post Author: dracos CA Forum: General Hello! I have a report that sometimes when we run it we get the following: Failed to retrieve data from the database Details [ Database Vendor Code 3236 ] We are using Oracle as our database but I have as of yet
-
Can't get the correct Oracle Developer Suite 10g disk 1
I tried to download Oracle Developer Suite 10g disk 1. After download completed, I check the size is only around 560mb, not 577mb. It is so wield. Then I followed the instruction and double-click the exe. I always got error it is not a win32 applicat