LEFT OUTER JOIN, Problem in POST-QUERY TRIGGER
Hi,
Please guide for the following
I wrote below query in POST-QUERY Trigger of a TABULAR DATA BLOCK, having only one text item, called INVENTORY_ITEM
select c.cat||' '||s.subcat||' '||l1.lvl1 ITEM INTO :DATABLOCK.INVENTORY_ITEM
from itemcat c
LEFT OUTER JOIN itemsubcat s on (c.catid = s.catid)
LEFT OUTER JOIN lvl1 l1 on (s.subcatid = l1.subcatid)
When I compile the module an error is generated
*" Encountered the symbol 'LEFT' when expecting one of the following ,; for group having intersect minus order start union where connect ".*
Above query is working fine in ORACLE SQL DEVELOPER .
Any solution please.
Regards,
Difference
Similar Messages
-
Multiple left outer join in single select query
My client requires to apply multiple left outer join in single select query.
Tell me how it is possible . tell me if we can use native sql query.HI vineet,
Using multile left join is possible but it reduce performance as it takes a long time to retrieve data.
The following code would help you in knowing how to use multiple left join
REPORT test.
PARAMETERS:
p_auart LIKE vbak-auart.
DATA:
BEGIN OF fs_sales,
auart LIKE vbak-auart,
vbeln LIKE vbak-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
netwr LIKE vbap-netwr,
END OF fs_sales,
fs_temp LIKE fs_sales.
DATA:
t_sales LIKE STANDARD TABLE OF fs_sales.
SELECT k~auart
k~vbeln
p~posnr
p~matnr
p~netwr
INTO TABLE t_sales
FROM vbak AS k
OUTER JOIN vbap AS p
ON k~vbeln = p~vbeln
WHERE auart = p_auart
AND p~netwr LT 1000.
IF sy-subrc EQ 0.
WRITE:/5 'Sales Document'(001),/,
15 'Sales Document Item'(002),
40 'Material Number'(003).
sort t_sales by netwr ascending.
LOOP AT t_sales INTO fs_sales.
WRITE:/ fs_sales-vbeln under text-001.
LOOP AT t_sales INTO fs_temp WHERE vbeln = fs_sales-vbeln.
WRITE:/ fs_temp-posnr under text-002,
fs_temp-matnr under text-003.
ENDLOOP.
ENDLOOP.
ELSE.
MESSAGE 'No Record Found' TYPE 'I'.
ENDIF.
But i would suggest you to go with views instead of using multiple joins..
Best of luck,
Bhumika -
Left outer join problem -- need feedback
using crystal 2008
haveing prolbems with a left outerjoin to get a blank field(null) to show up.
basically i have some po line have have long descriptions or text fields that i want to include with the report. Below is my sql statement. I have written a formula with a join between 2 fields to get the report to work- this does but- it leave the polines off that do not have a long description. I have tried left outer joins but seem to be having problems. The long description field where the data is actually at is under my po.line table, although serveral area have long description fields -
*one note i had to add a duplicate table to the field to get some items in my header to work properly - not sure if this is effecting the report or not.
OK- when I set up the link to a LO join enforce from = to
and dont add the ldtext.field to the report the left outjoin works(but no long description)and all my line items show up.
1. when I keep the same join and add either just the ld.text field to the report it comes back with a error saying invalid table
2. when i use my formula that joins the ld.text and po.line and place it in the report with the same left outerjoin i get the same failure.
3. when i dont reference the ldtext(field) at all in the report it works fine w/ the lo join
4. when i Dont use a left outer join and use my formula(see below)
if not isnull(({LONGDESCRIPTION.LDTEXT }))
then {POLINE.DESCRIPTION}+{LONGDESCRIPTION.LDTEXT}
else {POLINE.DESCRIPTION}
and link from poline.ld
to ld.ldtext - my formula works and populates the po.line and the ld.text together - except that any po.line with no description will not show up. Like its not there.
Not sure what to do?
here is my current sql statement with the longdescription field in the select statement
here is the error statement i am getting:
Failed to retrieve data from the database:
Details:42000[intersolv][odb sql base driver][sql base] 00906 itn invalid table name[database vendor code:906]
sql statement:
SELECT "PO"."PONUM", "PO"."STATUS", "PO"."VENDOR",
"COMPANIES"."NAME", "COMPANIES"."ADDRESS1",
"COMPANIES"."ADDRESS2", "COMPANIES"."ADDRESS3",
"COMPANIES"."ADDRESS4", "COMPANIES"."PHONE",
"COMPANIES"."FAX", "COMPANIES_1"."NAME",
"COMPANIES_1"."ADDRESS1", "COMPANIES_1"."ADDRESS2",
"COMPANIES_1"."ADDRESS3", "COMPANIES_1"."ADDRESS4",
"COMPANIES_1"."CONTACT", "COMPANIES_1"."PHONE",
"COMPANIES_1"."FAX", "PO"."PURCHASEAGENT",
"PO"."ORDERDATE",
"PO"."REQUIREDDATE", "PO"."PAYMENTTERMS",
"PO"."SHIPVIA", "PO"."FREIGHTTERMS", "PO"."FOB",
"POLINE"."DESCRIPTION", "POLINE"."ITEMNUM",
"POLINE"."ORDERQTY", "POLINE"."UNITCOST",
"POLINE"."LOADEDCOST", "POLINE"."POLINENUM",
"PO"."SHIPTOATTN", "LONGDESCRIPTION"."LDTEXT"
FROM ("MAXIMO"."PO" "PO" LEFT OUTER JOIN
"MAXIMO"."LONGDESCRIPTION" "LONGDESCRIPTION" ON "PO"."LDKEY"="LONGDESCRIPTION"."LDKEY"),
"MAXIMO"."POLINE" "POLINE",
"MAXIMO"."COMPANIES" "COMPANIES_1",
"MAXIMO"."COMPANIES" "COMPANIES"
WHERE ("PO"."PONUM"="POLINE"."PONUM") AND ("PO"."VENDOR"="COMPANIES_1"."COMPANY") AND ("PO"."SHIPTO"="COMPANIES"."COMPANY") AND "PO"."PONUM"='3386-053'If you took the time to read this thanks.... turns out... and I just want to pull my hair out over this. My connection had a old odbc driver so somehow it would not allow a left outer join....go figure - weeks of agony over that..... thanks ....have to say love this forum.
-
Error in making left outer join to a nested query
i am writing this query getting error here i am using nested query with that i am making join it is giving error
SQL
SELECT
* FROM IVItem INNER JOIN
IVPackSize_Mst ON IVItem.PackSizeID = IVPackSize_Mst.Id
left outer join IvItemGenericLink on IvItemGenericLink.itemID=IVItem.Id
Select GenericId from
IvItemGenericLink where ItemID=IVItem.Id and rownum <=1
)x
and x on IvItemGenericLink.GenericId=x.GenericId;
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
give me and suggestioni am using left outer join at virtual table say x your gave me its equivalent
EXISTS (SELECT 1 FROM IvItemGenericLink G
WHERE G.ITEMID =V.ID
AND G.GenericId = L.GenericId)-----its i guess inner join
i am not confirmed that why iam asking this i guess i have to use this
as i use keyword inner join for inner join and for left join i use
left outer join
EXISTS (SELECT 1 FROM IvItemGenericLink G
WHERE G.ITEMID =V.ID
AND G.GenericId(+) = L.GenericId)-----its i guess left outer join
left outer join
Select GenericId from
IvItemGenericLink where ItemID=IVItem.Id and rownum <=1
)*x*
IvItemGenericLink.GenericId=x.GenericId
-------------------Statement U Gave in this--------------------------------------------------------------------------
SELECT *
FROM IVITEM V, IVPACKSIZE_MST M , IVITEMGENERICLINK L,
WHERE V.PACKSIZEID = M.ID
AND V.ID = L.ITEMID (+)
AND EXISTS (SELECT 1 FROM IvItemGenericLink G
WHERE G.ITEMID =V.ID
AND G.GenericId = L.GenericId)
-------------------Statement U Gave in this--------------------------------------------------------------------------
is this equivalent to left outer join
*AND EXISTS (
SELECT 1 FROM IvItemGenericLink G*
WHERE G.ITEMID =V.ID
*AND G.GenericId = L.GenericId
please tell me this in this regard -
Problem with post query trigger
Hi,
I have a multi record block and there is a post-query trigger on it. Based on values of this block I populate other values over the other control block.
I wrote code in post-query trigger and when I execute the query and go to last but one record. The values in the control block are from last record instead of last but one record. Pls help me to fix
Thanks,if you want to see the data in the control block synchronized with the database block then use the WHEN-NEW-RECORD-INSTANCE and not the POST-QUERY.
with the POQ you add additional data (in non-basetable-items) to the records in the database block -
Left Outer Join Problem for Multiple Condition
Hi This is the code and I want to return the vlaues evens if it is not ther so my Sysntax is not right for that can you plz help me
SELECT ap.descripcion AS Production_Description,
conceptes.descripcion AS Concepts_Description ,
um.Nomenclatura AS Unit_Measure ,
-- real_daily_detail.FechaProduccion AS Production_Date ,
period.Codigo as June,
period.anio AS YEAR_08 ,
rmd.Valor AS Values_Monthly,
budgetd.Valor as Budget
FROM sgr_area_produccion ap ,
sgr_conceptos conceptes ,
SGR_Unidad_Medida um ,
SGR_Unidad_Produccion up ,
SGR_Unidad_Area_Produccion uap ,
SGR_Real_Mensual_Detalle rmd ,
SGR_Periodo period ,
SGR_Real_Mensual rm ,
SGR_Presupuesto budget ,
SGR_Presupuesto_Detalle budgetd
where uap.ID_Unidad_Produccion = up.ID_Unidad_Produccion (+)
and uap.ID_Area_Produccion = ap.ID_Area_Produccion (+)
and rm.ID_Area_Produccion = uap.ID_Area_Produccion (+)
and rm.ID_Unidad_Produccion = uap.ID_Unidad_Produccion (+)
and rmd.ID_Unidad_Produccion = rm.ID_Unidad_Produccion (+)
and rmd.ID_Area_Produccion = rm.ID_Area_Produccion (+)
and rmd.ID_Periodo = rm.ID_Periodo (+)
and period.ID_Periodo = rm.ID_Periodo (+)
and conceptes.ID_Concepto = rmd.ID_Concepto (+)
and budget.ID_Unidad_Produccion = uap.ID_Unidad_Produccion(+)
and budget.ID_Area_Produccion = uap.ID_Area_Produccion (+)
and budget.ID_Unidad_Produccion = budgetd.ID_Unidad_Produccion
and budget.ID_Area_Produccion = budgetd.ID_Area_Produccion (+)
and budget.ID_Periodo = budgetd.ID_Periodo (+)
and period.ID_Periodo = budget.ID_Periodo (+)
and period.Codigo = 'JUNIO-08'
and conceptes.ID_Concepto = budgetd.ID_Concepto (+)
and daily.ID_Area_Produccion = uap.ID_Area_Produccion (+)
and daily.ID_Unidad_Produccion = uap.ID_Unidad_Produccion (+)
and dailyd.ID_Unidad_Produccion = daily.ID_Unidad_Produccion(+)
and dailyd.ID_Area_Produccion = daily.ID_Area_Produccion (+)
and period.ID_Periodo = daily.ID_Periodo (+)
and conceptes.ID_Concepto = dailyd.ID_Concepto (+)
and um.ID_Unidad_Medida = conceptes .ID_Unidad_Medida (+)Oracle old outer join syntax had more restrictions than more recent ANSI outer join syntax. I do'nt want to emulate compiler and go through your code to spot any possible problems, even more if you cannot say also the exact error or exact problem what you get.
And bear in mind that for outer joins THERE IS DIFFERENCE [url http://www.gplivna.eu/papers/sql_join_types.htm#p6.4]between join conditions and predicates in where clause.
Gints Plivna
http://www.gplivna.eu -
Not using Index when SDO_RELATE in Spatial Query is used in LEFT OUTER JOIN
I want to know for every City (Point geometry) in which Municipality (Polygon geometry) it is.
Some cities will not be covered by any municipality (as there is no data for it), so its municipality name should be blank in the result
We have 4942 cities (point geometries)
and 500 municipalities (polygon geometry)
SELECT T1.NAME as City, T2.NAME as Municipality
FROM CITY T1
LEFT OUTER JOIN MUNICIPALITY T2 ON SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'The explain plan for this query is:
SELECT STATEMENT
FILTER
Filter Predicates
MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'
MERGE JOIN
TABLE ACCESS CITY FULL 11
BUFFER SORT 100605
TABLE ACCESS MUNICIPALITY FULL 20So the cost is in the BUFFER (whatever that is), it takes +2000 seconds to run this, it is not using the spatial index.
And we are not getting all rows, but only the ones interacting with a municipality, e.g. 2436 rows.
But I want all rows, including the ones not interacting with any Municipality.
When we want only those cities that actually are in a municipality, I use a different query and it will use the index.
SELECT T1.NAME as City, T2.NAME as Municipality
FROM CITY T1, MUNICIPALITY T2
WHERE SDO_RELATE(T1.GEOM, T2.GEOM, 'MASK=ANYINTERACT') = 'TRUE'I get (only) 2436 rows (as expected) in 5 seconds (it is fast) and the explain plan shows it is using the spatial index.
But in this case, I am not getting any cities not inside any municipality (of course)
SELECT STATEMENT
NESTED LOOPS
TABLE ACCESS MUNICIPALITY FULL 22
TABLE ACCESS CITY BY INDEX ROWID 22
DOMAIN INDEX CITY_SDX 0
Access Predicates
MDSYS.SDO_RTREE_RELATE(T1.GEOM, T2.GEOM, 'mask=ANYINTERACT querytype=window ') = 'TRUE'I always thought a LEFT OUTER JOIN would return all rows from the Table, whatever happens in the next,
but it seems the query has been rewritten so that it is now using a Filter Predicate in the end, which filters those geometries having no interaction.
As an example I also do thing alphanumerically, I do get 4942 rows, including the ones which have no Municipality name.
In this case the names must match, so its only for testing if the LEFT OUTER JOIN returns stuff correctly, which it does in this case.
SELECT T1.NAME as City, T2.NAME as Municipality
FROM CITY T1
LEFT OUTER JOIN MUNICIPALITY T2 ON T1.NAME = T2.NAMEIs this an Oracle Spatial bug, e.g. not return 4942 rows, but only 2436 rows on the first query?
Note all tests performed on Oracle 11g R2 (11.2.0.1.0)Patrick,
Even so, your geoms in the relate were the wrong way around.
Also, I don't recall you saying (or showing) that you wanted the municipality geometry returned. Still,
no matter, easy to do.
Here are some additional suggestions. I don't have your data so I have had to use some of my own.
set serveroutput on timing on autotrace on
SELECT T1.SPECIES as City,
(SELECT T2.ADMIN_NAME FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as Municipality,
(SELECT T2.GEOM FROM AUSTRALIAN_STATES T2 WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE') as geom
FROM GUTDATA T1;
762 rows selected
Elapsed: 00:00:21.656
Plan hash value: 2160035213
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 762 | 49530 | 5 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES | 1 | 115 | 0 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | AUSTRALIAN_STATES_GEOM_SPX | | | 0 (0)| 00:00:01 |
| 3 | TABLE ACCESS BY INDEX ROWID| AUSTRALIAN_STATES | 1 | 115 | 0 (0)| 00:00:01 |
|* 4 | DOMAIN INDEX | AUSTRALIAN_STATES_GEOM_SPX | | | 0 (0)| 00:00:01 |
| 5 | TABLE ACCESS FULL | GUTDATA | 762 | 49530 | 5 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
24576 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksThe above can look messy as you add more (SELECT ...) attributes, but is is fast (though can't use in Materialized Views).
/* The set of all cities not in municipalities */
SELECT T1.SPECIES as City,
cast(null as varchar2(42)) as municipality,
cast(null as sdo_geometry) as geom
FROM GUTDATA T1
WHERE NOT EXISTS (SELECT 1
FROM AUSTRALIAN_STATES T2
WHERE SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
UNION ALL
/* The set of all cities in municipalities */
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
INNER JOIN
AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
762 rows selected
Elapsed: 00:00:59.953
Plan hash value: 2854682795
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 99 | 13450 | 38 (87)| 00:00:01 |
| 1 | UNION-ALL | | | | | |
|* 2 | FILTER | | | | | |
| 3 | TABLE ACCESS FULL| GUTDATA | 762 | 49530 | 5 (0)| 00:00:01 |
|* 4 | DOMAIN INDEX | AUSTRALIAN_STATES_GEOM_SPX | | | 0 (0)| 00:00:01 |
| 5 | NESTED LOOPS | | 61 | 10980 | 33 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL| AUSTRALIAN_STATES | 8 | 920 | 3 (0)| 00:00:01 |
|* 7 | TABLE ACCESS FULL| GUTDATA | 8 | 520 | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter( NOT EXISTS (SELECT 0 FROM "AUSTRALIAN_STATES" "T2" WHERE "MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE'))
4 - access("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"(:B1,10000,0.5,'UNIT=M'))='TRUE')
7 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
131072 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksMuch slower but Materialized View friendly.
This one is a bit more "natural" but still slower than the first.
set serveroutput on timing on autotrace on
/* The set of all cities in municipalities */
WITH municipal_cities As (
SELECT T1.ID as City,
T2.ADMIN_NAME as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
INNER JOIN
AUSTRALIAN_STATES T2 ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
SELECT T1.ID as City,
T2.Municipality as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
LEFT OUTER JOIN
municipal_cities T2
ON (T2.CITY = T1.ID);
762 rows selected
Elapsed: 00:00:50.228
Plan hash value: 745978991
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 762 | 44196 | 36 (3)| 00:00:01 |
|* 1 | HASH JOIN RIGHT OUTER| | 762 | 44196 | 36 (3)| 00:00:01 |
| 2 | VIEW | | 61 | 3294 | 33 (0)| 00:00:01 |
| 3 | NESTED LOOPS | | 61 | 10980 | 33 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL | AUSTRALIAN_STATES | 8 | 920 | 3 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | GUTDATA | 8 | 520 | 4 (0)| 00:00:01 |
| 6 | INDEX FAST FULL SCAN| GUTDATA_ID_PK | 762 | 3048 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - access("T2"."CITY"(+)="T1"."ID")
5 - filter("MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
49152 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksFinally, the Pièce de résistance: trick the LEFT OUTER JOIN operator...
set serveroutput on timing on autotrace on
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality,
T2.GEOM as geom
FROM GUTDATA T1
LEFT OUTER JOIN
AUSTRALIAN_STATES T2
ON (t2.admin_name = to_char(t1.ID) OR
SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');
762 rows selected
Elapsed: 00:00:50.273
Plan hash value: 158854308
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 762 | 92964 | 2294 (1)| 00:00:28 |
| 1 | NESTED LOOPS OUTER | | 762 | 92964 | 2294 (1)| 00:00:28 |
| 2 | TABLE ACCESS FULL | GUTDATA | 762 | 49530 | 5 (0)| 00:00:01 |
| 3 | VIEW | | 1 | 57 | 3 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL| AUSTRALIAN_STATES | 1 | 115 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - filter("T2"."ADMIN_NAME"=TO_CHAR("T1"."ID") OR
"MDSYS"."SDO_ANYINTERACT"("T2"."GEOM","SDO_GEOM"."SDO_BUFFER"("T1"."GEOM",10000,0.5,'UNIT=M'))='TRUE')
Statistics
7 user calls
0 physical read total bytes
0 physical write total bytes
0 spare statistic 3
0 commit cleanout failures: cannot pin
0 TBS Extension: bytes extended
0 total number of times SMON posted
0 SMON posted for undo segment recovery
0 SMON posted for dropping temp segment
0 segment prealloc tasksTry these combinations to see what works for you.
Interestingly, for me, the following returns absolutely nothing.
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality
FROM GUTDATA T1
LEFT OUTER JOIN
AUSTRALIAN_STATES T2
ON (SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE')
MINUS
SELECT T1.SPECIES as City,
T2.ADMIN_NAME as Municipality
FROM GUTDATA T1
LEFT OUTER JOIN
AUSTRALIAN_STATES T2
ON (t2.admin_name = to_char(t1.ID) OR
SDO_ANYINTERACT(T2.GEOM, SDO_GEOM.SDO_BUFFER(T1.GEOM,10000,0.5,'UNIT=M')) = 'TRUE');(I leave it to you to see if you can see why as the LEFT OUTER JOIN seems to be working correctly for me but I am not going to dedicate time to detailed checking of results.)
Note all tests performed on Oracle 11g R2 (11.2.0.1.0)
If you get the answer you want: mark the post as answered to assign points.
regards
Simon -
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 -
Query slow when exctract column from a left outer join
Hi,
in my 2008 i've a query like this:
select a1, a2,a3
from ....
LEFT OUTER JOIN (select a2,a3....
from my_tab_with_170Milionrecords
if I exclude a2,a3 from principal select the elapsed is about 1
If I include a2,a3 the elapsed is abount 40s
How can solve this?
RegardsI posted an example how re-write it
select a1, a2,a3
from ....
LEFT OUTER JOIN
my_tab_with_170Milionrecords ON ........
Instead of subquery LEFT JOIN user the standard LEFT JOIN..
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
BI 7.0 Infoset - Infocube - Left outer join - query
Hi Expert,
A infoset contain Infocube and ODS, linked with left outer join, common fields are PO,PO item. PO account assignment ODS have three keyfields: PO Doc.,Item,account Assignment .
PO Infocube <b>PO Account Assignment ODS</b>
PO PO item Amt<b>PO Doc. Item AccAssignment Cost object</b>
1000 10 230 <b>1000 10 1 CC1</b>
1001 10 250 <b>1002 10 1 CC1</b>
1002 10 150 <b>1002 10 2 CC2</b>
in BEx result are like this:
1000 10 230 1 CC1
1001 10 250 # #
1002 10 150 1 CC1
1002 10 150 2 CC2 ( amount only duplicated)
The issue was that amount gets duplicated. It only occurs if PO has more than one account assignment.
In report, we want show like this
1000 10 230 1 CC1
1001 10 250 # #
1002 10 150 1 CC1
1002 10 # 2 CC2
Any suggestion or input to overcome this issue?
Thanks,
Saran
Message was edited by:
Saravanan KHi,
did you solve your problem? because I have the same issue right now: the left outer join doesn't seem to do its job.
Let me know if you have found a solution, it would be appreciated.
have a nice day,
Dominic -
Problem with XMLTABLE and LEFT OUTER JOIN
Hi all.
I have one problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns correct result but in 10g it doesn't, it is trated as INNER JOIN.
SELECT * FROM v$version;
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
--test for 11g
CREATE TABLE XML_TEST(
ID NUMBER(2,0),
XML XMLTYPE
INSERT INTO XML_TEST
VALUES
1,
XMLTYPE
<msg>
<data>
<fields>
<id>g1</id>
<dat>data1</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
2,
XMLTYPE
<msg>
<data>
<fields>
<id>g2</id>
<dat>data2</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
3,
XMLTYPE
<msg>
<data>
<fields>
<id>g3</id>
<dat>data3</dat>
</fields>
<fields>
<id>g4</id>
<dat>data4</dat>
</fields>
<fields>
<dat>data5</dat>
</fields>
</data>
</msg>
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4
3 data5 Here's everything fine, now the problem:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for HPUX: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
--exactly the same environment as 11g (tables and rows)
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4As you can see in 10g I don't have the last row, it seems that Oracle 10g doesn't recognize the LEFT OUTER JOIN.
Is this a bug?, Metalink says that sometimes we can have an ORA-0600 but in this case there is no error returned, just incorrect results.
Please help.
Regards.Hi A_Non.
Thanks a lot, I tried with this:
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x,
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)(+) y ;And is giving me the complete output.
Thanks again.
Regards. -
Need to adjust SQL query for left outer join in Crystal Reports 2008.
I need to change this SQL 2005 query.....
SELECT omnicell_anl.DeviceIDsLastMetricTable.member_id, omnicell_anl.DeviceIDsLastMetricTable.[Device Name],
omnicell_anl.DeviceIDsLastMetricTable.Account, omnicell_anl.labeledLastMetrics.PROPERTY_NAME,
omnicell_anl.labeledLastMetrics.latest_monitor_value
FROM omnicell_anl.DeviceIDsLastMetricTable LEFT OUTER JOIN
omnicell_anl.labeledLastMetrics ON omnicell_anl.DeviceIDsLastMetricTable.member_id = omnicell_anl.labeledLastMetrics.member_id
WHERE
omnicell_anl.labeledLastMetrics.PROPERTY_NAME = ?MyProperty
To this query in Crystal Reports Report Writer:
SELECT omnicell_anl.DeviceIDsLastMetricTable.member_id, omnicell_anl.DeviceIDsLastMetricTable.[Device Name],
omnicell_anl.DeviceIDsLastMetricTable.Account, omnicell_anl.labeledLastMetrics.PROPERTY_NAME,
omnicell_anl.labeledLastMetrics.latest_monitor_value
FROM omnicell_anl.DeviceIDsLastMetricTable LEFT OUTER JOIN
omnicell_anl.labeledLastMetrics ON omnicell_anl.DeviceIDsLastMetricTable.member_id = omnicell_anl.labeledLastMetrics.member_id AND
omnicell_anl.labeledLastMetrics.PROPERTY_NAME = ?MyProperty
I can't seem to get the left outer join function of Crystal Reports to emulate the same SQL query in SQL 2005. Any ideas on how I can create this same query in Crystal 2008?
Thanks,
Dominic
Edited by: Dominic Carissimi on Oct 28, 2008 7:55 PM
Edited by: Dominic Carissimi on Oct 28, 2008 7:56 PMIf you want the list of values for command level parameter then you need to add another command like
select PropertyField from table
and delete the links between this command and the existing command.
Now go to field explorer and edit the command level parameter and make it as dynamic and add the property field from newly added command.
Hope this helps!
Raghavendra -
Restriction to Left Outer Joins in PS Query
Hello I am trying to do Left Outer JOin in PS QUERY. I need to do dept tbl, job code tbl and locatable as left outer joins with JOB Table. Looks like in PS QUERY there is a error message saying as below. Can someone has any workaround to achieve this in PS QUERY. I know I can create a View and use that in PS QUERY but BUsiness Users are dependent on IT, so that doesn't work. Also, adding JOB table multiple times works but I am looking for better solution if anyone had come accorss working through PS QUERY Outer JOins.
Windows Internet Explorer
Left outer joins must be joined to the last record in the query. (139,290)
OK
Thanks,
SC.Hi Mike,
According to your description, you want to improve the performance for your DAX query in SQL Server Analysis Service Tabular model, right? Here is a white paper describes strategies and specific techniques for getting the best performance from your tabular
models, including processing and partitioning strategies, DAX query tuning, and server tuning for specific workloads.
http://msdn.microsoft.com/en-us/library/dn393915.aspx
Since this is a complex DAX query, from a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with Microsoft. Visit this link to see the various
support options that are available to better meet your needs:
http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone
Regards,
Charlie Liao
TechNet Community Support -
Query Of Queries : Error When Trying To Fake Left Outer Join
Hi there
I am trying to replicate a left outer join, combining two query of queries using a method I located here
However, I keep getting an error message..
Here is the code I am using....
<cfquery dbtype="query" name="qry">
SELECT *
FROM returnQry, returnQry2
WHERE returnQry.mediumImage = returnQry2.mediumImage
ORDER BY returnQry.name
</cfquery>
<cfquery name="returnQry3" dbtype="#application.mx#">
SELECT *
FROM trackmeanings AS t
</cfquery>
<cfquery dbtype="query" name="endQry">
SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
FROM qry, returnQry3
WHERE qry.name = returnQry3.sNameTrack
UNION
SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
FROM qry, returnQry3
WHERE #qry.name# NOT IN (#QuotedValueList(returnQry3.sNameTrack)#)
GROUP BY name,nameRcd,mediumImage
</cfquery>
When I try to use the query output in a page, i get the error message "Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition"
Would anyone have any ideas?
Many thanksActually , spoke a little too soon, my query now seems to be outputting duplicates when the value is found on both sides of the union, my group by clause doesnt seem to be eliminating them like it usually does.
My SELECT code now reads
<cfquery dbtype="query" name="endQry">
SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
FROM qry, returnQry3
WHERE qry.name = returnQry3.sNameTrack
GROUP BY name,nameRcd,mediumImage
UNION
SELECT name,nameRcd,mediumImage, 0 AS comments
FROM qry
WHERE qry.name NOT IN (<cfqueryparam
value="#returnQry3.sNameTrack#"
cfsqltype="cf_sql_varchar"
list="yes"
/>)
GROUP BY name,nameRcd,mediumImage
ORDER BY name DESC
</cfquery>
and my ouput...is producing duplicates
<cfoutput query="rc.qryTopTracks" group="name">
#rc.qryTopTracks.name#
</cfoutput>
Would you have any idea of how to eliminate them here? Thanks
Maybe you are looking for
-
Hello Gurus I have a sales order with 5 items, the requirement is suppose all the the 8 items have different delivery dates eg: item 1 - 06.01.2009, item 2 - 15.02.2009, item 3 - 03.03.2009, item 4 - 25.01.2009, item 5 - 03.02.2009. The need is i wa
-
Indesign export of PDFs - images in pdf fragmented, missing metadata
Can anyone help with this one? We use InDesign CS3 to create PDF 1.6's, directly from InDesign export. The metadata contained in the images on the layout normally are visible in the PDF when you control click and select "show metadata" on the image w
-
DVD studio Pro discs still will not play
Hi Folks, no matter what settings I change in DVD studio pro they will not play on computers or any DVD player I try. If I print a copy off with a consumer platform like toast they play it fine.... what are the settings I need toadjust to ensure the
-
HT4623 Unable to update. Error. Pls help.
Unable to check for update. This message prompted when updating. Pls help. How to go about it.
-
Windows 7 ultimate, this program worked fine for the last 5 months and all of a sudden just quit. I erased and put on earlier versions all have same outcome. Click on icon and just looks like time clock just spins. No program opens but says program i