Does anybody know what is required to use "OpenAcs DB API" for
accessing Postgres DB within aolserver?
Thank you
--
Xavier Bourguignon
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <list...@listserv.aol.com> with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.
The code relies on a configuration param in your AOLserver config file also see
return [nsv_get ad_database_type .] where there is an nsv variable
set on startup to decide oracle or postgresql.
This was just a quick review there might be other stuff you will need
to make it work.
OpenACS also has automatic database handle handling (sorry couldn't
think of a better word for that.)
This contains the postgresql bind variable emulation implementation as
well that replaces tcl variables in the query string.
Here is an overview of how the database api works.
http://openacs.org/doc/current/db-api.html
Dave
--
Dave Bauer
da...@solutiongrove.com
http://www.solutiongrove.com
OpenACS is a complete integrated platform for creating web communities;
I suspect that the DB api builds on the ACS core api and as such it is
not a trivial matter to use the former without the latter. If you're
building a new community system, OpenACS is worth a look, but it's a
large system to just jump into (especially as an intro to aolserver,
tcl, or both).
http://openacs.org/ - OpenACS home
http://openacs.org/doc/current/db-api.html - docs on the ACS db api
That said, it's not difficult to emulate some of the useful things like
bind variables. This proc expands ? in sql statements. It could easily
be made to call ns_dbquotevalue before replacing the variables. It does
not do anything with the db drivers, so it is of no help for something
like bypassing oracle's 4000 character limit as native bind variables do.
proc bindsql {sql args} {
set varcount [llength $args]
set indices [regexp -all -indices -inline {\?} $sql]
if {[llength $indices] != $varcount} {
error "[llength $indices] variables expected, $varcount passed"
}
set ofs 0
foreach replacement $args idx $indices {
set ix [expr {[lindex $idx 0]+$ofs}]
set sql [string replace $sql $ix $ix $replacement]
incr ofs [string length $replacement]
incr ofs -1
}
return $sql
}
set adminop_sql {select * from tadminop where status = ?}
ns_db select $db [bindsql $adminop_sql 'a']
-J
On Wed, 2008-04-02 at 20:49 +0100, Xavier Bourguignon wrote:
> Hi All,
>
> Does anybody know what is required to use "OpenAcs DB API" for
> accessing Postgres DB within aolserver?
>
> Thank you
>
--
Jeff, I have been using your code and adapted it to my needs, thanks for that.
On 02/04/2008, Juan José del Río (Simple Option)
--
Xavier Bourguignon