Index: openacs-4/packages/acs-core-docs/www/db-api.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/db-api.adp,v diff -u -r1.1.2.3 -r1.1.2.4 --- openacs-4/packages/acs-core-docs/www/db-api.adp 28 Sep 2015 07:54:13 -0000 1.1.2.3 +++ openacs-4/packages/acs-core-docs/www/db-api.adp 2 Jan 2016 21:55:21 -0000 1.1.2.4 @@ -214,7 +214,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 @@ -232,7 +232,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 @@ -277,7 +277,7 @@

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 db_dml "abort" "abort +this instead of db_dml "abort" "abort transaction".

db_multirow
@@ -456,11 +456,11 @@ files containing the data to 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 of the @@ -508,13 +508,13 @@ 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)} } } proc print_the_foo {} { - doc_body_append "foo is [db_string "select col from foo"]<br>\n" + doc_body_append "foo is [db_string get_foo {select col from foo}]<br>\n" } replace_the_foo 8 @@ -523,7 +523,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 { @@ -582,11 +582,10 @@ # Clean out the foo table # -db_dml unused "delete from foo" +db_dml unused {delete from foo} +db_dml unused {insert into foo(baz) values(:baz)} -db_dml unused "insert into foo(baz) values('$baz')" - -set n_rows [db_string unused "select count(*) from foo where baz is null"] +set n_rows [db_string unused {select count(*) from foo where baz is null}] # # $n_rows is 1; in effect, the "baz is null" criterion is matching # the empty string we just inserted (because of Oracle's coercion @@ -596,7 +595,7 @@

To balance out this asymmetry, you can explicitly set baz to null by writing:

 
-db_dml foo_insert "insert into foo(baz) values(:1)" {[db_nullify_empty_string $baz]}
+db_dml foo_insert {insert into foo(baz) values(:1)} {[db_nullify_empty_string $baz]}