views:

37

answers:

1

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 or any resources about this?

A: 

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.

clacke
Wikipedia says ANSI SQL is turing complete though? I fail to see how though
Earlz
Where?[WP:Transact-SQL](https://secure.wikimedia.org/wikipedia/en/wiki/Transact-SQL)"Transact-SQL augments SQL with certain additional features . . . These additional features make Transact-SQL Turing complete."
clacke
Earlz