Unrolling procedural code into SQL

0 votes
asked Jul 30, 2010 by earlz

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){
    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?

1 Answer

0 votes
answered Jul 30, 2010 by clacke

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.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter