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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Earlz
  • 62,085
  • 98
  • 303
  • 499

1 Answers1

0

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
  • 7,688
  • 6
  • 46
  • 48
  • 1
    Wikipedia says ANSI SQL is turing complete though? I fail to see how though – Earlz Jul 30 '10 at 17:31
  • 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 Jul 31 '10 at 09:13
  • nevermind it got edited out: http://en.wikipedia.org/w/index.php?title=SQL&action=historysubmit&diff=376242269&oldid=376220546 – Earlz Jul 31 '10 at 17:21