Unrolling procedural code into 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};
开发者_如何学JAVA }
}
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?
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.
精彩评论