From: Justin B. <jgb...@gm...> - 2009-11-14 23:45:47
|
On Sat, Nov 14, 2009 at 1:35 PM, R. Emre Başar <re...@cs...> wrote: > Thanks. I managed to get it to some level. I defined a table like: > > $(mkDBDirectTableWithName "LastInsertId" "Server" [("LAST_INSERT_ID()", [t|Int|])]) > Nice work! Unfortunately you are right - you have to give a table name. If the table name is irrelevant (i.e., it doesn't affect LAST_INSERT_ID), try using information_schema.schema_catalog_name. That's a SQL-standard table that always has one row. It's useful for a "fake" query like this. If you are feeling adventerous, the darcs version of haskelldb has the "func" and "literal" query operators which would let you build this query fairly easily: lastInsertID = func "last_insert_id()" or lastInsertID = constant (literal "last_insert_id()") but it is has undergone some major changes in syntax. The underlying Record system was shifted over to HList and the library is still very much in flux. In any case you can find it at http://code.haskell.org/haskelldb > This gives me the last insert id for a table, but the problem is it > generates an SQL like: SELECT LAST_INSERT_ID() FROM Server as T1; which > is table specific. > > Is it possible to remove the FROM clause, so that it can work on any > insert? As far as I dived into the source of HaskellDB I got the > impression that it is not possible to build queries without a FROM > component. Is that correct? > > -- > R. Emre Başar > İstanbul Bilgi University > Department of Computer Science > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iD8DBQFK/yKF86wLPNcWbrwRAvOVAJ9gecd4U8InxYBX0L+wfMsLWLZLugCghY6p > 5tAS994UAjwwtyNyoGwLkkU= > =e4HE > -----END PGP SIGNATURE----- > > |