Index: openacs-4/packages/acs-core-docs/www/db-api-detailed.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/db-api-detailed.adp,v diff -u -r1.1.2.3 -r1.1.2.4 --- openacs-4/packages/acs-core-docs/www/db-api-detailed.adp 28 Sep 2015 07:54:13 -0000 1.1.2.3 +++ openacs-4/packages/acs-core-docs/www/db-api-detailed.adp 2 Jan 2016 21:55:21 -0000 1.1.2.4 @@ -46,9 +46,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)} }
This would insert greeble #33 and do all the stuff in @@ -217,9 +217,9 @@ Useful
Why bother with bind variables at all - why not just write the Tcl statement above like this:
-db_dml presentation_delete " - delete from wp_presentations where presentation_id = $some_presentation_id -" +db_dml presentation_delete { + delete from wp_presentations where presentation_id = :some_presentation_id +}
(Note the use of double-quotes to allow the variable reference
to $some_presentation_id
to be
@@ -324,7 +324,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
@@ -342,7 +342,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
@@ -494,11 +494,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
files /var/tmp/the_photo
and
@@ -540,13 +540,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
@@ -555,7 +555,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 {
@@ -570,7 +570,7 @@
db_abort_transaction
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 db_dml "abort" "abort
+this instead of
db_dml "abort" "abort
transaction"
.
db_multirow
@@ -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
@@ -508,17 +508,19 @@
transactions. It is possible to specify an optional on_error
code block that will be executed if some code in code_block throws
an exception. The variable errmsg
will be bound in that scope.
-If there is no on_error
code, any errors will be propagated.
Example:
+If there is noon_error
code, any + errors will be propagated. +Example:
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 @@ -527,7 +529,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 +543,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"
.
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
-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]}Index: openacs-4/packages/acs-core-docs/www/db-api.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/db-api.html,v diff -u -r1.50.2.5 -r1.50.2.6 --- openacs-4/packages/acs-core-docs/www/db-api.html 1 Dec 2015 14:38:40 -0000 1.50.2.5 +++ openacs-4/packages/acs-core-docs/www/db-api.html 2 Jan 2016 21:55:21 -0000 1.50.2.6 @@ -299,7 +299,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"
.
@@ -567,13 +567,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
@@ -582,7 +582,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 {
Index: openacs-4/packages/acs-core-docs/www/xml/developers-guide/db-api.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/xml/developers-guide/db-api.xml,v
diff -u -r1.13 -r1.13.8.1
--- openacs-4/packages/acs-core-docs/www/xml/developers-guide/db-api.xml 12 Jul 2009 01:08:30 -0000 1.13
+++ openacs-4/packages/acs-core-docs/www/xml/developers-guide/db-api.xml 2 Jan 2016 21:55:21 -0000 1.13.8.1
@@ -467,7 +467,7 @@