How to insert data in MYSQL database from the Common LISP?

Discussion of Common Lisp

How to insert data in MYSQL database from the Common LISP?

Postby nitinkapoor25 » Thu Feb 05, 2009 11:00 am

Hi,

I have made the connection between MySQL and LISP. Below is the query that I run to insert the data in the database, but I got Error message.

Query:


(clsql-sys:query "insert into article_EAN (article_id, article_ean) values (123789, 147852)")


Error Getting:


Unhandled memory fault at #x3C.
[Condition of type SB-SYS:MEMORY-FAULT-ERROR]

Restarts:
0: [ABORT] Return to SLIME's top level.
1: [TERMINATE-THREAD] Terminate this thread (#<THREAD "repl-thread" RUNNING {A884611}>)

Backtrace:
0: (SB-SYS:MEMORY-FAULT-ERROR)
[No Locals]
1: (SB-SYS:MEMORY-FAULT-ERROR)[:EXTERNAL]
Locals:
SB-DEBUG::ARG-0 = 0
2: ("foreign function: #x8064EFC")
[No Locals]
3: ("foreign function: #x8065150")
[No Locals]
4: ("foreign function: #xB7617C17")
[No Locals]
5: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0. SB-PCL::.ARG1. SB-PCL::.ARG2. SB-PCL::.ARG3.)) #<unavailable argument> #<unavailable argument> "insert into article_EAN (article_id, article_ean) values (123789, 147852)" #<CLSQL-MYSQL:MYSQL-DATABASE /POS/root OPEN {B376281}> :AUTO T)
Locals:
SB-DEBUG::ARG-0 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-1 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-2 = "insert into article_EAN (article_id, article_ean) values (123789, 147852)"
SB-DEBUG::ARG-3 = #<CLSQL-MYSQL:MYSQL-DATABASE /POS/root OPEN {B376281}>
SB-DEBUG::ARG-4 = :AUTO
SB-DEBUG::ARG-5 = T
6: ((SB-PCL::FAST-METHOD CLSQL-SYS:QUERY (STRING)) #<unavailable argument> #<unavailable argument> "insert into article_EAN (article_id, article_ean) values (123789, 147852)")[:EXTERNAL]
Locals:
SB-DEBUG::ARG-0 = 3
SB-DEBUG::ARG-1 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-2 = :<NOT-AVAILABLE>
SB-DEBUG::ARG-3 = "insert into article_EAN (article_id, article_ean) values (123789, 147852)"
7: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CLSQL-SYS:QUERY "insert into article_EAN (article_id, article_ean) values (123789, 147852)") #<NULL-LEXENV>)
Locals:
SB-DEBUG::ARG-0 = (CLSQL-SYS:QUERY "insert into article_EAN (article_id, article_ean) values (123789, 147852)")
SB-DEBUG::ARG-1 = #<NULL-LEXENV>
8: (SWANK::EVAL-REGION "(clsql-sys:query \"insert into article_EAN (article_id, article_ean) values (123789, 147852)\")
")
Locals:
SB-DEBUG::ARG-0 = "(clsql-sys:query \"insert into article_EAN (article_id, article_ean) values (123789, 147852)\")
"
9: ((LAMBDA NIL))
10: (SWANK::TRACK-PACKAGE #<CLOSURE (LAMBDA NIL) {BB03345}>)
Locals:
SB-DEBUG::ARG-0 = #<CLOSURE (LAMBDA NIL) {BB03345}>
11: ((LAMBDA (SWANK-BACKEND::FN)) #<CLOSURE (LAMBDA NIL) {BB0332D}>)
Locals:
SWANK-BACKEND::FN = #<CLOSURE (LAMBDA NIL) {BB0332D}>
12: (SWANK::CALL-WITH-BUFFER-SYNTAX #<CLOSURE (LAMBDA NIL) {BB0332D}>)
Locals:
SB-DEBUG::ARG-0 = #<CLOSURE (LAMBDA NIL) {BB0332D}>
13: (SWANK::REPL-EVAL "(clsql-sys:query \"insert into article_EAN (article_id, article_ean) values (123789, 147852)\")
")
Locals:
SB-DEBUG::ARG-0 = "(clsql-sys:query \"insert into article_EAN (article_id, article_ean) values (123789, 147852)\")
"
14: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:LISTENER-EVAL "(clsql-sys:query \"insert into article_EAN (article_id, article_ean) values (123789, 147852)\")
") #<NULL-LEXENV>)
Locals:
SB-DEBUG::ARG-0 = (SWANK:LISTENER-EVAL "(clsql-sys:query \"insert into article_EAN (article_id, article_ean) values (123789, 147852)\")
")
SB-DEBUG::ARG-1 = #<NULL-LEXENV>
15: ((LAMBDA NIL))
16: ((FLET #:FORM-FUN1570))
Locals:
SWANK-BACKEND::FUN = #<CLOSURE (LAMBDA NIL) {BB03295}>
17: ((FLET #:FORM-FUN1570))
Locals:
SWANK-BACKEND::FUN = #<CLOSURE (LAMBDA NIL) {BB03295}>
18: ((LAMBDA (SWANK-BACKEND::HOOK SWANK-BACKEND::FUN)) #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL) {BB03295}>)
Locals:
SB-KERNEL:*HANDLER-CLUSTERS* = :<NOT-AVAILABLE>
SWANK-BACKEND::FUN = #<CLOSURE (LAMBDA NIL) {BB03295}>
SWANK-BACKEND::HOOK = #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK>
19: ((LAMBDA NIL))
[No Locals]
20: ((FLET #:FORM-FUN1570))
Locals:
SWANK-BACKEND::FUN = #<FUNCTION (LAMBDA NIL) {B9C0F0D}>
21: ((FLET #:FORM-FUN1570))
Locals:
SWANK-BACKEND::FUN = #<FUNCTION (LAMBDA NIL) {B9C0F0D}>
22: ((LAMBDA (SWANK-BACKEND::HOOK SWANK-BACKEND::FUN)) #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL) {B9C0F0D}>)
Locals:
SB-KERNEL:*HANDLER-CLUSTERS* = :<NOT-AVAILABLE>
SWANK-BACKEND::FUN = #<FUNCTION (LAMBDA NIL) {B9C0F0D}>
SWANK-BACKEND::HOOK = #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK>
23: (SWANK::CALL-WITH-REDIRECTED-IO #<SWANK::CONNECTION {B3B1001}> #<CLOSURE (LAMBDA NIL) {BB031FD}>)
Locals:
SB-DEBUG::ARG-0 = #<SWANK::CONNECTION {B3B1001}>
SB-DEBUG::ARG-1 = #<CLOSURE (LAMBDA NIL) {BB031FD}>
24: (SWANK::CALL-WITH-CONNECTION #<SWANK::CONNECTION {B3B1001}> #<FUNCTION (LAMBDA NIL) {B9C0F0D}>)
Locals:
SB-DEBUG::ARG-0 = #<SWANK::CONNECTION {B3B1001}>
SB-DEBUG::ARG-1 = #<FUNCTION (LAMBDA NIL) {B9C0F0D}>
25: (SWANK::HANDLE-REQUEST #<SWANK::CONNECTION {B3B1001}>)
Locals:
SB-DEBUG::ARG-0 = #<SWANK::CONNECTION {B3B1001}>
26: (SWANK::REPL-LOOP #<SWANK::CONNECTION {B3B1001}>)
Locals:
SB-DEBUG::ARG-0 = #<SWANK::CONNECTION {B3B1001}>
27: (SWANK::REPL-LOOP #<SWANK::CONNECTION {B3B1001}>)[:EXTERNAL]
Locals:
SB-DEBUG::ARG-0 = 1
SB-DEBUG::ARG-1 = #<SWANK::CONNECTION {B3B1001}>
28: (SWANK::CALL-WITH-BINDINGS NIL #<CLOSURE (LAMBDA NIL) {A88A07D}>)
Locals:
SB-DEBUG::ARG-0 = NIL
SB-DEBUG::ARG-1 = #<CLOSURE (LAMBDA NIL) {A88A07D}>
29: ((FLET SB-THREAD::WITH-MUTEX-THUNK))
[No Locals]
Catch-tags:
SB-IMPL::%END-OF-THE-WORLD
SB-INT:TOPLEVEL-CATCHER
30: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-MUTEX]477))
[No Locals]
31: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK) {B6449215}> #S(SB-THREAD:MUTEX :NAME "thread result lock" :%OWNER #<SB-THREAD:THREAD "repl-thread" RUNNING {A884611}> :STATE 1) #<SB-THREAD:THREAD "repl-thread" RUNNING {A884611}> T)
Locals:
SB-DEBUG::ARG-0 = #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK) {B6449215}>
SB-DEBUG::ARG-1 = #S(SB-THREAD:MUTEX :NAME "thread result lock" :%OWNER #<SB-THREAD:THREAD "repl-thread" RUNNING {A884611}> :STATE 1)
SB-DEBUG::ARG-2 = #<SB-THREAD:THREAD "repl-thread" RUNNING {A884611}>
SB-DEBUG::ARG-3 = T
32: ((LAMBDA NIL))
[No Locals]
33: ("foreign function: #x8064EFC")
[No Locals]
34: ("foreign function: #x8052D31")
[No Locals]
35: ("foreign function: #x805C1AD")
[No Locals]
36: ("foreign function: #xB7FBC50F")
[No Locals]
nitinkapoor25
 
Posts: 11
Joined: Mon Jan 05, 2009 10:17 am

Re: How to insert data in MYSQL database from the Common LISP?

Postby dmitry_vk » Thu Feb 05, 2009 1:13 pm

I think that the reason of this is that for INSERTs, you need not to use the clsql:query, but clsql:execute-command. They differ in that clsql:query expects that the SQL query will return some results, and clsql:execute-command does not expect results. CL-SQL uses libmysql and probably libmysql crashes when you try to extract result from query that does not produces one.
But the backtrace and the memory fault are certainly a bad thing here, CLSQL should be more polite to the user :)
dmitry_vk
 
Posts: 96
Joined: Sat Jun 28, 2008 8:01 am
Location: Russia, Kazan

Re: How to insert data in MYSQL database from the Common LISP?

Postby nitinkapoor25 » Fri Feb 06, 2009 9:52 am

Thank brother...it is working for me :D
nitinkapoor25
 
Posts: 11
Joined: Mon Jan 05, 2009 10:17 am


Return to Common Lisp

Who is online

Users browsing this forum: Bing [Bot] and 3 guests