[docs] docs - heins modified ictags.sdf

docs@interchange.redhat.com docs@interchange.redhat.com
Wed Jul 3 15:00:00 2002


User:      heins
Date:      2002-07-03 18:59:57 GMT
Modified:  .        ictags.sdf
Log:
* Document [counter sql=3D"sometable:sequence_name"]

Revision  Changes    Path
1.89      +70 -4     docs/ictags.sdf


rev 1.89, prev_rev 1.88
Index: ictags.sdf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/docs/ictags.sdf,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- ictags.sdf	22 Jun 2002 15:19:02 -0000	1.88
+++ ictags.sdf	3 Jul 2002 18:59:57 -0000	1.89
@@ -1,10 +1,10 @@
 !init OPT_LOOK=3D"akopia"; OPT_STYLE=3D"manual"=20
-# $Id: ictags.sdf,v 1.88 2002/06/22 15:19:02 edl Exp $
+# $Id: ictags.sdf,v 1.89 2002/07/03 18:59:57 mheins Exp $
=20
 !define DOC_NAME "Interchange Tags Reference"
 !define DOC_TYPE ""
 !define DOC_CODE "ictags"
-!define DOC_VERSION substr('$Revision: 1.88 $', 11, -2)
+!define DOC_VERSION substr('$Revision: 1.89 $', 11, -2)
 !define DOC_STATUS "Draft"
 !define DOC_PROJECT "Interchange"
 !define DOC_URL "http://interchange.redhat.com/doc/ictags.html"
@@ -3653,7 +3653,13 @@
=20
 The counter is implemented using Perl's C<File::Counter> module, which pro=
tects the file against simultaneous access by multiple processes.
=20
-\WARNING: This tag will not work under {{CMD[jump=3D"http://www.perl.com/p=
ub/doc/manual/html/lib/Safe.html"]Safe}}, i.e. in embedded Perl.
+If the optional C<sql> attribute is used, a SQL sequence will be used. Cur=
rently
+MySQL and Postgres are supported. The sequence must already exist. If no C=
<bypass>
+parameter is sent, the table in the sequence callout (explained below) wil=
l be used
+and must be an Interchange table (i.e. set up with Database setting). If C=
<bypass>
+is set, then the DSN for the sequence will be passed in the C<dsn> paramet=
er.
+
+\WARNING: This tag may not work under {{CMD[jump=3D"http://www.perl.com/pu=
b/doc/manual/html/lib/Safe.html"]Safe}}, i.e. in embedded Perl.
=20
 Additional parameters:
=20
@@ -3664,20 +3670,80 @@
=20
 H4: {{CMD[id=3D"counter_start"]start=3D50}}
=20
-Causes a new counter to be created and to start from 50 (for example) if i=
t did not exist before.
+Causes a new counter to be created and to start from 50 (for example) if
+it did not exist before. This option is not applicable to SQL counters.
=20
 H4: {{CMD[id=3D"counter_value"]value=3D1}}
=20
 Shows the value of the counter without incrementing or decrementing it.
+This option is not applicable to SQL counters.
=20
+H4: {{CMD[id=3D"counter_sql"]sql=3D"table:sequence"}}
=20
+The table and sequence name of the SQL counter.
=20
+If the type of database is Postgres, the C<table> is used to derive the
+database and the sequence will be a named sequence independent of the
+table; the sequence is incremented and accessed by "SELECT
+nextval('sequence_name')".
=20
+If the type of database is MySQL, an AUTO_INCREMENT key column is
+assumed and an insert of C<0> followed by "select last_insert_id()" will
+increment then access the counter.
=20
 # BEGIN ########### counter Subsections ##############
 H4: {{CMD[id=3D"counter_file"]file}}
=20
+H3: SQL Counter Examples
+
+To set up a Postgres counter, simply create a named sequence in the
+database:
+
+!block example
+  CREATE SEQUENCE "foo" start 1 increment 1 maxvalue 2147483647 minvalue 1=
 cache 1=20
+!endblock
+
+You will want to make sure you have an Interchange table that uses
+that database ("sometable" in the below example).
+
+Then access it with:
=20
+!block example
+  [counter sql=3D"sometable:foo"]
+!endblock
+
+You can create as many sequences as you like.
+
+To set up a MySQL counter, add a table to your MySQL database in catalog.c=
fg
+or other place like C<dbconf/mysql>:
+
+!block example
+  Database sequence_name sequence_name.txt dbi:mysql:test_foundation
+  Database sequence_name COLUMN_DEF "id=3Dint NOT NULL AUTO_INCREMENT PRIM=
ARY KEY"
+!endblock
+
+Make sure you set up the sequence.txt file if you want Interchange to crea=
te
+the table for you.
+
+Then access it with:
+
+!block example
+  [counter sql=3D"sequence_name:sequence_name"]
+!endblock
+
+Alternatively, you can create the table without Interchange definition
+as long as it is in the same database as an Interchange table:
+
+!block example
+  mysql> create table sequence_name(id int NOT NULL AUTO_INCREMENT PRIMARY=
 KEY);
+!endblock
+
+Then access it by calling the Interchange-defined table name followed
+by the table that has the AUTO_INCREMENT key:
+
+!block example
+  [counter sql=3D"products:sequence_name"]
+!endblock
=20
 # END ++++++++++++ counter Subsections +++++++++++++
=20