<cl> (load "/b/objfads/src/objfads/libpq/defsys.cl")
; Loading /b/objfads/src/objfads/libpq/defsys.cl.

T 
<cl> (libpq::load-libpq)
Loading PQEXEC...
; Fast loading /b/objfads/src/objfads/libpq/pqexec.fasl.
Loading PQCOMM...
; Fast loading /b/objfads/src/objfads/libpq/pqcomm.fasl.
; Foreign loading /b/objfads/src/objfads/libpq/libpq.o.
; Fast loading /usr/local/lib/cl/code/foreign.fasl.
Loading BLOCKS...
; Fast loading /b/objfads/src/objfads/libpq/blocks.fasl.
Loading PORTAL...
; Fast loading /b/objfads/src/objfads/libpq/portal.fasl.
Loading DUMPDATA...
; Fast loading /b/objfads/src/objfads/libpq/dumpdata.fasl.

NIL 
<cl> (use-package 'libpq)

T 
<cl> (pqdatabase)

NIL 
<cl> (pqsetdb "ywang")

"ywang" 
<cl> (pqexec "create emp (name = char16, salary = int4, dept = text)")

T 
("C" "CREATE") 
<cl> (pqexec "append emp (name = \"Yongdong\", salary = 10000, dept = text[\"shoe\"])")

T 
("C" "append") 
<cl> (pqexec "retrieve portal eportal (emp.all) where emp.salary > 5000")

T 
("C" "retrieve") 
<cl> (pqexec "fetch all in eportal")

T 
("P" "eportal") 
<cl> (setq foo (pqparray "eportal"))

#(1 1 1 3 #("name" 19 16 "salary" 23 4 "dept" 25 65535 NIL ...) #("Yongdong10000shoe" 0 8 "Yongdong10000shoe" 8 5 "Yongdong10000shoe" 13 4 NIL ...) NIL NIL NIL NIL ...) 
<cl> (setq n (pqntuples foo))

1 
<cl> (setq m (pqnfields foo 0))

3 
<cl> (dotimes (i m) (print (pqgetvalue foo 0 i)))

"Yongdong" 
"10000" 
"shoe" 
NIL 
<cl> (pqexec "replace emp (salary = 20000) where emp.dept = text[\"shoe\"] and emp.salary != 20000")")

T 
("C" "replace") 
<cl> (pqexec "retrieve (emp.all)")

T 
("P" "") 
<cl> (let () (setq blankp (pqparray "")) nil)

NIL 
<cl> (pqfname blankp 0 0)

"name" 
<cl> (pqfname blankp 0 1)

"salary" 
<cl> (pqgetvalue blankp 0 1)

"20000" 
<cl> (pqexec "delete emp where emp.name = \"Yongdong\"")

T 
("C" "delete") 
<cl> (pqexec "destroy emp")

T 
("C" "DESTROY") 
<cl> (pqfinish)

T 
<cl> 
