Select resultset in join query
I have a SQL query:
SELECT * FROM Job_Request_Record, Requester_Record WHERE Job_Request_Record.Job_Requester_ID=Requester_Reco rd.Requester_ID; if i want to call an attribute from Job_Request_Record table e.g. rs.getString("ID")is it valid? or anything else. please help.
Also, is it possible to have a create view table in ms access 2003?
I have a SQL query:
SELECT * FROM Job_Request_Record, Requester_Record
WHERE
Job_Request_Record.Job_Requester_ID=Requester_Reco
rd.Requester_ID; if i want to call an attribute from
Job_Request_Record table e.g. rs.getString("ID")is it
valid? or anything else. please help.
Also, is it possible to have a create view table in ms
access 2003?You can call rs.getString("ID") provided you have a column name as "ID". But I would advise you to write query without * as it is very ambiguous. You can write
select a.column1,b.column2 from a,b where a.column=b.column
Similar Messages
-
Updatable ResultSet for join Query
Hi all,
It is inevitable that i use a 'JOIN' operation for a particular query and i need the resultSet to be updated. Heard JDBC driver doesnt support this. Is there any workaround for this. Any help is really appreciated.
Thanks,
AbhijitWelcome to the forum!
>
It is inevitable that i use a 'JOIN' operation for a particular query and i need the resultSet to be updated. Heard JDBC driver doesnt support this.
>
As gimbal2 mentioned this isn't supported even by the latest 11g version and driver. See 'Result Set Limitations' in Chapter 17 of the JDBC doc for confirmation and discussion.
http://docs.oracle.com/cd/E14072_01/java.112/e10589/resltset.htm#BABBCECI
>
Result Set Limitations
The following limitations are placed on queries for enhanced result sets. Failure to follow these guidelines will result in the JDBC driver choosing an alternative result set type or concurrency type.
To produce an updatable result set:
A query can select from only a single table and cannot contain any join operations.
In addition, for inserts to be feasible, the query must select all non-nullable columns and all columns that do not have a default value.
A query cannot use SELECT * .
However, there is a workaround for this.
A query must select table columns only.
It cannot select derived columns or aggregates, such as the SUM or MAX of a set of columns.
>
>
Actually my exact requirement is i have two tables, earlier i used to select the results from one table and check for the existance of the corresponding record in the second table from the output of resultset. This is causing a lot of performance issue and i thought of using a single query by joining two tables which reduces the number of records.
>
So is this a correct description of what you want to do?
1. TableA and TableB have one or more columns in common.
2. Query TableA, possibly using filter predicates (WHERE tabA.col1 ...) and identify records in TableB that match on the join columns
3. Update the TableB records from step #2.
If so then you have a couple of options.
The record-by-record approach would be to execute your current query (the one that joins the two tables) but retrieve ONLY the ROWID from TableB. Then iterate thru the result set and use a separate query to get each TableB record by using the ROWID retrieved from the first query. This is different from your original approach because the first query WILL identify the TableB records you need it just won't retrieve them (only the ROWID).
Your original performance issues were probably because you were retrieving ALL of the TableA records and then checking each one to see if there were any TableB records for it.
The BULK approach would be a slight modification of of the record-by-record approach but pushes the work to the DB server.
This approach queries TableB to retrieve ONLY those records that EXIST in the query of TableA just described. So the query is of the form
SELECT * FROM TableB b WHERE EXISTS (SELECT '1' FROM TableA a WHERE a.col1 = b.col1); This query only uses one table for the resultset and does not contain any join operators so it can be updateable.
Test a simple query first until you get the syntax correct. -
Use ResultSet in a query - join??
Hello there,
I would like to ask if it is possible to use the ResultSet from a query in another query. For example my result set contains some indexes and I want to select the rows from the database whose index is not in the result set. Can I do a join somehow?
I find ResultSet very restrictive otherwise
please help
thanx ;)No, you can't use a ResultSet, but you should be able to modify your original query to do whatever it is you need to do. You can do joins in SQL.
-
Deciphering column names in a join query using jdbc
hi all....
I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
Any pointers would be most appreciated.
cheers
vivekthanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
this also puts me in a doubt whether i can use join in my case.
for eg ... .
lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
this would return me 3 rows and i can also recognize various columns with their aliases ..
but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
i guess the only soln left is to visit contact and address table separately. :( -
How to get Hierarchical XML File from a Database Join Query !
Hi,
How can i get a Hierarchical XML File from a Database Join Query ?
Any join query returns repeated values as below:
BD17:SQL>select d.dname, e.ename, e.sal
2 from dept d
3 natural join
4 emp e
5 /
DNAME ENAME SAL
ACCOUNTING CLARK 2450
ACCOUNTING KING 5000
ACCOUNTING MILLER 1300
RESEARCH SMITH 800
RESEARCH ADAMS 1100
RESEARCH FORD 3000
RESEARCH SCOTT 3000
RESEARCH JONES 2975
SALES ALLEN 1600
SALES BLAKE 2850
SALES MARTIN 1250
SALES JAMES 950
SALES TURNER 1500
SALES WARD 1250
14 rows selected.
We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <ROWSET>
- <ROW num="1">
<DNAME>ACCOUNTING</DNAME>
<ENAME>CLARK</ENAME>
<SAL>2450</SAL>
</ROW>
- <ROW num="2">
<DNAME>ACCOUNTING</DNAME>
<ENAME>KING</ENAME>
<SAL>5000</SAL>
</ROW>
- <ROW num="3">
<DNAME>ACCOUNTING</DNAME>
<ENAME>MILLER</ENAME>
<SAL>1300</SAL>
</ROW>
- <ROW num="4">
<DNAME>RESEARCH</DNAME>
<ENAME>SMITH</ENAME>
<SAL>800</SAL>
</ROW>
- <ROW num="5">
<DNAME>RESEARCH</DNAME>
<ENAME>ADAMS</ENAME>
<SAL>1100</SAL>
</ROW>
- <ROW num="6">
<DNAME>RESEARCH</DNAME>
<ENAME>FORD</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="7">
<DNAME>RESEARCH</DNAME>
<ENAME>SCOTT</ENAME>
<SAL>3000</SAL>
</ROW>
- <ROW num="8">
<DNAME>RESEARCH</DNAME>
<ENAME>JONES</ENAME>
<SAL>2975</SAL>
</ROW>
- <ROW num="9">
<DNAME>SALES</DNAME>
<ENAME>ALLEN</ENAME>
<SAL>1600</SAL>
</ROW>
- <ROW num="10">
<DNAME>SALES</DNAME>
<ENAME>BLAKE</ENAME>
<SAL>2850</SAL>
</ROW>
- <ROW num="11">
<DNAME>SALES</DNAME>
<ENAME>MARTIN</ENAME>
<SAL>1250</SAL>
</ROW>
- <ROW num="12">
<DNAME>SALES</DNAME>
<ENAME>JAMES</ENAME>
<SAL>950</SAL>
</ROW>
- <ROW num="13">
<DNAME>SALES</DNAME>
<ENAME>TURNER</ENAME>
<SAL>1500</SAL>
</ROW>
- <ROW num="14">
<DNAME>SALES</DNAME>
<ENAME>WARD</ENAME>
<SAL>1250</SAL>
</ROW>
</ROWSET>
Thank you for some help.
Nelson AlbertiHi,
I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
It can be easily scheduled as a background job to grab content on a daily basis etc ...
Regards,
Steven -
How can I perform this kind of range join query using DPL?
How can I perform this kind of range join query using DPL?
SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
--mark -
SCORE(n) returning zero values in an outer join query
Hello all,
Is there any way to get a query that contains an outer join to return proper scores. I couldn't find out why this was happening in my query, but I'm getting a score values of 0 on most results.
Below are queries with result sets. As you can see the results that are scoring in the second query are scoring correctly, but only two have scores.
- - - Query 1, no outer join - - -
SELECT DISTINCT SCORE(0) AS scr,
file_repository.file_id,
file_repository.file_title
FROM file_repository
WHERE CONTAINS(index_url,'SYN(dui,a_thesaurus)', 0) > 0
ORDER BY scr ASC
SCR FILE_ID FILE_TITLE
7 136 Prisoners
7 240 Drug booklet
8 64 Communications
8 146 Rates
8 168 Vehicle Collisions
8 206 document4
14 207 document5
14 211 document5
15 74 Diplomatic Personnel
22 214 documentB
30 81 DUI and PCA Offences
- - - Query 2, with outer join - - -
SELECT DISTINCT SCORE(0) AS scr,
file_repository.file_id,
file_repository.file_title
FROM file_repository, file_security
WHERE CONTAINS(index_url,'SYN(dui,a_thesaurus)', 0) > 0
AND file_repository.file_id = file_security.file_id(+)
AND file_security.auth_id = 0
ORDER BY scr asc
SCR FILE_ID FILE_TITLE
0 74 Diplomatic Personnel
0 81 DUI and PCA Offences
0 136 Prisoners
0 146 Rates
0 168 Vehicle Collisions
0 206 document4
0 207 document5
0 214 documentB
0 240 Drug booklet
8 64 Communications
14 211 document5
This is on Oracle 9i using Oracle Text.
Thanks in advanceTo do this wouldn't you need to know the data in advance? The real source table had 1800 organisations and 8,000,000 transactions.
I Tried this as well, creating a pl/sql package as follows.
create or replace PACKAGE stack AS
TYPE gnt_push_numbers IS TABLE OF NUMBER INDEX BY PLS_INTEGER;
TYPE gvt_push_varchars IS TABLE OF VARCHAR(1000) INDEX BY PLS_INTEGER;
gna_push_numbers gnt_push_numbers;
gva_push_varchars gvt_push_varchars;
FUNCTION PUSH ( pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
FUNCTION PUSH ( pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
FUNCTION POP_NUM ( pn_offset NUMBER) RETURN NUMBER DETERMINISTIC;
FUNCTION POP_VAR ( pn_offset NUMBER) RETURN VARCHAR DETERMINISTIC;
END stack;
CREATE OR REPLACE
PACKAGE BODY "STACK" AS
FUNCTION push(pn_push_var NUMBER, pn_offset NUMBER) RETURN NUMBER deterministic IS
BEGIN
gna_push_numbers(pn_offset) := pn_push_var;
RETURN pn_push_var;
END push;
FUNCTION push(pv_push_var VARCHAR, pn_offset NUMBER) RETURN VARCHAR deterministic IS
BEGIN
gva_push_varchars(pn_offset) := pv_push_var;
RETURN pv_push_var;
END push;
FUNCTION pop_num(pn_offset NUMBER) RETURN NUMBER deterministic IS
BEGIN
RETURN gna_push_numbers(pn_offset);
END pop_num;
FUNCTION pop_var(pn_offset NUMBER) RETURN VARCHAR deterministic IS
BEGIN
RETURN gva_push_varchars(pn_offset);
END pop_var;
END stack;
Unfortunately it appears to act before the rows are sorted, so will only work in specialised circumstances, in that you have to ensure the rows have been sorted before the function is used.
SELECT PUSH(COL), POP..(COL)
FROM ( SELECT etc.
Luckily the client decided they didn't want to mix their graphs any more so a more classic approach using a base table select for actuals and then a date table select with a sub-query columns for the projection provided a simple solution. -
Help with Inner Join query in SQL
Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
My table structure is :
table_packages
packageID
package
packageDetails
etc
table_destinations
destinationID
destination
destinationDetails
etc
table_packagedestinations
packageID
destinationID
..so nothing that complicated.
So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
This is the PHP from the header, including my INNER JOIN query....
PHP Code:
<?php
$ParampackageID_WADApackages = "-1";
if (isset($_GET['packageID'])) {
$ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
$ParamSessionpackageID_WADApackages = "-1";
if (isset($_SESSION['WADA_Insert_packages'])) {
$ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
$ParampackageID2_WADApackages = "-1";
if (isset($_GET['packageID'])) {
$ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
mysql_select_db($database_connPackages, $connPackages);
$query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
$WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
$row_WADApackages = mysql_fetch_assoc($WADApackages);
$totalRows_WADApackages = mysql_num_rows($WADApackages);
$colname_educationalDestinations = "1";
if (isset($_GET['PackageID'])) {
$colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
mysql_select_db($database_connPackages, $connPackages);
$query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
$educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
$row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
$totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
?>
And where I'm trying to display the destinations themselves, I have :
<table>
<tr>
<td>Destinations :</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_educationalDestinations['destination']; ?></td>
</tr>
<?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
</table>
If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working.
Thanks.First off, you need to get the database tables so that there is a relationship between them.
In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
table_packages
packageID
package
packageDetails
destination
destinationDetails
etc
If there is a one to many relationship, then the following would be true
packages
packageID
package
packageDetails
etc
destinations
destinationID
packageID
destination
destinationDetails
etc
The above assumes that there are many destinations to one package with the relationship coloured orange.
Once you have the above correct you can apply your query as follows
SELECT *
FROM packages
INNER JOIN destinations
ON packages.packageID = destinations.packageID
WHERE packages.packageID = %s
ORDER BY destination ASC
The above query will show all packages with relevant destinations -
Problem getting results with no unique key in a joined query
I created a descriptor to do a joined query, which generated a query in log as:
Select t0.empID,t1.empID, t1.phone from Emp t0, Phone t1
where t0.empId=t1.empId and t0.empId=1001
When I run it, I got the result as:
1001,1001,9999999
1001,1001,9999999
The correct result should be (I copy and paste the query from log into SQL-Plus):
1001,1001,9999999
1001,1001,1234455
I suspect this is caused by Toplink caching objects by primary key. I wonder if anybody has a solution for this.
My descriptor is created using WorkBench. Emp is the primary table, Phone as additional table linked by foreignKey empId.
The join is implemented by modifying the descriptor as the following:
ExpressionBuilder builder = new ExpressionBuilder();
descriptor.getQueryManage()
.setMultipleTableJoinExpression(
builder.getField("EMP.EMPID").equal(
builder.getField("EMP.EMPID")));
descriptor.disableCacheHits();
I'd really appreciate your help.I am implementing a people search function. The batch reading is quite expensive if toplink does a read query for every person. A customized query requires only one database access, the other way may requires hundreds.
I don't want to use the cache either in this case because the database is also accessed by legacy system which cann't notify toplink any updates.
I opened a TAR on this and the solution I got is to use ReportQuery rathen than ReadAllQuery. The only problem here is that now I have to map the query result to my class manually. -
Different selection in a single query according to an ID
Hi
I'm looking for a way to perform different selections in a single query according to a specific value:
Here is the first selection:
select g.*,gf.*,gs.*
FROM graphs g
LEFT JOIN graph_frames gf on g.graph_id = gf.graph_id
LEFT JOIN graph_sets gs on gf.frame_id = gs.frame_id
WHERE g.graph_id = :IDHere is the second selection:
SELECT gg.graph_id, gg.graph_name
FROM generic_graphs gg
INNER JOIN generic_graph_frames ggf on gg.graph_id = ggf.graph_id
INNER JOIN generic_graph_sets ggs on ggf.frame_id = ggs.frame_id
WHERE gg.graph_id = :IDNow, the ID cannot be in both the tables and I want to perform that in a single query, UNION cannot be applied since the tables are different.
Any ideas?
Edited by: BluShadow on 14-Sep-2011 09:09
added {noformat}{noformat} tags. Please read {message:id=9360002} and learn to do this yourself.Example of consolidating the columns...
SQL> ed
Wrote file afiedt.buf
1 with t as (select &id as id from dual)
2 select e.empno, e.ename, e.job, e.mgr, d.deptno, d.dname, d.loc
3 from (select * from emp cross join t where empno = t.id) e
4 full outer join
5 (select * from dept cross join t where deptno = t.id) d
6* on (1=1)
SQL> /
Enter value for id: 7521
old 1: with t as (select &id as id from dual)
new 1: with t as (select 7521 as id from dual)
EMPNO ENAME JOB MGR DEPTNO DNAME LOC
7521 WARD SALESMAN 7698
SQL> /
Enter value for id: 10
old 1: with t as (select &id as id from dual)
new 1: with t as (select 10 as id from dual)
EMPNO ENAME JOB MGR DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
SQL>Though, this would be considered poor design because you are trying to query two disperate things, so they should be treated differently. i.e. in my example, I should already know if I'm querying an employee or a department beforehand. -
Filter on "---" in Left Outer Join Query
Hi guys,
very basic question but I have not found an answer, yet. I built an left outer join MDO query and need to select all those dataset that did not find a "partner", that is fields are set to "---". However, I do not manage to filter on '---', NULL...
When using SQL, it appears to be a String "---" but in MDO???Hey guys, found out that IS NULL needs to be used in query. Anyway, it appears to cause problems somewhere else.
I placed an IS NULL filter expression inside a join query but query did not return any results when called in by transaction. After removing this line, both NULL and NOT NULL data were returned. When used in test mode, IS NULL was working fine... -
Hi Experts,
I am facing a problem with left outer join query. Am using one standard table and ztable for this join. My problem is values are not extracted from the Ztable.
Query:
SELECT b~lifnr b~belnr b~gjahr b~xblnr b~shkzg b~blart b~zfbdt b~budat b~wrbtr
b~wskto b~zlspr s~EXTRACT_STATUS s~maturity_date FROM bsik AS b
LEFT OUTER JOIN zprm_rvne_sapdoc AS s
ON s~belnr EQ b~belnr
AND s~gjahr EQ b~gjahr
INTO CORRESPONDING FIELDS OF TABLE it_join
WHERE b~zlsch = p_zlsch
AND b~xblnr IN so_invno
ORDER BY b~lifnr b~xblnr.
I have all entries of BSIK table in Ztable with extract status as Y but this query is not fetching extract status and maturity date of ztable so it is blank in the internal table.
Need solution.
Regards
Sridevi SHi,
see the sample wiki for writing the Left outer join
http://wiki.sdn.sap.com/wiki/display/Snippets/EmployeeInfotype0000to9999ChangeHistory
Specifying Two or More Database Tables as a Left Outer Join
The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
SELECT...
FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>
<options>
<tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The OUTER addition is optional. The tables are linked in the same way as the inner join with the one exception that all lines selected from <tab> are included in the final selection. If <dbtab> does not contain any lines that meet the condition <cond>, the system includes a single line in the selection whose columns from <dbtab> are filled with null values.
In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In addition to the above restrictions:
EQ or = is the only permitted relational operator.
There must be at least one comparison between columns from <tab> and <dbtab>.
The WHERE clause may not contain any comparisons with columns from <dbtab>. All comparisons using columns from <dbtab> must appear in the condition <cond>.
If we have two tables named stud1,stud2 with the following data
Stud1: id Name stud2: id Name
1 xxx 1 aaa
2 yyy 2 bbb
3 zzz 4 ccc
4 www 6 ddd
When we use Left Outer Join we get the output as:
1 aaa
2 bbb
3 <Null>
4 ccc
When we use Right Outer Join we get the output as:
1 aaa
2 bbb
4 ccc
<Null> ddd
When we use Full Outer Join we get the output as:
1 aaa
2 bbb
3 <Null>
4 ccc
<Null> ddd
Prabhudas -
hi
i am encountering error like the values not getting populated in internal table though values are in dbtable...so if u can help me out in the join query it will be of gr8 help
SELECT a1~guid a1~posting_date a1~process_type
b1~sales_org b1~division b1~dis_channel
INTO CORRESPONDING FIELDS OF TABLE it_ordel
FROM ( ( crmd_orderadm_h AS a1 INNER JOIN crmd_link AS c1 ON a1~guid = c1~guid_hi )
INNER JOIN crmd_orgman AS b1 ON c1~guid_hi = b1~guid )
WHERE c1~objtype_hi = '05'
AND c1~objtype_set = '21'.
AND a1~process_type IN so_prst
AND a1~posting_date IN so_podt
AND b1~division IN so_div.
thnxSELECT a1~guid a1~posting_date a1~process_type
b1~sales_org b1~division b1~dis_channel
INTO CORRESPONDING FIELDS OF TABLE it_ordel
FROM ( ( crmd_orderadm_h AS a1 INNER JOIN crmd_link AS c1 ON a1~guid = c1~guid_hi )
INNER JOIN crmd_orgman AS b1 ON c1~guid_hi = b1~guid )
WHERE c1~objtype_hi = '05'
AND c1~objtype_set = '21'.
AND a1~process_type IN so_prst
AND a1~posting_date IN so_podt
AND b1~division IN so_div.
SELECT a1~guid a1~posting_date a1~process_type
b1~sales_org b1~division b1~dis_channel
INTO CORRESPONDING FIELDS OF TABLE it_ordel
FROM ( ( crmd_orderadm_h AS a1 INNER JOIN crmd_link AS c1 ON a1~guid = c1~guid_hi )
INNER JOIN crmd_orgman AS b1 ON c1~guid_hi = b1~guid )
WHERE c1~objtype_hi = '05'
AND c1~objtype_set = '21' ". delete that period its wrong
AND a1~process_type IN so_prst
AND a1~posting_date IN so_podt
AND b1~division IN so_div. -
Inner Join. How to improve the performance of inner join query
Inner Join. How to improve the performance of inner join query.
Query is :
select f1~ablbelnr
f1~gernr
f1~equnr
f1~zwnummer
f1~adat
f1~atim
f1~v_zwstand
f1~n_zwstand
f1~aktiv
f1~adatsoll
f1~pruefzahl
f1~ablstat
f1~pruefpkt
f1~popcode
f1~erdat
f1~istablart
f2~anlage
f2~ablesgr
f2~abrdats
f2~ableinh
from eabl as f1
inner join eablg as f2
on f1ablbelnr = f2ablbelnr
into corresponding fields of table it_list
where f1~ablstat in s_mrstat
%_HINTS ORACLE 'USE_NL (T_00 T_01) index(T_01 "EABLG~0")'.
I wanted to modify the query, since its taking lot of time to load the data.
Please suggest : -
Treat this is very urgent.Hi Shyamal,
In your program , you are using "into corresponding fields of ".
Try not to use this addition in your select query.
Instead, just use "into table it_list".
As an example,
Just give a normal query using "into corresponding fields of" in a program. Now go to se30 ( Runtime analysis), and give the program name and execute it .
Now if you click on Analyze button , you can see, the analysis given for the query.The one given in "Red" line informs you that you need to find for alternate methods.
On the other hand, if you are using "into table itab", it will give you an entirely different analysis.
So try not to give "into corresponding fields" in your query.
Regards,
SP. -
Cartesian Join query optimization
Hello Experts!
I have a question about cartesian join query which might look a bit weird.
Assume the SQL query like that:
SELECT DISTINCT A.NAME
FROM A, B, C;
Here we have cartesian join for 3 tables A, B and C.
It looks to me, in order to get the result for such a particular SQL tables/sets B and C need to be accessed only to ensure they return at least 1 row (otherwise result set is empty), query table A, but there is no actual need to join the data.
If you run such a query Oracle is doing full table scans and actually joins the data.
Yes, DBMS is doing exactly what you are asking for, but I wonder if there is any way (SQL hint or db parameter or anything else) to enforce more optimal access path here?
Obvious solution to remove B and C tables from the SELECT statement is not acceptable. :-)
Thank you!Your statement in the other thread indicates you don't understand how the BI prompts actually work because you say you want it to do something that doesn't make sense for it to do.
Of course Product and Account levels will be constrained to the interval you specified. It wouldn't make sense for them not to be. Because that would mean returning data for based on product and account levels that has a different open data range than what you specified.
All UI prompt dialogs I have seen use AND relationships between the parameters. If there are three parameters (A, B, C) then the ultimate relationship is 'A AND B AND C'; not 'A OR (B AND C)', 'A AND (B OR C)', 'A OR (B OR C).
Unless the tool allows you to select OR relationships you need to use a separate dialog box (parameter dialog) for each condition set.:-)
I understand how BI prompts work and basically agree on your comment, but there are two problems here:
1. I need to convince the customer his original requirements are not valid. Customer want it to work different way and there are some reasons why.
2. There are pretty large dimensions and fact tables used here, so when I choose filter criteria for the Product (which is small table) to populate/recalculate prompt values, large SR dimension and fact tables are joined too, and if there are Account dimension filters added, huge Account dimension will be added as well. This looks to be a bit sub-optimal for just populating the Product prompt values.
Of course, technically this is solvable, but requires to put some extra effort and does not solve the 1st issue.
That other link doesn't explain the sample code you posted in this thread. Post the actual query that is being generated and the query that you want to actually use.This is what is generated:
>
select distinct T311691.X_CUST_SUBTYPE as c1
from
WC_LOV_SR_AREA_H T311695,
WC_LOV_PROD_H T311687,
WC_LOV_CUST_TYPE_H T311691,
W_SRVREQ_D T302384 /* Dim_W_SRVREQ_D */
where ( T311687.LEV1 = 'Product X' and T311691.X_CUST_TYPE = 'Business' and T302384.OPEN_DT between TO_DATE('2012-03-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2012-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
order by c1
>
This is what is actually needed to query this data:
>
select distinct T311691.X_CUST_SUBTYPE as c1
from
WC_LOV_CUST_TYPE_H T311691
where ( T311691.X_CUST_TYPE = 'Business' )
order by c1
Maybe you are looking for
-
I have had my iPad 2 since the start of June 2011. There are a lot of times when it works great, but I have had trouble sometimes when I sync. Prior problems were with SQLite3.dll, but got help copying that file to the right place. I have also comple
-
Mass change of telephone extension within SU01
Hi! We would like to change for alls the users within SU01 the telephone extension within tcode SU01. Unfortunately the tcode SU10 does not have the option to mass change the telephone extension. Is there some possibilities to do this via BADI/user e
-
My IPad says it has not backed up. I tried but it won't, why?
-
Internet based management of SCCM clients and management points ?
We have an SCCM backend infrastructure which is used to manage what is in affect multiple external organizations over the internet. Currently each SCCM client is managed by the primary server directly over the internet. Am I right that we could pla
-
Need to Disable Sales Order Header Text
Hi everyone, My problem goes like this: We have a header text in the sales order that is being filled in by an external program. Since this header text is being read by the same external program, it is very important that the user does not change t