Writing OR query for fetching records
Hi,
I have dowloaded a custom wsdl and generated a java client from it using Jdeveloper.
I have a method named customObject1QueryPage(QueryInputObj) which is used to query the CRM oD to fetch records.
I have successfully queried using the above method for one condition:-
QueryInputObj param= new QueryInputObj();
QueryType q = new QueryType();
q.set_value("='" + "ABC'");
//q.set_value("LIKE 'A*'");
param.setAccountName(q);
customObject1QueryPage(param);
But now I want to query using "OR" condition with multiple names in the condition and I don't know how to
write query for that.
SQL query would be like "Select * from table where name='ABC' OR name='PQR' OR name ='XYZ' ";
I want to execute same query for CRM oD but have no idea how to write it.
Can somebody please help me as soon as possible.
Thanks.
Hi,
If your intent to Use OR Condition on a field with multiple Values
say, AccountName = 'xyz' OR AccountName= 'abc' the syntax would be *(='xyz') OR (='abc')*
say, AccountName = 'xyz' OR AccountName= 'abc' OR AccountName = 'pqr' the syntax would be *((='xyz') OR (='abc'))OR(='pqr')*
You can find similar example under On Demand Web Service Documentation
Regards
Deepak H Andeli
Similar Messages
-
Need help writing a query for following scenario
Hi all, I need some help writing a query for the following case:
One Table : My_Table
Row Count: App 5000
Columns of Interest: AA and BB
Scenario: AA contains some names of which BB contains the corresponding ID. Some
names are appearing more than once with different IDs. For example,
AA BB
Dummy 10
Me 20
Me 30
Me 40
You 70
Me 50
Output needed: I need to write a query that will display only all the repeating names with their corresponding IDs excluding all other records.
I would appreciate any input. ThanksIs it possible to have a records with the same values for AA and BB? Are you interested in these rows or do you only care about rows with the same value of AA and different BB?
With a slight modification of a previous posting you can only select those rows that have distinct values of BB for the same value of AA
WITH t AS (
SELECT 'me' aa, 10 bb FROM dual
UNION ALL
SELECT 'me' aa, 20 bb FROM dual
UNION ALL
SELECT 'you' aa, 30 bb FROM dual
UNION ALL
SELECT 'you' aa, 30 bb FROM dual
SELECT DISTINCT aa, bb
FROM (SELECT aa, bb, COUNT(DISTINCT bb) OVER(PARTITION BY aa) cnt FROM t)
WHERE cnt > 1; -
Select query for fetching from 3 tables.
Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
Regards,
Shashank.Hi,
If you have kunnr field in all the 3 tables then it is possible. use inner join as below
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.
<b>Reward Points if this helps,</b>
Satish -
Query for getting records max reported timestamp and 2nd max report
query for getting records in between
max reported timestamp and 2nd max reported timestamp
HERE IS ALL RESULT SET
TIME DOMAIN
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
QUERY RESULT TO COME
TIME DOMAIN
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
Message was edited by:
user517983Hi,
can we write query like this.
1 select pd_user,PD_REPORTED_TIMESTAMP
2 from sp_process_detail_current spdc
3 where host_id='DSCP02469'and pd_user='TOMCAT'
4 and exists(
5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
SQL> /
PD_USER PD_REPORTED_TIMESTAM
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45 -
SQL query to fetch records from 26 onwards
Want to know SQL query to fetch records from 26 onwards.
See the fifth entry on the FAQ page:
Re: How to attach a java bean in forms6i -
How to fire a query for every record in a table, pass values in a loop
Hi,
For each record in a table, I want to loop through each record and then fire a query by passing acct, product and date from this table to the where clause of the query. I would have to create a pl/sql block..The output of the query I want to spool from sql developer.
I need the exact syntax please for doing this.. since i am new to Oracle. Just the template will be enough. I will fill in the query.
Any help is appreciated as always..
Regards,
hena904385 wrote:
Hi,
For each record in a table, I want to loop through each record and then fire a query by passing acct, product and date from this table to the where clause of the query. I would have to create a pl/sql block..The output of the query I want to spool from sql developer.
I need the exact syntax please for doing this.. since i am new to Oracle. Just the template will be enough. I will fill in the query.
Any help is appreciated as always..
Regards,
henaHave you ever considered using a JOIN ? It does the same thing as looping through a table and applying that to the where clause of a select on a query, only much, much, much faster and without the need to write any code. SQL is a declarative language, so you specify what you want and not how to do it. It can be bit of a journey to change your thought process if you come from a procedural or object world, but once you get there it's a beautiful view. -
Query - to fetch records - before particular date
I need to retrive last analyzed table prior to 28/Nov/2010 - to put into simple wanted to fetch records from a table which are created before the above mentioned date.
Thanks,
SteveSpade wrote:
I need to retrive last analyzed table prior to 28/Nov/2010 - to put into simple wanted to fetch records from a table which are created before the above mentioned date.
Thanks,
SteveYou want to fetch the rows which were "inserted" before that date?
Then you either:
a) Need to have a timestamp column on the row or
b) Use ORA_ROWSCN pseudo-column if you created your table(s) with row-level dependency tracking or
c) Install log miner and query the necessary archive logs.
:p -
Af:query not fetching records when VC Modified for advance search
Gurus,
I have a view criteria and using it i have a af:query component in my page. When i run the page i see the fields in the search box correctly. However i see another LOV in the search which has options like "Equals","Between", "Does not contain" etc. Though this option is good for 1 search criteria, it is not of any use for another. How can i remove it from the search criteria that i dont want
thnks
Jdev 11.1.1.5.you would need to add the following to the view criteria item in the view criteria definition for the VO - in order NOT to show any of the operators.
<CompOper
Name="DepartmentName"
ToDo="-2"
Oper="">You would need to do - by open the VO.xml and add this xml snippet - which would ensure that the operators are NOT shown in the query panel.
Sample:
For Departments VO, say there is a view criteria that defined on department id and department name and you do NOT want to show the operators.
After defining the VC, open the VO file - add the above.
<ViewCriteria
Name="DepartmentsVOByDeptIdorDeptName"
ViewObjectName="com.samples.model.DepartmentsVO"
Conjunction="AND">
<Properties>
<CustomProperties>
<Property
Name="displayOperators"
Value="Always"/>
<Property
Name="autoExecute"
Value="false"/>
<Property
Name="allowConjunctionOverride"
Value="true"/>
<Property
Name="showInList"
Value="true"/>
<Property
Name="mode"
Value="Basic"/>
</CustomProperties>
</Properties>
<ViewCriteriaRow
Name="vcrow0"
UpperColumns="1">
<ViewCriteriaItem
Name="DepartmentsVOCriteria_vcrow0_DepartmentId"
ViewAttribute="DepartmentId"
Operator="="
Conjunction="AND"
Required="Optional"/>
<ViewCriteriaItem
Name="DepartmentsVOCriteria_vcrow0_DepartmentName"
ViewAttribute="DepartmentName"
Operator="STARTSWITH"
Conjunction="AND"
Required="Optional">
*<CompOper*
Name="DepartmentName"
ToDo="-2"
Oper="">
*</CompOper>*
</ViewCriteriaItem>
</ViewCriteriaRow>
</ViewCriteria>
Thanks,
Navaneeth -
How to write ABAP Logic in SAP Query to fetch records from many Tables
Hi Expert,
I have one requirement, want to display all BOM (Equipment BOM, Function Location BOM and Meterial BOM) from a particular plant.
List of tables as below:
EQST: Equipment to BOM Link
TPST: Link Between Functional Location and BOM
MAST: Material to BOM Link
STPO:BOM item
Requirement: When user enters Plant then SAP Query should execute and fetch all BOMs (as mentioned above) from STPO Table.
I have done so far is as follows:
I create User Group, Infoset and SAP Query.
While creating INFOSET, i used 4 tables (EQST,TPST,MAST & STPO) and link between then is as follows:
STPO-STLNR ---> EQST-STLNR : Left Outer Join
STPO-STLNR ---> TPST-STLNR : Left Outer Join
STPO-STLNR ---> MAST-STLNR : Left Outer Join
Now its showing all BOM from all plants though I enter one Plant value.
Please advise me to write SAP Query and Logic to fetch all BOM from selected Plant Value.
Thanks,
Jay.
Edited by: jaykrishna007 on Jul 29, 2011 11:41 AMHi FCannavo,
Thanks for your quick reply.
See, now I changed my Infoset design.
I added one Plant Table (T001W) and then
T001W-WERKS--->EQST-WERKS
T001W-WERKS--->MAST-WERKS
T001W-WERKS--->TPST-WERKS
and then
EQST-STLNR--->STPO-STLNR
MAST-STLNR--->STPO-STLNR
TPST-STLNR--->STPO-STLNR
on selection screen, user will enter Plant Value.
Now its showing some records, but i dont think so i would be correct output or not, please guide me whether it is correct or not?
Thanks,
Jay. -
Query for next record in a multiple records display
Hi. I have a text item whose data block displays 10 records after post query. I want to put a query on the keyboard up and down button so that when i press the up or down arrow of the keyboard, the cursor moves to the next record and executes the post query trigger. I tried using the next_record command but the cursor remains on the first record and then tries to create a new record there instead of moving to the next record outputted by the initial post query trigger. I hope you get my point. Thanks
Hi,
I have a text item whose data block displays 10 records after post query. <b>I want to put a query on the keyboard up and down button so that when i press the up or down arrow of the keyboard</b>, the cursor moves to the next record and executes the post query trigger. I tried using the next_record command but the cursor remains on the first record and then tries to create a new record there instead of moving to the next record outputted by the initial post query trigger. I hope you get my point. You do not have to query again for moving cursor up and down. You have to use KEY-UP and KEY-DOWN with NEXT_RECORD and PREVIOUS_RECORD built-ins. Use FIRST_RECORD and LAST_RECORD for boundary conditions.
Regards, -
Tunning the query for faster record retrieval
Hi,
I am back, now this time I donot really know in which forum I should post this query, in XML or in Oracle Developers ?
Anyway...
The problem is :
I have a database with millions of record in that, I give a query based on some 4/5 parameters, and retrieve the records corresponding to that, I have added indexes in the database for faster retrieval of the same, but since the no of records returned is quite high and I planned to put a prev and next link to show only 10 records at a time, I had to get the count(*) of the number of records that match, here is the problem, since there are so many records, and count(*) doesn't consider index, it takes nearly 20-30 seconds for the retrieved list to be seen on the browser window, if I just remove that count(*), the retrieval is quite fast, but then there is no prev and next as I had linked them to count(*).
Could some one please let me know the proper way of doing it. I am a newbie to this and I have been doing some trial and error to get my work done.
Thanks in advance,
Regards,
Shanthi RajaramMake sure to select the COUNT() of an indexed column (the more selective the index the better), this way the optimizer can satisfy the count query with a few IO's of the index blocks instead of a full-table scan.
-
Need a query for duplicate records deletion
here is one scenario...
23130 ----> 'A'
23130 ----> 'X'
23130 ----> 'c'
These are duplicate records.. when we remove duplicates, the record must get 'c', if it contains A,C,X. If it contains A and X, then the record must get 'X'. That means the priority goes like this C-->X-->A. for this i need query.. this is one scenario. It would be great if u reply me asap.Hello
It's great that you gave examples of your data, but it is quite helpful to supply create table and insert statements too along with a clear example of expected results. Anyway, I think this does what you are looking for.
CREATE TABLE dt_dup (ID NUMBER, flag VARCHAR2(1))
INSERT INTO dt_dup VALUES(23130, 'A');
insert into dt_dup values(23130, 'X');
insert into dt_dup values(23130, 'C');
INSERT INTO dt_dup VALUES(23131, 'A');
INSERT INTO dt_dup VALUES(23131, 'X');
DELETE
FROM
dt_dup
WHERE
ROWID IN ( SELECT
rid
FROM
( SELECT
rowid rid,
ROW_NUMBER() OVER (PARTITION BY ID ORDER BY CASE
WHEN flag = 'A' THEN
3
WHEN flag = 'X' THEN
2
WHEN flag = 'C' THEN
1
END
) rn
FROM
dt_dup
WHERE
rn > 1
select * from dt_dup;HTH
David
Edited by: Bravid on Jun 30, 2011 8:12 AM -
Improving SQL query for large records.
I need to extract the difference on the table t1 and t2(contains both almost 6M records). Im looking specifically on the two columns (c1,c2)for my comparison.I need also to look at reference table to extract also other fields for my report. thank you
Dynamic Table (same table and structure but different records.)
t1
t2
Reference Static Table (all the tables below have two columns. c1 and c2 used for reference only)
t3
t4
t5
--Extracting data in t1 but not exists in t2
WITH v1 AS(SELECT c2,c3,c4 FROM t1 at1
WHERE NOT EXISTS (SELECT 'x' FROM t2 at2 WHERE at1.c1 = at2.c2)),
v2 AS (SELECT c1, c2 FROM t3),
v3 AS (SELECT c1, c2, c3 FROM t4),
v4 AS (SELECT c1,c2 FROM t5)
SELECT v1.c1, v1.c2, v3.c2, v4.c2 FROM t,t2,t3,t4
WHERE v1.c1 = v2.c1
AND v2.c2 = v3.c1
AND v3.c2 = v4.c1
ORDER BY v1.c1
I'm trying to improve my scripts to generate the record as fast as possible coz it takes too long. Any suggestions guys.? Im trying to look also on explain plan but I'm new on this. thank youHi,
your sample code can not compile?
There is no column c1 in the v1?
Probably a typo anyway :)
A couple of remarks:
The way you've used v1, v2, v3 and v4 does not help performance.
It only helps increasing the confusion.
Rewrite the query without the WITH clause, post the execution plan for the query and report your Oracle version and we can help you further.
/ Ronnie -
Query for Existing Records( to improve performance)
Hi Friends,
I want to show only those records from A Table which is not in B Table.
Table A--
Ticket no Ticket date
1 01-01-2009
2 02-01-2009
3 02-02-2009
Table B---
Ticket no Ticket date
3 02-02-2009
means only 1,2 should show.
I am using EXISTS
select ticket_no,ticket_date
from A
where not exists( select '1'
from B
where B.ticket_no=A.ticket_no
and B.ticket_date=A.ticket_date
is any other way to improve my query ?
Help me out.
KarTiK PareeK.SomeoneElse wrote:
That should reduce cost up to 20%.That's doubtful.
BTW: joins and operator sets will be much slower that EXISTS in that case.Maybe, maybe not.
It's possible that the two queries wouldn't return the same results, so they wouldn't be comparable anyway.
Minus also does a sort to eliminate duplicates. But maybe that's what the OP wanted.
Of course, as usual we didn't get any sample tables, data, results...I wrote that based on my own research. I created two tables, populated them with sample data (1,000,000 rows each).
What I wrote about 20% decrease in cost, was based on query time consumption and explain plan before and after analyzing tables.
In my case, joins were slower. USE_* hints didn't help. MINUS was slower also. -
SAP Quickviewer query for pricing records - V12L and KONH / KONP
Has anyone used the logical database 'V12L' for pricing queries? There seems to be an issue with this logical database with some vague warning messages.. When I tried to create a simple table join query with KONH and KONP there are again some vague errors. I need to see the following fields in the query output.
KONH-KNUMH, KONH-KOTABNR, KONH-KSCHL, KONP-KBETR, KONP-KONWA, KONP-KPEIN, KONP-KMEIN.
Are there any other simple and robust way to query KONH and KONP simultaneously? Thanks in advance.Hi Dhanaraj,
I tried linking KONH and KONP and it just gave me just warning errors that won't affect your query. Disregard those errors since your not using it anyway and proceed as usual.
Try not to query directly to these tables as much as possible for obvious reason, IT"S HUGE....
I suggest to start with AXXX pricing tables and then link KONP with it. It's faster and you can directly identify the key combinations used.
Enjoy!
Arnel
Maybe you are looking for
-
Content Copier freezes with N95
Hi there, I just updated my software on my N95. I did everything right and have been trying to restore the backup I made with content copier. My problem is that it doesn't complete the restore and seems to stop at 68%. I thought that maybe it wasn't
-
Removal of leading zeros?
Hi, if my infoobject value is 9999 it is updated into cube as 0000009999. How to write the routine to remove the leading zeros before the value? shilpa
-
Is this considered 'freezing' - and what to do next
My Playbook powers on, and then the screen pops up to prompt me to Log In to my Blackberry account. So I enter my information (and I KNOW I have it right) and it does the whole blue-circle ... and never stops. Like, hours. I've done re-boots, and
-
How do you uninstall plugins for Safari?
-
So, what CAN i do with 1.1.3?
Well, i updated to 1.1.3, and im not buying the apps. besides the new gray thing at the bottom and able to view the chapters on a movie, what else can i do with 1.1.3 without having to pay 20$?