Re: Question about update-records-from-instance
David Thole <[email protected]>
| Newsgroups | gmane.lisp.clsql.general |
|---|---|
| Message-ID | <[email protected]> |
Thanks Thijs for the reply. I looked at other alternatives, digging through the code like mad during lunch today, and came up with this solution as well: ... (dolist (obj (query ...)) (setf (slot-value obj (intern "VIEW-DATABASE" 'clsql-sys)) nil) (clsql:update-records-from ...)).. I found that this works pretty well too, since the slot for the object is set to the database instance - which evaluates to true, so the update-records-from will always execute. Thanks for the tip on the debug output, I'll definitely be sure to use that a lot, since this is a big project for me at the moment. -David On Thu, Dec 17, 2009 at 11:16 AM, Thijs Oppermann <[email protected]<thijso%[email protected]> > wrote: > I'd start by doing: > > (start-sql-recording :type :both) > > This outputs all the statements clsql is running against the database > in your REPL. Handy for debugging. > > For the rest, update-records-from-instance is for adding or updating > based on OODML, i.e. from an object created by def-view-class. I think > you need to actually build the correct sql statement if you want to do > what you seem to want to do in your code snippet (sorry, hurried > reply... ) > > Gr, > Thijs > > On Wed, Dec 16, 2009 at 10:31 PM, David Thole <[email protected]> wrote: > > Hey all, > > I'm trying to run the code, something like below: > > (defun build-sqlite-db () > > (with-generic-wordnet-mssql-connection (dbms) > > (with-generic-wordnet-sqlite-connection (sqlitedb) > > ; (clsql:create-view-from-class 'worddef :database sqlitedb) > > > > > > (dolist (obj (query-db :word "cat" :tbl 'worddef :db dbms)) > > (clsql:update-records-from-instance obj :database sqlitedb))))) > > > > Error: > > While accessing database #<SQLITE3-DATABASE db/wordnet.sqlite3 OPEN > > {1003013921}> > > > > with expression "UPDATE WORD_DEFS SET LEMMA = 'cat',POS = > 'n',DEFIN...": > > > > > > Error 1 / no such table: WORD_DEFS > > > > > > has occurred. > > [Condition of type CLSQL-SYS:SQL-DATABASE-DATA-ERROR] > > The goal I'm trying to do is query from MSSQL (which works), and then > insert > > the data into the sqlite database. I wanted to generate the error, to > > illustrate what the update-records is doing. With it uncommented out, > it'll > > execute just fine...just not insert records. > > Is there a good way to accomplish what I'm trying to do? I was hoping > for > > an insert-records-from-instance, but couldn't find anything that did > that. > > -David > > _______________________________________________ > > CLSQL mailing list > > [email protected] > > http://lists.b9.com/cgi-bin/mailman/listinfo/clsql > > > > > _______________________________________________ > CLSQL mailing list > [email protected] > http://lists.b9.com/cgi-bin/mailman/listinfo/clsql > _______________________________________________ CLSQL mailing list [email protected] http://lists.b9.com/cgi-bin/mailman/listinfo/clsql