Convert non-asni sql to ansi sql?
Hi,
I tried converting this using Query Editor but it rejected it.
select LDate,
b.Book,
a.Type,
a.Cusip,
Ticker,
Description,
a.BankCode
FROM
dbo.SL_LPositions a,
dbo
.SL_LBankDTC b,
dbo
.sl_Lfisemap c
where
a.BankCode
*= b.Bankcode
and
a.type
*= c.type
and
a.cusip
*= c.cusip
and a.colltype
=
'C'
and c.category
=
'lnpos'
and LDate
=
'20140130'
thanks
oldmandba
Hi,
THe original query returned 770 rows: I converted it to this which also returns 770 rows - the solutions posted return 313 rows. I moved the where conditions up to the on portion.
SELECT
LDate, a.Type,
a.Cusip,
Ticker,
Description,
a.BankCode
FROM
dbo.SL_LPositions a
LEFT
OUTER
JOIN dbo.SL_LBankDTC
b ON a.BankCode
= b.Bankcode
and a.colltype
=
'C'
LEFT
OUTER
JOIN dbo.sl_Lfisemap
c ON a.type
= c.type
and a.cusip
= c.cusip
and c.category
=
'lnpos'
WHERE
LDate =
'20140130'
oldmandba
Similar Messages
-
Help on - convert ansi sql to oracle sql
hi gurus,
i'm try'g to convert ansi sql to oracle sql.
but i'm getting an error. can u please let me know, if i can convert it or is it better to use ansi sql!
original code in ansi format::
select distinct bfc.NBR_SEQ, bfc.IDN_ENTITY, bfc.CDE_TYPE_ENTITY, n.CDE_STATUS,
gec.idn_group as idn_parent_id, bfc.IDN_FUNC_BUSS,
case when bfc.CDE_TYPE_ENTITY = 'P' OR bfc.CDE_TYPE_ENTITY = 'A' then
PKG_FW_NVGTR.GET_NAM_PAGE(bfc.IDN_ENTITY)
else
PKG_FW_NVGTR.GET_NAM_GROUP(bfc.IDN_ENTITY)
end as ENTITY_NAM,
p.Category, p.Display_Txt, p.show_in_nav, p.page_uri
from
T_BUSS_FUNC_ENTITY_CREF bfc
inner join t_buss_func bf on bfc.idn_func_buss = bf.idn_func_buss
inner join t_entity_prog_cref epc on bfc.idn_entity = epc.idn_entity and bfc.cde_type_entity = epc.cde_type_entity
left outer join t_page p on bfc.idn_entity = p.idn_page
left outer join t_group_entity_cref gec on bfc.idn_entity = gec.idn_entity and bfc.cde_type_entity = gec.cde_type_entity
left outer join t_nvgtr n on bfc.idn_entity = n.idn_entity and bfc.cde_type_entity = n.cde_type_entity
where
BF.nam_func_buss = 'CP' AND--P_NAM_FUNC_BUSS and
epc.cde_program in
( select p.cde_program from t_program p where p.nam_program in (
SELECT * FROM TABLE (CAST(PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST('LC', ',') AS TYP_ARRAY))))
order by
bfc.NBR_SEQ;tried to convert into oracle
SELECT DISTINCT bfc.NBR_SEQ,
bfc.IDN_ENTITY,
bfc.CDE_TYPE_ENTITY,
n.CDE_STATUS,
gec.idn_group as idn_parent_id,
bfc.IDN_FUNC_BUSS,
case when bfc.CDE_TYPE_ENTITY = 'P' OR bfc.CDE_TYPE_ENTITY = 'A' then
PKG_FW_NVGTR.GET_NAM_PAGE(bfc.IDN_ENTITY)
else
PKG_FW_NVGTR.GET_NAM_GROUP(bfc.IDN_ENTITY)
end as ENTITY_NAM,
p.Category,
p.Display_Txt,
p.show_in_nav,
p.page_uri
FROM T_BUSS_FUNC_ENTITY_CREF bfc,
T_BUSS_FUNC bf,
T_ENTITY_PROG_CREF epc,
T_PAGE p,
T_GROUP_ENTITY_CREF gec,
T_NVGTR n
WHERE bfc.IDN_FUNC_BUSS = bf.IDN_FUNC_BUSS
AND bfc.IDN_ENTITY = epc.IDN_ENTITY
AND bfc.CDE_TYPE_ENTITY = epc.CDE_TYPE_ENTITY
AND bfc.IDN_ENTITY(+) = p.IDN_PAGE
AND bfc.IDN_ENTITY(+) = gec.IDN_ENTITY
AND bfc.CDE_TYPE_ENTITY(+) = gec.CDE_TYPE_ENTITY
AND bfc.IDN_ENTITY(+) = n.IDN_ENTITY
AND bfc.CDE_TYPE_ENTITY(+) = n.CDE_TYPE_ENTITY
AND BF.nam_func_buss = 'CP' AND--P_NAM_FUNC_BUSS and
epc.cde_program in
( select p.cde_program from t_program p where p.nam_program in (
SELECT * FROM TABLE (CAST(PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST('LC', ',') AS TYP_ARRAY))))
order by
bfc.NBR_SEQ;error is
ORA-01417: a table may be outer joined to at most one other tableso how can i convert it?
thanksuser642856 wrote:
explain plan for this select statement
ID PID Operation Name Rows Bytes Cost CPU Cost IO Cost Temp space IN-OUT PQ Dist PStart PStop
0 SELECT STATEMENT 10M 1183M 570694 33G 567917
1 0 SORT UNIQUE 10M 1183M 287940 17G 286502 2607M
2 1 HASH JOIN 10M 1216M 179 1G 84
3 2 COLLECTION ITERATOR PICKLER FETCH PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST
4 2 HASH JOIN OUTER 2693 299K 58 34M 55
5 4 HASH JOIN OUTER 37 3959 11 24M 9
6 5 HASH JOIN OUTER 37 3663 10 18M 8
7 6 HASH JOIN 37 1147 7 12M 6
8 7 HASH JOIN 59 1180 5 6060823 4
9 8 NESTED LOOPS 2 24 3 15843 3
10 9 TABLE ACCESS BY INDEX ROWID T_BUSS_FUNC 1 6 1 8341 1
11 10 INDEX UNIQUE SCAN UK_NAM_FUNC_BUSS 1 0 1050 0
12 9 TABLE ACCESS FULL T_PROGRAM 2 12 2 7501 2
13 8 INDEX FULL SCAN PK_T_ENTITY_PROG_CREF 59 472 1 18921 1
14 7 TABLE ACCESS FULL T_BUSS_FUNC_ENTITY_CREF 37 407 2 14891 2
15 6 TABLE ACCESS FULL T_PAGE 26 1768 2 14141 2
16 5 INDEX FULL SCAN UK_UNIQUE_GROUP_DEPENDENT 26 208 1 12321 1
17 4 TABLE ACCESS FULL T_NVGTR 6986 47K 46 3179613 46 as you can see.. cpu cost is in 33G..
is there any better way?
thanksCan you run this in a session please:
ALTER SESSION set optimizer_dynamic_sampling = 4;Then run an explain plan again.
And you have a function in there - PKG_FW_NVGTR.FN_GET_ARRAY_FROM_COMMA_LIST - which isn't helping things. -
Converting oracle join to Ansi sql join
Hi Guys,
I am new to SQL and trying to convert the following Oracle query (joins) into ANSI sql joins...Can someone please help me?
SELECT M.EXTERNALCODE, M.NAME AS MNAME, SC.BIRIM, SM.TRANSACTIONDATE, SMD.AMOUNT,
SMD.UNITPRICE, SM.ID AS SMID, SMD.ID AS SMDID, F.NAME AS FNAME,
IFNULL (SMD.AMOUNT, 0, SMD.AMOUNT) * IFNULL (SMD.UNITPRICE, 0, SMD.UNITPRICE) AS TOTALPRICE, SMD.AMOUNT AS RECEIVED_QUANTITY,
PD.ORDERID, PD.AMOUNT QUANTITY, PO.PROCESSDATE
FROM STOCKMAINTRANSACTION SM,
STOCKMAINTRANSACTIONDETAIL SMD,
MATERIAL M,
STOCKCARD SC,
FVSTOCK FVS,
FIRM F,
PURCHASEORDER PO,
PURCHASEORDERDETAIL PD,
PURCHASEORDERDETAILSUPPLIED PDS
WHERE SM.ID = SMD.MAINTRANSACTIONID
AND SMD.MATERIALID = M.ID
AND SMD.STOCKCARDID = SC.ID
AND SM.PROPREF = FVS.RECORDID(+)
AND FVS.FIELDID(+) = 2559
AND FVS.FLEVEL(+) = 'F'
AND F.ID(+) = SUBSTR (FVS.FVALUE, 1, 9)
AND SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)
AND SMD.CANCELLED = 0
AND SMD.STOCKUPDATED = 1
AND SMD.ID = PDS.STOCKMAINTRANSACTIONDETAILID
AND PDS.ORDERDETAILID = PD.ORDERDETAILID
AND PO.ORDERID = PD.ORDERID
AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}
ORDER BY F.NAME, M.EXTERNALCODE, SM.TRANSACTIONDATE
Really appreciate the help!
Thanks.Hi,
Welcome to the forum!
To convert to ANSI syntax, replace join conditions in the WHERE clause
FROM x
, y
WHERE x.x1 = y.y1
AND x.x2 = y.y2with ON conditions in the FROM clause:
FROM x
JOIN y ON x.x1 = y.y1
AND x.x2 = y.y2In inner joins, conditions that do not reference 2 tables are not really join conditions, so it doesn't matter if they are in the FROM clause or in the WHERE clause.
In your case
SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)could be part of a join condition involving sm, or it could be in the WHERE clause. Most people find it clearer if 1-table conditions like this are in the WHERE clause.
Again, this only applies to inner joins. For outer joins, all conditions that apply to a table that may lack matching rows must be included in the FROM clause, like this:
LEFT OUTER JOIN fvstock fvs ON sm.propref = fvs.recordid
AND fvs.fieldid = 2559
AND fvs.flevel = 'F'Try it.
If you have trouble, post your best attempt, along with CREATE TABLE and INSERT statements for a little sample data from all the tables involved, and the results you want from that data. Simplify the problem. Post only the tables and columns that you don't know how to handle.
See the forum FAQ {message:id=9360002}
user8428528 wrote:
AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}This is not valid Oracle SQL. Is {@MATERIALID@} some kind of variable? -
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. -
ANSI SQL to Oracle Old SQL conversion
I need help to convert this ANSI SQL Query to Oracle Old school (With inline views and =(+) joins and where clasuses)
CUrrent Query and new one should return same resultset
---------------------------------Query Start----------------------------------------------------
SELECT COUNT(*)
FROM
SELECT
'XXXXXX' as Big_Boss,
da.Direct,
da.Director,
da.Manager,
da.SubArea,
da.Project,
da.Project_Name,
da.Project_Class,
da.HISL,
da.Resource_Name,
da.Resource_Status,
da.mon,
to_char(sysdate, 'dd-Mon-YYYY') AS "Current_Date",
DECODE(da.Project, NULL, 0, round(da.Slice / da.month_total, 2)) as
"Approved_Demand",
SUM(da.Availability) as "Headcount"
FROM
SELECT
w.level4_name AS Direct,
w.level5_name AS Director,
w.level6_name AS Manager,
w.level7_name AS SubArea,
INV.Code as Project,
inv.name as Project_Name,
det.hum_project_gate as Project_Class,
r.id AS HISL,
r.full_name as Resource_Name,
lookup.lookup_code as Resource_Status,
alc.slice AS Slice,
alc.slice_date as Mon,
avl.slice AS month_total,
alc.slice / avl.slice as FTE,
count(distinct r.id) AS Availability
FROM
nbi_dim_obs w,
prj_blb_slices_m_avl avl,
prj_obs_units obs,
cmn_lookups lookup,
srm_resources r
************** Section to be Converted ***************************----------
----------------------------Start----------------------------------------------------
left outer join(prj_resources t inner join srm_resources res on
t.prprimaryroleid = res.id) on r.id = t.prid
left outer join(prj_blb_slices_m_alc alc
left outer join(prteam tm
inner join(inv_investments INV inner join odf_ca_project det on det.id = inv.id
and det.hum_project_gate = 'approved_for_development') on tm.prprojectid = INV.ID
and INV.Is_Active = 1) on alc.prj_object_id = tm.prid
and alc.investment_id = inv.id) on alc.resource_id = t.prid
--------------------------------------End--------------------------------------------
-- inner join prj_blb_slices_m_avl avl on alc.resource_id = avl.prj_object_id
-- inner join prj_obs_units obs on res.unique_name = obs.unique_name
-- inner join nbi_dim_obs w on w.level7_unit_id = obs.id
WHERE
w.obs_type_name = 'Workgroup'
AND alc.slice > 0
AND alc.slice_date = avl.slice_date
AND r.is_active = 1
AND r.person_type = lookup.id
AND w.level7_unit_id = obs.id
AND alc.resource_id = avl.prj_object_id
AND res.unique_name = obs.unique_name
GROUP BY
w.level4_name
, w.level5_name
, w.level6_name
, w.level7_name
, r.id
, r.full_name
, lookup.lookup_code
, inv.code
, inv.NAME
, det.hum_project_gate
, alc.slice_date
, alc.slice
, avl.slice
) DA
GROUP BY
da.direct
, da.director
, da.manager
, da.subarea
, da.project_class
, da.hisl
, da.resource_name
, da.resource_status
, da.project
, da.Project_Name
, da.mon
, da.availability
, da.slice
, da.month_total
ORDER BY
da.direct
, da.director
, da.manager
, da.subarea
-------------------------------Query End----------------------------------------------------------Joins are joins ... what do you mean by "nested" joins?
If you are concerned about outer joins that can be performed using ANSI syntax that are not supported in the classic Oracle syntax then use in-line view and outer join the views.
If your code was properly formatted it would be possible for someone to read it and possibly see what you are seeing.
Read the FAQ page and learn to format your posted code. -
Differences between ANSI SQL and Oracle 8/9
Hallo,
i'm looking for good online texts or books concerning the problem "Differences between ANSI SQL and different database implementations (ORACLE, Informix, MySQL...)" I want to check a program written in C (with ESQL) that works with an Informix-DB. In this code i want to find code that is specific to the Informix-DB. I want to change the database, so all the code should be independent from a DB. Does anybody know texts or books concerning this problem?
thx
Marco SeumBasically there is syntax difference between both of them.
Lets say i want to join two table EMP and DEPT based on DEPTNO.
With Oracle SQL format its like this.
select e.*
from emp e, dept d
where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
With ANSI SQL format its like this.
select e.*
from emp e
join dept d
on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
Oracle supports ANSI SQL starting from 9i version.
You can read more about the syntax difference Here -
How to convert string to an integer in SQL Server 2008
Hi All,
How to convert string to an integer in sql server,
Input : string str="1,2,3,5"
Output would be : 1,2,3,5
Thanks in advance.
Regards,
SunilNo, you cannot convert to INT and get 1,2,3 BUT you can get
1
2
3
Is it ok?
CREATE FUNCTION [dbo].[SplitString]
@str VARCHAR(MAX)
RETURNS @ret TABLE (token VARCHAR(MAX))
AS
BEGIN
DECLARE @x XML
SET @x = '<t>' + REPLACE(@str, ',', '</t><t>') + '</t>'
INSERT INTO @ret
SELECT x.i.value('.', 'VARCHAR(MAX)') AS token
FROM @x.nodes('//t') x(i)
RETURN
END
----Usage
SELECT * FROM SplitString ('1,2,3')
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 -
How to convert epoch time to datetime in sql*loader Oracle
Hello,
I wan't to question how to convert epoch time to datetime in sql*loader Oracle. I try this script for convert epoch time to datetime in sql*loader, but error:
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
This is my loader:
LOAD DATA INFILE 'C:\Documents and Settings\Administrator\My Documents\XL_EXTRACT_211\load.csv'
into table TEMP_TEST_LANGY append
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
DATADATA CHAR "TO_DATE('01-JAN-1970','DD-MON-YYYY')+:datadata/86400"
This is my csv file:
79314313.7066667
79314336.2933333
79314214.3466667
This is my table:
CREATE TABLE TEMP_TEST_LANGY
DATADATA DATE
Thanks
Edited by: xoops on Sep 21, 2011 8:56 AM
Edited by: xoops on Sep 21, 2011 8:58 AMthanks for your answer, but I asked to use sql loader instead of the external table, which so my question is why can not the epochtime converted to datetime, if there is no way to convert a datetime epochtime using sql loader, so I'm required to use the external table. thank you.
This is my error log:
Column Name Position Len Term Encl Datatype
DATADATA FIRST * , CHARACTER
SQL string for column : "TO_DATE('1-Jan-1970 00:00:00','dd-MM-YYYY hh24:mi:ss') + (:DATADATA/60/60/24)"
Record 1: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 2: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Record 3: Rejected - Error on table TEMP_TEST_LANGY, column DATADATA.
ORA-01722: invalid number
Edited by: xoops on Sep 21, 2011 12:33 PM -
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 -
Hi,
Do you know if the extensions of Oracle SQL
- DML error logging
- model clause
- pivot clause
are supported by ANSI SQL (or other RDBMS) ?
Thanks for your helpAFAIK
The <b><tt>Error Logging</tt></b> clause can be used in <tt><b>Insert</b></tt>, <tt><b>Update</b></tt> and <tt><b>Merge</b></tt> statements
Error Logging Restrictions and Caveats
http://docs.oracle.com/cd/E11882_01/server.112/e25494/tables004.htm#ADMIN11640
There seems to be no difference concerning join syntax
<tt><b>Model</b></tt> and <tt><b>Pivot</b></tt> clauses belong to the <tt><b>Select</b></tt> statement
http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#SQLRF01702
There seems to be no difference concerning join syntax
However:
How Oracle Virtual Private Database Policies Affect Outer or ANSI Join Operations
http://docs.oracle.com/cd/E11882_01/network.112/e16543/vpd.htm#DBSEG305
Oracle Virtual Private Database rewrites SQL by using dynamic views. For SQL that contains outer join or ANSI operations, some views may not merge and some indexes may not be used. This problem is a known optimization limitation. To remedy this problem, rewrite the SQL to not use outer joins or ANSI operations.
Regards
Etbin -
What is Difference between ANSI SQL and ORACLE SQL
Hi,
I am going to take the assesment test for ANSI SQL Programming before that i want to know any difference between ANSI SQL and ORACLE SQL?
I am studying for SQL but the test will be ANSI SQL please let me give an idea about the both.
Thanks
Merina RoslinBasically there is syntax difference between both of them.
Lets say i want to join two table EMP and DEPT based on DEPTNO.
With Oracle SQL format its like this.
select e.*
from emp e, dept d
where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
With ANSI SQL format its like this.
select e.*
from emp e
join dept d
on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
Oracle supports ANSI SQL starting from 9i version.
You can read more about the syntax difference Here -
How to convert Oracle User defined datatype to SQL Server 2014 using SSMA Version 6.0
I am trying to convert Oracle 11g OE schema to SQL Server 2014, using SSMA version 6.0
Getting an error in converting the Oracle View to SQL Server
CREATE OR REPLACE VIEW OC_CUSTOMERS OF OE.CUSTOMER_TYP WITH OBJECT IDENTIFIER (customer_id) AS
SELECT c.customer_id, c.cust_first_name, c.cust_last_name, c.cust_address,
c.phone_numbers,c.nls_language,c.nls_territory,c.credit_limit,
c.cust_email,
CAST(MULTISET(SELECT o.order_id, o.order_mode,
MAKE_REF(oc_customers,o.customer_id),
o.order_status,
o.order_total,o.sales_rep_id,
CAST(MULTISET(SELECT l.order_id,l.line_item_id,
l.unit_price,l.quantity,
MAKE_REF(oc_product_information,
l.product_id)
FROM order_items l
WHERE o.order_id = l.order_id)
AS order_item_list_typ)
FROM orders o
WHERE c.customer_id = o.customer_id)
AS order_list_typ)
FROM customers c
* SSMA error messages:
* O2SS0461: Conversion of object view is not supported.
* OF OE.CUSTOMER_TYP
* WITH OBJECT IDENTIFIER (customer_id)
CREATE VIEW dbo.OC_CUSTOMERS
AS
/*Generated by SQL Server Migration Assistant for Oracle version 6.0.0.*/
* SSMA error messages:
* O2SS0481: Conversion of statement containing user defined type column 'c.cust_address' not supported.
* O2SS0481: Conversion of statement containing user defined type column 'c.phone_numbers' not supported.
* O2SS0430: Conversion of multiset conditions is not supported.
* CAST(MULTISET
* SELECT
* o.order_id,
* o.order_mode,
* MAKE_REF(oc_customers, o.customer_id),
* o.order_status,
* o.order_total,
* o.sales_rep_id,
* CAST(MULTISET
* SELECT
* l.order_id,
* l.line_item_id,
* l.unit_price,
* l.quantity,
* MAKE_REF(oc_product_information, l.product_id)
* FROM order_items l
* WHERE o.order_id = l.order_id
* ) AS order_item_list_typ)
* FROM orders o
* WHERE c.customer_id = o.customer_id
* ) AS order_list_typ)
SELECT
c.CUSTOMER_ID,
c.CUST_FIRST_NAME,
c.CUST_LAST_NAME,
c.cust_address,
c.phone_numbers,
c.NLS_LANGUAGE,
c.NLS_TERRITORY,
c.CREDIT_LIMIT,
c.CUST_EMAIL,
NULL
FROM dbo.CUSTOMERS AS c */
Any suggestion on converting this view would be helpful.
Kind regards.Thanks Lydia Zhang for your reference urls.
Please let me know if you come across any reference articles related to
Creating a SQL Server table and View with columns as SQL Server TVP similar to Oracle UDT like
CREATE TABLE "OE"."CUSTOMERS"
( "CUSTOMER_ID" NUMBER(6,0),
"CUST_FIRST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_FNAME_NN" NOT NULL ENABLE,
"CUST_LAST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_LNAME_NN" NOT NULL ENABLE,
"CUST_ADDRESS" "OE"."CUST_ADDRESS_TYP" ,
"PHONE_NUMBERS" "OE"."PHONE_LIST_TYP" ,
"NLS_LANGUAGE" VARCHAR2(3 BYTE),
And also creating a SQL Server TVP inside an another SQL Server TVP as in Oracle
create or replace TYPE customer_typ
AS OBJECT
( customer_id NUMBER(6)
, cust_first_name VARCHAR2(20)
, cust_last_name VARCHAR2(20)
, cust_address cust_address_typ
, credit_limit NUMBER(9,2)
, cust_email VARCHAR2(30)
, cust_orders order_list_typ
NOT FINAL;
Kind regards.
Venkatesha -
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
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 ) -
Convert SSIS SQL 2005 to SQL 2008
Hi!
We have problem converting our SSIS package from SQL 2005 to SQL 2008.
When we try to to open our SSIS package from SQL 2005 in SQL 2008 BIDS we get an error.
We don´t get the old BPC tasks in Visual Studio 2008 just the new ones, can this be the problem? And how can we solve this?All,
Usually, User can use MS migration tool for converting DTS to SSIS.
Here are something user needs to do
1. after convert, user should replace Some custom tasks from 4.2 version to 7M version.
2. Sometimes MS migration tool makes wrong conversion like connection. We need to fix it manually.
3. If user is using some specific tasks like Data mining tasks, Migration tool doesn't support
This is the only case that user should create package again.
Except #3 case, all existing packages could convert to SSIS package easily,
I converted a customers 4.2 DTS packages to 7 version recently and converting one package only took 5 minutes -10 minutes including test.
As I know, SAP is preparing HOW TO DO as WebCast very soon.
Please wait a little bit more.
Thank you
James
For the answer of this thread, sometimes you need to restart SSIS services at Appserver after you MS patches or add new tasks , I think it is a bug of MS but please try it.
Maybe you are looking for
-
Time Machine, external hard drive and more
Guys, I am very excited about the release of Leopard and in preparation, want to obtain separate external hards drive for use with Time Machine. I've got a Mac Pro 3Ghz with 3 Terabytes of hard disk space, 4Gig Ram. What would I need in terms of size
-
Recently reinstalled CS3. On first opening the system pulled down updates. These won't install. The updater is caught in a perpetual circle of trying to update and stopping. My instinct tells me this is something simple but I can't find a clue an
-
Problem in getting data into database with standard direct input program
HI All, I am having problem which is not updating the records in MM01 or MM02 with standard direct input program. i have data in internal table. from that table i am trying to upload into database by using background job MRP_MATERIAL_MASTER_DATA_LOAD
-
Can I see my saved passwords on my iphone
I have all my user names and passwords saved on my Mac. I want to know if they can be synced to my iPhone using firefox home
-
TS3989 Can't synch photos from PC to Ipad through icloud
Two days ago I successfully set up icloud and transferred a few photos from my PC to my ipad. Tried again today, by dragging photos to the Photostream folder on my PC but can't get them to move to the ipad. Can someone guide me through the process