On 08/03/2012 6:15 PM, Nico Williams wrote:
On Thu, Mar 8, 2012 at 4:37 PM, Simon Slavin<slav...@bigfraud.org>  wrote:
That's why you don't make a DBMS (SQL) do the job of a programming language.  
Use your programming
language to to retrieve the values you need to make your calculations.
  Then use your programming language to figure out the new values and
execute the UPDATE commands needed to make the changes.

Lots of people want to and do use SQL to do a lot of what a regular
programming language can do.

Some are even taking SQL and applying it to new problems.  See ql.io
for example.

One very nice thing about using SQL to do more is that you can do a
lot of prototyping from a SQL shell and then start on the scaffolding
around it in whatever other language, and if you do it this way you'll
probably find yourself doing a lot of programming in SQL.

SQL is not a programming language.  Trying to use it like one leads to 
ridiculous contortions which take longer to run than doing it all in SQL would 
take.  There's nothing magically fast about SQL, it still has to do the same 
amount of work in the end.
SQL was not, originally, a Turing complete language (unless one were
to consider cross self joins of large tables for driving iteration as
good enough), but nowadays it pretty much is, therefore it  is a
programming language.  The language supported by SQLite3 is Turing
complete, FYI, since you have conditionals (WHERE, WHEN, CASE, ...)
and iteration (e.g., via recursive triggers).  And the SQLite3 VM most
assuredly is Turing complete.
Don't forget stored procedures.

I'd dearly love to have even a simple stored procedure language in sqlite3... the VM supports *everything* it needs, even function call/return. Triggers already connect multiple statements, joins open and iterate over cursors, etc. There's just no parser support to expose the functionality in a nice way.

Perhaps a Google summer of code project or something?

But, really, it's quite a hole that I can INSERT INTO table SELECT
<complex query>  but I can't UPDATE table<complex expressions>.
++, though I don't know of a non-kludgy syntax that would make this happen

INSERT OR REPLACE is almost a very good alternative.
The semantics are subtle enough to worry me, just based on what we've discussed so far.

Ryan

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to