将过程代码展开为 SQL
最近我对将过程代码转换为 SQL 的行为很感兴趣。我知道并不是所有的事情都可以用图灵完备的过程语言来表达。
如果您有特殊用途的过程语言怎么办?例如将这样的东西转换
foreach(var row in Table){
if(row.FirstName=="Foo"){
yield new {row.TableRID};
}
}
成这样:
select TableRID from Table where FirstName='Foo'
这样的东西有名字吗?
另外,在我的伪代码中假设 row
是不可变的,并且不可能执行诸如 Table[0].FirstName...
之类的操作以及其他显然没有 (简单)翻译成 ANSI SQL。
谁能给我这个的名字吗?
The act of transforming procedural code into SQL has been of interest to me lately. I know that not absolutely everything is expressable in a turing complete procedural language.
What if you have a special purpose procedural language though? For instance converting something like this:
foreach(var row in Table){
if(row.FirstName=="Foo"){
yield new {row.TableRID};
}
}
into this:
select TableRID from Table where FirstName='Foo'
Is there a name for something like this?
Also, in my psuedo code assume that row
is immutable and it is impossible to do something like Table[0].FirstName...
and other things which obviously have no (easy) translation into ANSI SQL.
Can anyone give me a name for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一切都可以用图灵完备的过程语言来表达。但它并不总是富有表现力。有时,您可以通过消除权力、为您想要解决的问题创建一种特定于领域的语言或DSL来获得表现力。也许这就是您正在寻找的术语?
没有扩展的 SQL 不是图灵完备的,因此正如您所注意到的,只能转换图灵完备语言的可能程序的子集。
Everything is expressible in a Turing-complete procedural language. It's not always expressive, though. Sometimes you can gain expressiveness by removing power, creating a domain-specific language, or DSL, for the kind of problem you want to solve. Maybe this is the term you are looking for?
SQL without extensions is not Turing-complete, so as you note, only a subset of the possible programs of a Turing-complete language can be transformed.