refactor sqlite bind

db4
Doug Coleman 2009-04-13 17:40:35 -05:00
parent 1789a58bbf
commit c9db0fdee1
2 changed files with 8 additions and 2 deletions

View File

@ -23,7 +23,7 @@ PRIVATE>
: sql-bind-command ( sequence string -- )
f f <statement> [
sqlite-maybe-prepare [
handle>> '[ [ _ ] 2dip 1+ swap sqlite-bind-text ] each-index
handle>> swap sqlite-bind-sequence
] [
sqlite-result-set new-result-set advance-row
] bi
@ -32,7 +32,7 @@ PRIVATE>
: sql-bind-query ( in-sequence string -- out-sequence )
f f <statement> [
sqlite-maybe-prepare [
handle>> '[ [ _ ] 2dip 1+ swap sqlite-bind-text ] each-index
handle>> swap sqlite-bind-sequence
] [
statement>result-sequence
] bi

View File

@ -8,6 +8,9 @@ IN: db2.sqlite.lib
: ?when ( object quot -- object' ) dupd when ; inline
: assoc-with ( object sequence quot -- obj curry )
swapd [ [ -rot ] dip call ] 2curry ; inline
: sqlite-check-result ( n -- )
{
{ SQLITE_OK [ ] }
@ -107,3 +110,6 @@ IN: db2.sqlite.lib
: sqlite-next ( prepared -- ? )
sqlite3_step sqlite-step-has-more-rows? ;
: sqlite-bind-sequence ( handle sequence -- )
[ 1+ swap sqlite-bind-text ] assoc-with each-index ;