简体   繁体   English

从Oracle SQL迁移到ANSI SQL的优缺点

[英]Moving from Oracle SQL to ANSI SQL pros and cons

I work in a project where the UI has direct access to the database through SQL code. 我在一个项目中工作,其中UI通过SQL代码直接访问数据库。 The company has a framework where we create UI pages in xml and after that it is parsed and creates FLEX pages. 该公司有一个框架,我们可以在其中创建xml的UI页面,然后对其进行解析并创建FLEX页面。 If we want some data from the DB (Oracle) we add a sql query in the xml (instead of databinding with a datacontext object like we could do with WPF). 如果要从DB(Oracle)获得一些数据,则在xml中添加一个sql查询(而不是像使用WPF那样使用datacontext对象进行数据绑定)。 If we want to add some logic, there is no code behind, we call store procedures. 如果我们要添加一些逻辑,则没有代码,我们将调用存储过程。 After we have the data we need the parser does the job. 获得数据后,我们需要解析器来完成这项工作。

The new requirements are to use the framework and create a new product that will be compatible with SQL Server and the thoughts are to start transforming the (Oracle)SQL queries to ANSI SQL. 新要求是使用框架并创建与SQL Server兼容的新产品,并且想法是开始将(Oracle)SQL查询转换为ANSI SQL。

Can somebody tell me the benefits and mainly the problems that we are going to face doing that? 有人可以告诉我这样做的好处以及主要是我们面临的问题吗? Do you think there is a better way? 您认为有更好的方法吗? Note: The framework is really big and there are a lot of products built on that so managers are not keen to just throw it away(I tried but.. :)) 注意:该框架确实很大,并且有很多基于此框架构建的产品,因此管理人员不希望仅将其丢弃(我尝试过,但是.. :))

Each dialect of SQL is different. SQL的每种方言都是不同的。 You could use ANSI SQL but a) not all of ANSI SQL is implemented by most DBMS and b) most DBMS's have implementation-specific optimisations which will perform better for some cases. 您可以使用ANSI SQL,但a)并非所有ANSI SQL都由大多数DBMS实现,并且b)大多数DBMS具有特定于实现的优化,在某些情况下性能会更好。

So I'd say, don't go for ANSI SQL. 所以我想说,不要选择ANSI SQL。 It won't always work and sometimes it will work slower than taking advantage of a vendor's non-standard implementations. 它并不总是可以工作,有时它的工作速度会比利用供应商的非标准实现慢。

Specifically, Oracle requires a StoredProcedure to return a REF_CURSOR from a stored procedure to fill a DataSet. 具体来说,Oracle要求StoredProcedure从存储过程中返回REF_CURSOR来填充数据集。 SQL Server doesnt; SQL Server不会; the SP returns what the sp SELECTed. SP返回sp选定的内容。 You're going to have to change your SP's to get rid of the returned REF_CURSOR. 您将必须更改您的SP以摆脱返回的REF_CURSOR。

Date handling is quite different: Oracle needs a to_date to turn a string into a date in where clauses etc; 日期处理是完全不同的:Oracle需要一个to_date才能在where子句等中将字符串转换为日期。 SQL Server just takes the string and converts it for you. SQL Server只是获取字符串并将其转换为您。 And so on and so on. 等等等等。 (I'm not at all sure what the ANSI Standard is, or even if it covers this!) To avoid changing your SQL you could add create SQL Server function called to_date, but this is now going to slow up your SQL. (我完全不确定ANSI标准是什么,或者即使它涵盖了这一点!)为了避免更改SQL,可以添加名为to_date的create SQL Server函数,但这现在会使SQL变慢。

If you have much PL/SQL in stored procedures, you have a big job converting it to T-SQL. 如果存储过程中包含大量PL / SQL,则将其转换为T-SQL的工作量很大。 They are quite different. 他们是完全不同的。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM