How to generate ANSI SQL syntax mapping
I am not able to force OWB to generate ANSI SQL syntax mapping.
In mapping configuration I have checked "ANSI SQL syntax" On, "Operating mode" is "Set based fail over to row based", "Optimize code" is On.
"PLSQL generation mode" is set to 10gR2.
OWB 10.2.0.4.36, OraDB 10.2.0.4.0
Oracle SQL is based on ANSI sql 92 standards. But not possible to generate queries in ansi sql 92 format?
Similar Messages
-
Generate ANSI SQL with Oracle IKM
Is it possible for ODI to generate ANSI SQL with the Oracle IKM?
I have used ANSI joins in a filter in an interface, now when I run the interface I get the error: ORA-25156: old style outer join (+) cannot be used with ANSI joins.
I would prefer to use ANSI joins in my filters instead of the old style (+) syntax. Is this possible?Sure,
Go to topology, edit your Oracle technology , on SQL tab change it over to ordered joins - clause location - From , you can specify the keywords left join, right join, full outer join etc to get rid of your '(+)' -
ANSI SQL Syntax - What belongs to join-clause and what to where-clause
Hello,
we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
Lets say there is a query like this:
+SELECT *+
FROM employees emp, departments dept
WHERE emp.dept_country = dept.dept_country
AND emp.dept_name = dept.dept_name
AND dept.dept_type = 'HQ'
AND emp.emp_lastname = 'Smith'
Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
Now I have rewritten the query to Ansi Syntax:
+SELECT *+
FROM employees emp
JOIN departments dept
ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
WHERE dept.dept_type = 'HQ'
AND emp.emp_lastname = 'Smith'
Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
+SELECT *+
FROM employees emp
JOIN departments dept
+ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
WHERE emp.emp_lastname = 'Smith'
Can somebody tell me which on is correct?
Is there any definition for that? I couldn't find it in the Oracle Database definition.
I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
Thank you in advance
MarcoHi,
As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
Regards -
Hi all,
I have a simple query
SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
WHERE ALTERNATE_REF LIKE 'PF%'
AND A.alt_ref_code = B.Equip_No
AND B.Dstrct_Code = 'ACME';
which works fine, but I want to convert it to ANSI
SQL syntax, so I tried
SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
WHERE ALTERNATE_REF LIKE 'PF%'
INNER JOIN ON A.alt_ref_code = B.Equip_No
AND B.Dstrct_Code = 'ACME';
but I get
ERROR at line 3:
ORA-00933: SQL command not properly ended
Could some kind soul explain why?
Paul...An example that looks a lot like your example:
SQL> select dept.*
2 , emp.ename
3 from dept, emp
4 where dept.dname like '%A%'
5 inner join on dept.deptno = emp.deptno
6 and emp.sal > 1000
7 /
inner join on dept.deptno = emp.deptno
FOUT in regel 5:
.ORA-00933: SQL command not properly ended
SQL> select dept.*
2 , emp.ename
3 from dept
4 inner join emp on dept.deptno = emp.deptno
5 where dept.dname like '%A%'
6 and emp.sal > 1000
7 /
DEPTNO DNAME LOC ENAME
30 SALES CHICAGO ALLEN
30 SALES CHICAGO WARD
20 RESEARCH DALLAS JONES
30 SALES CHICAGO MARTIN
30 SALES CHICAGO BLAKE
10 ACCOUNTING NEW YORK CLARK
20 RESEARCH DALLAS SCOTT
10 ACCOUNTING NEW YORK KING
30 SALES CHICAGO TURNER
20 RESEARCH DALLAS ADAMS
20 RESEARCH DALLAS FORD
10 ACCOUNTING NEW YORK MILLER
12 rijen zijn geselecteerd.Regards,
Rob. -
Hi,
Is there a performance difference between ansi and old syntax.
The following query
SELECT ITD.display_description
FROM structure_child SC
RIGHT OUTER JOIN structure S ON SC.structure_id = S.structure_id
INNER JOIN structure_level SL ON SL.structure_level_id = S.structure_level_id
INNER JOIN item_type_naming ITN ON ITN.structure_id = S.structure_id
INNER JOIN item_type_description ITD ON ITN.item_type_description_id = ITD.item_type_description_id
AND item_type_id = p_item_type_id
WHERE ( S.structure_id = p_structure_id OR S.structure_id = 0)
and itd.item_type_id = p_item_type_id
ORDER BY structure_level
Runs much slower than the old style query
SELECT ITD.DISPLAY_DESCRIPTION
FROM structure S, structure_child SC, structure_level SL,item_type_naming ITN,
item_type_description ITD
WHERE SC.structure_id(+) = S.structure_id
AND SL.structure_level_id = S.structure_level_id
AND ITN.structure_id = S.structure_id
AND ITN.item_type_description_id = ITD.item_type_description_id
AND item_type_id = p_item_type_id
AND (S.structure_id = p_structure_id OR S.structure_id = 0)
ORDER BY structure_level
Any reasons why this is the case. Also is there any hint I can give to improve the performance.They ought to be the same.
Be sure to run the query twice to ensure the extra time doesn't including parsing, etc.
Do you get the same results?
Are the explain/execution plans the same?
The only caveat I can think of with ANSI joins is that there is a problem using them over a dblink in which one of the remote tables has a LOB column, an error is generated it that case...
Steve -
Hi
How to use ANSI SQL JOINS (9i) for below query
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL1 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
UNION ALL
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL2 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
UNION ALL
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL3 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
EMPNO TNO SAL1
7369 7369 100
7499 7499 1000
7566 7566 400
7782 7782 4000
7369 7369 200
7499 7499 2000
7566 7566 500
7782 7782 5000
7369 7369 300
7499 7499 3000
7566 7566 600
EMPNO TNO SAL1
7782 7782 6000
Regards
MMSELECT EMP.EMPNO,
EMP_T.TNO,
EMP_T.SAL1
FROM EMP
JOIN EMP_T ON ( EMP.EMPNO = EMP_T.TNO )
UNION ALL
SELECT EMP.EMPNO,
EMP_T.TNO,
EMP_T.SAL2
FROM EMP
JOIN EMP_T ON ( EMP.EMPNO = EMP_T.TNO )
UNION ALL
SELECT EMP.EMPNO,
EMP_T.TNO,
EMP_T.SAL3
FROM EMP
JOIN EMP_T ON ( EMP.EMPNO = EMP_T.TNO ) -
Hey,
one of my colleagues managed to create a SQL-statement (in ansi-sql-syntax) that just blocks the session and gives no response at all.
When I rewrote the statement, it gave results within a second.
It's not quite possible to provide a sample-case, but maybe someone here has an idea why the first statement doesn't work, and the second does?
First:
====
SELECT c.CONTRACTID as ENTITEITID,
v.VASTSTELLINGCODE,
'' as INFO,
v.CAMPAGNE
FROM NFD_CONTRACT c
INNER JOIN NFD_OVK o ON o.OVKID = c.OVKID
INNER JOIN NFD_VSTDEFCMP v ON v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
INNER JOIN NFD_BETROKKENPSN_CON psn ON c.CONTRACTID = psn.CONTRACTID
INNER JOIN (SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
else 0
end AS OA_Heeft_E
FROM NFD_AANGIFTE a
WHERE AANGIFTETYPE = 'Oogstaangifte') vst ON psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1
Second:
======
SELECT c.CONTRACTID as ENTITEITID,
v.VASTSTELLINGCODE,
'' as INFO,
v.CAMPAGNE
FROM NFD_CONTRACT c
,nfd_ovk o
,nfd_vstdefcmp v
,nfd_betrokkenpsn_con psn
,(SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA04M_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA04S_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
else 0
end AS OA_Heeft_E
FROM NFD_AANGIFTE a
WHERE AANGIFTETYPE = 'Oogstaangifte') vst
WHERE o.OVKID = c.OVKID
AND v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
AND c.CONTRACTID = psn.CONTRACTID
AND psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1hey riedelmie,
off course the second statement is different.
I rewrote the query so the inner joins are being replaced by where-clauses with the table-names all in the from-clause.
In the second statement there are two extra when-clauses but they should also be in the first statement (the problem is still there, so data could indeed be different, but the problem is the same)
Tnx.
Greetings,
Dave
Message was edited by:
geysemansdave
added text about the when-clauses -
How to generate orm.xml
Hi,
I would like to know how to generate orm.xml, the mapping file for JPA. I am using jdev 10.1.3.0.4.
Thanks in advanceThere is not yet any built in support for this.
What I have been doing is configuring JDev to understand the orm.xml schema so that when editing the file with JDeveloper it can assist me on the available elements and attributes as well as a default structure.
JDeveloper :: Tools -> Preferences -> XML Schema -> Add
jar:file:/C:/oracle/10.1.3.1/preview/jdev/toplink/jlib/toplink-essentials.jar!/orm_1_0.xsd
Now when you wish to create an orm XML instance document in your project you can use:
New -> General -> XML -> XML Document from Schema
Select "Use Registered Schema"
Select the ORM target namespace: http://java.sun.com/xml/ns/persistence/orm
This will give you a basic orm.xml file properly configured which you can then use to define your mappings.
Doug -
How to generate alert from Mapping
Hello,
I know how to generate alrets by configuring ALRTCATDEF, Alert Configuration.
I want to know how we can generate alert from mapping for ex..
If a=b then send the message
and if a!=b then failed the message and throw and alert.
In java or XSLT mapping
Thnaks and Regards
HemantHi Hemanth,
Bhavesh Blog explied to raise alert using UDF,if you want using JAVA or XSLT converth the same code in to JAVA Map,I think it will work.
I had done similar requirement using Mial adapter using Java Mapping.
Regards,
Raj -
Hi there,
I'd like to be able to capture entire SQL that gets executed when our software creates Oracle schema. In this way we can get a SQL script, which then can be executed separately. Can I achieve that with Oracle Enterpreise Manager or any other Oracle client component ?
If so, could you tell me how to do that ?
Thank you.You don't say which version of the database you are using. If it's 9i then you should check out the DBMS_METADATA package. Otherwise, it is possibly to generate the SQL from the data dictionary (ALL_TABLES, ALL_INDEXES, etc) but that's kind of complicated.
Your best option if you want everything is to use the EXPORT utility with this parameter setting ROWS=N.
If you only want a few objects then TOAD has some neat facilities. Not only can TOAD export DDL scripts, it also allows us to capture the SQL and produce scripts from the worksheet. Probably other SQL tools have similar functionality.
Of course, there's no substitute for writing scripts and storing them in source control in the first place.
Cheers, APC -
How to generate serial number in group by sql
I need the query output with record serial number by a group,
Sr No by dept Dept Id Emp Name
========= ===== =======
1 10 aaaaa
1 11 abndddd
2 11 sdfffffff
3 11 s sdfe
4 11 ggg
1 12 dDEWQ
1 13 xccc
2 13 DSAFG
How to generate the first column in the above output using sql?
Thanks in advance
Shrinivasuse the analytic function ROW_NUMBER
here is a small example
SQL> select row_number() over(partition by deptno order by empno) rno, deptno, empno
2 from emp
3 /
RNO DEPTNO EMPNO
1 10 7782
2 10 7839
3 10 7934
1 20 7566
2 20 7788
3 20 7876
4 20 7902
1 30 7499
2 30 7521
3 30 7654
4 30 7698
RNO DEPTNO EMPNO
5 30 7844
6 30 7900
13 rows selected. -
ANSI SQL 92 SYNTAX OUTER JOIN PERFORMANCE ISSUE
Good Morning
Could anyone explain why the excution time for these two (ment to be identical)
queries run so differently.
oracle syntax execution time 1.06 seconds
select COUNT(*) from
PL_EVENT_VIEW pev,
PL_EVENT_STAFF_VIEW pesv
WHERE pev.EVENT_ID=PESV.EVENT_ID(+)
AND pev.WEEKS=PESV.WEEK_NUM(+)
AND pev.event_id=2520
ansi sql 92 syntax execution time 7.05 seconds
select COUNT(*) from
PL_EVENT_VIEW pev
LEFT JOIN PL_EVENT_STAFF_VIEW pesv
ON (pev.EVENT_ID=PESV.EVENT_ID
AND pev.WEEKS=PESV.WEEK_NUM)
WHERE pev.event_id=2520
Thanks
David HillsBTW Oracle outer join operator (+) and ANSI SQL OUTER JOIN syntax are NOT equivalent. Consider following:
DROP TABLE T1;
CREATE TABLE T1 (C1 NUMBER);
DROP TABLE T2;
CREATE TABLE T2 (C2 NUMBER);
DROP TABLE T3;
CREATE TABLE T3 (C3 NUMBER);
-- Following SELECT works:
SELECT COUNT(*)
FROM T1, T2, T3
WHERE C2 = C1
AND C3(+) = C1
COUNT(*)
0
-- But:
SELECT COUNT(*)
FROM T1, T2, T3
WHERE C2 = C1
AND C3(+) = C1
AND C3(+) = C2
AND C3(+) = C1
ERROR at line 4:
ORA-01417: a table may be outer joined to at most one other table
-- However with ANSI syntax:
SELECT COUNT(*)
FROM T1
JOIN T2 ON (C2 = C1)
LEFT JOIN T3 ON (C3 = C1 AND C3 = C2)
COUNT(*)
0 -
How to generate synthetic rows (raw(16) guid cols) in one SQL statement?
We're populating a table containing two GUID columns:
create table object
( object_guid raw(16) primary key
, project_guid raw(16)
)All object GUIDs are unique (thus the PK), and each object belongs to a given project (should be a FK to some project table). We want N objects / rows, belonging to only 100 projects, i.e. 1% of the rows of the object table belong to the project #1, 1% to #2, etc...
Right now we're using about 25 lines of C++/OCI code to do that (one query doing a "select sys_guid() from dual", and using the generated GUIDs to do inserts into object), but I suspect it's possible to do this using a single SQL statement using mysterious connect by or some other Oracle SQL magic. (our OCI code does quite a few round-trips to do the equivalent).
Would anyone please demonstrate how to generate the rows as explained above, and possibly describe how it works for the non-initiated?
Thanks, --DD
PS: I'm sure it can be done in PL/SQL as well, but I'm interested in a SQL version if one's possible.I've found two ways, both taking a few SQL statements, but somehow I think this ought to be possible without intermediary tables... I'm sure there's a better way.
#1drop table project_tmp;
create table project_tmp
as select rownum pid, sys_guid() guid from dual
connect by level <= 100;
drop table object_tmp;
create table object_tmp
as select mod(rownum, 100) + 1 pid, sys_guid() guid from dual
connect by level <= 1000;
drop table object;
create table object
as select o.guid object_guid, p.guid project_guid
from object_tmp o, project_tmp p
where o.pid = p.pid;
drop table project_tmp;
drop table object_tmp;#2:drop table project;
create table project
as select mod(rownum, 100) + 1 prj_id, sys_guid() guid from dual
connect by level <= 100;
drop table object;
create table object
as select mod(rownum, 100) + 1 prj_id, sys_guid() object_guid from dual
connect by level <= 1000;
alter table object add project_guid raw(16);
update object o set o.project_guid = (select guid from project p where p.prj_id = o.prj_id);
drop table project;
alter table object drop column prj_id;Verification:select count(distinct project_guid) from object;
select project_guid, count(OBJECT_GUID) from object group by project_guid; -
How to Generate Trace Files in SQL*Plus
Hi Friends ,
How to Generate Trace Files in SQL*Plus ?
i have no idea
thanks
rajWhat trace files would you like to generate?
Are we talking SQL trace files?
ALTER SESSION SET sql_trace = TRUE;This will be generated in the user_dump_dest on the server.
show parameter dump -
How to generate XML file from SQL file !
I am new to XML publisher. I known one way to generate XML file is register one report file in concurrent manager.
But I want to generate XML file from sql file.
Could someone show me how to code in sql file, how to register is in concurrent manager.
Thanks !Hi
Phew ... not sure we have the space here. So I can point you in the right direction:
1. XML data generation - there are two packages in the db you can use with a plsql procedure, XMLGEN and SQL XML. You can also use java APIs too. Try checking the db documentation and search for the above methods.
2. Registering the report - the system administrators guide will provide this info. Hooking the program up with XMLP is covered here - http://www.oracle.com/technology/products/applications/publishing/resource/CM%20Whitepaper5.0.pdf
Regards, Tim
Maybe you are looking for
-
Parameter driven query and SSRS Dataset fields
I have a Parameter in my SSRS Report, @PatientSelection. I use this Parameter within my SQL Stored Procedure to execute one version of the report and get specific columns, or another version of the report with different columns. -- @PatientSelection
-
The computer/pc which stored all the songs I had bought from the ITUNE store some, crashed a few years back. Since then, I only accessed my ITUNES account sporadically and, and however hard I tried, I have not managed to find the way which will help
-
Dropdown list default value in Visual Composer
Hi all , i have dropdown list in my Visual composer layout i have values coming like 2001 to 2014 ,everything is fine . i need to display default value in the dropdown list should be curent year like 2009when i deploy the application by default the
-
Error in Viewing Draft Invoice for Service Item Type
Hi I am facing an error in viewing draft service invoice. I am saving a document (PO/ Invoice) as draft. When i am trying to view from document draft list by double-clicking it. the Visual Studio Just-in-Time debugger opens up stating SAP Business O
-
Using Adobe PhotoShop CS4, I cannot add text to a new layer. It was always a snap with previous versions of OS 10. Has anyone else noticed issues with CS4 and Lion? Many thanks in advance. Pete Hendricks