Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CL-SQL Experts for insert instead of update

4 views
Skip to first unread message

David Thole (TheDarkTrumpet)

unread,
Dec 16, 2009, 5:35:12 PM12/16/09
to
Hey All,

For any clsql experts here. For this particular bit of code:
http://gist.github.com/258247 I'm trying to select objects from one
database, and insert into another. I took out the create table
portion to illustrate the error in the 2nd part. Are there any ways
to select an object out of one database, and insert it into another?
The update* updates the record, which makes sense by its name..but I
would like to insert if possible.

code for those that don't want to click:
(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)))))


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]

Thanks for any help on this.

-David

David Thole (TheDarkTrumpet)

unread,
Dec 17, 2009, 8:37:42 PM12/17/09
to
Incase others run into this issue, I've come up with a solution that
appears to work fine. The snippet of code I'm using is something
like:

...
(dolist (obj (query ...))
(setf (slot-value obj (intern "VIEW-DATABASE" 'clsql-sys)) nil)
(clsql:update-records-from ...))..

In short, the update-records.. method will look for if the accessor
view-database is set. When a select query is done, this object is
generated with this set to the instance of the database that was used
to get the result. The update method assumes that if this is set,
that we are updating the record - even if we pass a database instance
along to the method.

I hope if others run into this issue that this will help explain
what's going on.

-David

On Dec 16, 4:35 pm, "David Thole (TheDarkTrumpet)" <dth...@gmail.com>
wrote:
> Hey All,
>
> For any clsql experts here.  For this particular bit of code:http://gist.github.com/258247I'm trying to select objects from one

Francogrex

unread,
Dec 19, 2009, 6:19:13 AM12/19/09
to
On Dec 18, 2:37 am, "David Thole (TheDarkTrumpet)" <dth...@gmail.com>
wrote:

> Incase others run into this issue, I've come up with a solution that
> appears to work fine.  The snippet of code I'm using is something
> like:
>
> ...
> (dolist (obj (query ...))
>   (setf (slot-value obj (intern "VIEW-DATABASE" 'clsql-sys)) nil)
>   (clsql:update-records-from ...))..
>
> In short, the update-records.. method will look for if the accessor
> view-database is set.  When a select query is done, this object is
> generated with this set to the instance of the database that was used
> to get the result.  The update method assumes that if this is set,
> that we are updating the record - even if we pass a database instance
> along to the method.
>
> I hope if others run into this issue that this will help explain
> what's going on.
>
> -David

Thanks for posting your solution. I encourage others as well to do the
same, it is very helpful that even if no external relies/solutions are
offered and the OP finds the solution in any other way, that he/she
inform the rest of us. Anyone with similar problem in the future would
search the google archives, finds this and hence life would be easier
(just like the OP intended).

0 new messages