mysql、mssql、oracle 的相同 SQL 连接运算符
我试图对上述三个 DBMS 使用相同的 sql 语句..但问题是它涉及字符串连接,但每个 dbms 中有不同的连接操作方式..但我想要单个运算符..需要有人的帮助
I am trying to use same sql statement for the above three DBMS .. but the problem is that it has string concatenation involved but there are different ways in each dbms for concatenation operation .. but i want the single operator .. Need someone's help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您也许可以在应用程序代码中解决这个问题,方法是在 sql 语句中使用占位符进行串联,然后将其替换为您正在使用的 RDBMS 的正确样式:
然后在伪代码中:
You can perhaps get around this in your application code by using a placeholder for concatenation in your sql statements, and then replacing it with the correct style for the rdbms you are using:
Then in pseudo-code:
我会避免编写自己的问题解决方案,并使用现有的多数据库工具之一。如果您曾经遇到过这个问题,那么您很快就会再次遇到它。
我与以下内容没有任何关系,但您可以尝试 Datanamic Multirun
I'd avoid writing your own solution to the problem and use one of the muti-database tools already available. If you have come across this problem once you will come across it again soon.
I've no affiliation with the following but you could try Datanamic Multirun
这个问题的简单答案似乎是否定的。
但是...
如果您在 Oracle 中创建包 dbo 会怎样?
在 mysql 中是否也可以在名为 dbo 的单独数据库中创建一个名为 concat 的函数,以便使用语法 dbo.concat(a, b, c) 调用函数?
不幸的是,mysql不支持默认参数(除非最近更改)或函数重载,因此您必须为每个参数数量创建函数:
concat2(s1, s2)
concat3(s1, s2, s3)
等等。
The simple answer is to the question seems to be no.
However...
What if you create the package dbo in Oracle?
Is it not also possible in mysql to create a function called concat in a separate database called dbo, so that a function is called using the syntax dbo.concat(a, b, c)?
Unfortunately, mysql doesn't support default parameters(unless recently changed) or function overloading, so you would have to create on function for each number of arguments:
concat2(s1, s2)
concat3(s1, s2, s3)
and so on.
有一种方法可以使用 ODBC 转义序列来实现此目的
我目前的理解 这在 SQL Server 和 MySQL 中可以正常工作,但对于 Oracle 来说取决于连接方法。
There is a way of doing this using ODBC escape sequences
From my current understanding this will work fine in SQL Server and MySQL but for Oracle is dependant upon connection method.
MySQL:
输出为:纽约市
Oracle:
输出为:城市为巴黎
SQL Server:
输出为:城市为巴黎
输出为: 城市是巴黎
MySQL:
Output is : New York City
Oracle:
Output is : The city is Paris
SQL Server:
Output is : The city is Paris
Output is : The city is Paris