Index: openacs-4/packages/acs-core-docs/www/db-api-detailed.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/db-api-detailed.html,v diff -u -N -r1.48 -r1.49 --- openacs-4/packages/acs-core-docs/www/db-api-detailed.html 27 Oct 2014 16:39:17 -0000 1.48 +++ openacs-4/packages/acs-core-docs/www/db-api-detailed.html 7 Aug 2017 23:47:49 -0000 1.49 @@ -1,5 +1,5 @@ -Database Access API

Database Access API

By Jon Salz. Revised and expanded by Roberto Mello (rmello at fslc dot usu dot edu), July 2002.

+Database Access API

Database Access API

By Jon Salz. Revised and expanded by Roberto Mello (rmello at fslc dot usu dot edu), July 2002.

OpenACS docs are written by the named authors, and may be edited by OpenACS documentation staff.
  • Tcl procedures: /packages/acs-kernel/10-database-procs.tcl

  • Tcl initialization: /packages/acs-kernel/database-init.tcl

The Big Picture

@@ -29,9 +29,9 @@ } db_transaction { -db_dml unused "insert into greeble(bork) values(33)" -foo $db -db_dml unused "insert into greeble(bork) values(50)" + db_dml unused {insert into greeble(bork) values(33)} + foo $db + db_dml unused {insert into greeble(bork) values(50)} }

@@ -314,7 +314,7 @@ set bar "" set baz "" -db_dml foo_create "insert into foo(bar, baz) values(:bar, :baz)" +db_dml foo_create {insert into foo(bar, baz) values(:bar, :baz)} # # the values of the "bar" and "baz" columns in the new row are both # null, because Oracle has coerced the empty string (even for the @@ -333,7 +333,7 @@ set bar [db_null] set baz [db_null] -db_dml foo_create "insert into foo(bar, baz) values(:bar, :baz)" +db_dml foo_create {insert into foo(bar, baz) values(:bar, :baz)} # # sets the values for both the "bar" and "baz" columns to null @@ -471,11 +471,11 @@ insert. Only one of -blobs, -clobs, -blob_files, and -clob_files may be provided.

Example:

 
-db_dml insert_photos "
+db_dml insert_photos {
         insert photos(photo_id, image, thumbnail_image)
         values(photo_id_seq.nextval, empty_blob(), empty_blob())
         returning image, thumbnail_image into :1, :2
-    "  -blob_files [list "/var/tmp/the_photo" "/var/tmp/the_thumbnail"] 
+    } -blob_files [list "/var/tmp/the_photo" "/var/tmp/the_thumbnail"] 
 
 

This inserts a new row into the photos table, with the contents @@ -494,7 +494,7 @@ db_write_blob statement-name sql [ -bind bind_set_id | -bind bind_value_list ] db_blob_get_file statement-name sql [ -bind bind_set_id | -bind bind_value_list ] -

Analagous to ns_ora write_clob/write_blob/blob_get_file. +

Analogous to ns_ora write_clob/write_blob/blob_get_file.

db_release_unused_handles
@@ -512,8 +512,8 @@
 
 proc replace_the_foo { col } {
     db_transaction {
-        db_dml "delete from foo"
-        db_dml "insert into foo(col) values($col)"
+        db_dml delete {delete from foo}
+        db_dml insert {insert into foo(col) values($col)}
     }
 }
 
@@ -527,7 +527,7 @@
 db_transaction {
     replace_the_foo 14
     print_the_foo ; # Writes out "foo is 14"
-    db_dml "insert into some_other_table(col) values(999)"
+    db_dml insert_foo {insert into some_other_table(col) values(999)}
     ...
     db_abort_transaction
 } on_error {
@@ -541,7 +541,7 @@
 
 db_abort_transaction
 

Aborts all levels of a transaction. That is if this is called within -several nested transactions, all of them are terminated. Use this insetead of +several nested transactions, all of them are terminated. Use this instead of db_dml "abort" "abort transaction". @@ -728,4 +728,4 @@ The nsv containing the list is initialized by the bootstrap script and should never be referenced directly by user code. Returns the current rdbms type and version. -

($Id$)
View comments on this page at openacs.org
+

($Id$)