Ns db

From AOLserver Wiki
Jump to: navigation, search

Man page: http://aolserver.com/docs/tcl/ns_db.html


NAME

ns_db - Standard database access API.

SYNOPSIS

ns_db option ?arg arg ...?

DESCRIPTION

This command provides a mechanism to access databases. The legal options (which may be abbreviated) are:

  • ns_db bindrow dbhandle
  • ns_db bouncepool poolname
Marks all database handles for the specified database pool as stale. When any database handle currently open is put back into the pool, its connection to the database will be reset.
  • ns_db cancel dbhandle
  • ns_db close dbhandle
Closes the connection. Use this function only on handles that were obtained by the ns_db open function. The server automatically close handles when the operation is complete, so you don't normally have to call this function.
  • ns_db connected dbhandle
  • ns_db datasource dbhandle
Returns the datasource for the database pool.
  • ns_db dbtype dbhandle
Returns the database type for the database pool.
  • ns_db dml dbhandle sql
  • ns_db driver dbhandle
Returns the name of the driver of the handle.
  • ns_db exception dbhandle
  • ns_db exec dbhandle sqlcommand
Executes the specified SQL command. It returns either NS_DML (if the SQL command is a DML or DDL command) or NS_ROWS (if the SQL command returns rows, such as a SELECT). This function can be used for ad hoc querying, where you don't know what kind of SQL command will be executed.
  • ns_db flush dbhandle
  • ns_db gethandle ?-timeout timeout? poolname ?nhandles?
  • ns_db getrow dbhandle setId
  • ns_db open driver datasource user password
  • ns_db poolname dbhandle
  • ns_db pools
  • ns_db releasehandle dbhandle
Puts the handle back in the pool. The server will automatically return any open handles to the pool after a page has finished executing.
  • ns_db 1row dbhandle sql
This command expects the SQL to be a select statement that returns exactly one row and returns that row as an ns_set. An error is returned if zero or more than one row is returned.
  • ns_db 0or1row dbhandle sql
This command expects the SQL to be a select statement that returns exactly zero or one row. On zero rows, a null string is returned. On one row, a newly allocated ns_set is returned. An error is thrown if more then one row is returned.
  • ns_db password dbhandle
Returns the password of the user for the database pool.
  • ns_db select dbhandle sql
  • ns_db setexception dbhandle code message
  • ns_db sp_exec dbhandle
  • ns_db sp_getparams
  • ns_db sp_returncode dbhandle
  • ns_db sp_setparam dbhandle varname vartype inout value
  • ns_db sp_start dbhandle procname
  • ns_db user dbhandle
Returns the user for the database pool.
  • ns_db verbose dbhandle ?on | off?

EXAMPLES

SEE ALSO

ns_buildsqldate, ns_buildsqltime, ns_buildsqltimestamp, ns_dbquotename, ns_dbquotevalue, ns_localsqltimestamp, ns_parsesqldate, ns_parsesqltime, ns_parsesqltimestamp, ns_writecsv
The tutorial Accessing A Database shows some very simple ns_db usage