1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988
|
<section id="dio">
<title>DIO - Database Interface Objects</title>
<refentry id="dio_package">
<refnamediv>
<refname>DIO</refname>
<refpurpose>Database Interface Objects</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>::DIO::handle</command>
<arg choice="plain"><replaceable>interface</replaceable></arg>
<arg choice="opt"><replaceable>objectName</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<cmdsynopsis>
<command>::DIO::handle Tdbc</command>
<arg choice="plain"><replaceable>interface</replaceable></arg>
<arg choice="opt"><replaceable>objectName</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>DIO</command> is designed to be a generic,
object-oriented interface to SQL databases. Its main goal
is to be as generic as possible, but since not all SQL
databases support the exact same syntaxes, keeping code
generic between databases is left to the abilities of the
programmer. DIO simply provides a way to keep the Tcl
interface generic.
</para>
<para>
<option>interface</option> - The name of the database
interface. Currently supported direct interfaces are
<option>Postgresql</option>, <option>Mysql</option>,
<option>Oracle</option> and <option>Sqlite</option>.
Start with version 1.2 DIO supports also the <ulink url="https://https://core.tcl-lang.org/tdbc">TDBC</ulink>
interface through the <option>Tdbc</option> interfaces.
In this form the command requires a further argument for one of the
TDBC supported DBMS driver <option>mysql</option>. TDBC drivers are:
<option>mysql</option> (supports also MariaDB),
<option>odbc</option> (provides also support for <option>Oracle</option>),
<option>postgresql</option> and <option>sqlite</option>
</para>
<para>
If <option><replaceable>objectName</replaceable></option> is
specified, DIO creates an object of that name. If there is
no <option><replaceable>objectName</replaceable></option>
given, DIO will automatically generate a unique object ID
</para>
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-host</arg>
<arg choice="opt"><replaceable>hostname</replaceable></arg>
</cmdsynopsis>
<para>
The hostname of the computer to connect to. If none
is given, DIO assumes the local host.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-port</arg>
<arg><replaceable>portNumber</replaceable></arg>
</cmdsynopsis>
<para>The port number to connect to on <option>hostname</option>.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-user</arg>
<arg><replaceable>username</replaceable></arg>
</cmdsynopsis>
<para>The username you wish to login to the server as.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-pass</arg>
<arg><replaceable>password</replaceable></arg>
</cmdsynopsis>
<para>The password to login to the server with.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-db</arg>
<arg><replaceable>database</replaceable></arg>
</cmdsynopsis>
<para>
The name of the database to connect to.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-table</arg>
<arg><replaceable>tableName</replaceable></arg>
</cmdsynopsis>
<para>
The default table to use when using built-in commands
for storing and fetching.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-keyfield</arg>
<arg><replaceable>keyFieldname</replaceable></arg>
</cmdsynopsis>
<para>
The default field to use as the primary key when using
built-in commands for storing and fetching.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-autokey</arg>
<group>
<arg>1</arg>
<arg>0</arg>
</group>
</cmdsynopsis>
<para>
If this option is set to 1, DIO will attempt to
determine an automatic key for
<option>keyField</option> when storing and fetching.
In most databases, this requires that the
<option>sequence</option> also be specified. In the
case of MySQL, where sequences do not exist, autokey
must be used in conjunction with a table which has a
field specified as AUTO.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-sequence</arg>
<arg><replaceable>sequenceName</replaceable></arg>
</cmdsynopsis>
<para>
If DIO is automatically generating keys, it will use
this sequence as a means to gain a unique number for
the stored key.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>DIO Object Commands</title>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>array</arg>
<arg><replaceable>request</replaceable></arg>
</cmdsynopsis>
<para>
Execute <option>request</option> as a SQL query and
create an array from the first record found. The
array is set with the fields of the table and the
values of the record found.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>autokey</arg>
<group choice="opt">
<arg>value</arg>
<arg>boolean</arg>
</group>
</cmdsynopsis>
<para>
Return the current autokey value. If
<option>value</option> is specified, it sets a new
value for the autokey option.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>close</arg>
</cmdsynopsis>
<para> Close the current database connection. This command is
automatically called when the DIO object is destroyed.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>count</arg>
</cmdsynopsis>
<para> Return a count of the number of rows in the
specified (or current) table.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>db</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current database. If
<option>value</option> is specified, it sets a new
value for the database. In most cases, the DIO object
will automatically connect to the new database when
this option is changed.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>delete</arg>
<arg><replaceable>key</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Delete a record from the database where the primary
key matches <option>key</option>.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>destroy</arg>
</cmdsynopsis>
<para>
Destroy the DIO object.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>errorinfo</arg>
<arg choice="opt">value</arg>
</cmdsynopsis>
<para><option>errorinfo</option> contains the value of
the last error, if any, to occur while executing a
request. When a request fails for any reason, this
variable is filled with the error message from the SQL
interface package.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>exec</arg>
<arg><replaceable>request</replaceable></arg>
</cmdsynopsis>
<para>
Execute <option>request</option> as an SQL query.
When the exec command is called, the query is
executed, and a DIO result object is returned. From
there, the result object can be used to obtain
information about the query status and records in a
generic way. See <link linkend="resultobj">Result
Object Commands</link>
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>fetch</arg>
<arg><replaceable>key</replaceable></arg>
<arg><replaceable>arrayName</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Fetch a record from the database where the primary key
matches <option>key</option> and store the result in
an array called <option>arrayName</option>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>forall</arg>
<arg><replaceable>request</replaceable></arg>
<arg><replaceable>arrayName</replaceable></arg>
<arg><replaceable>body</replaceable></arg>
</cmdsynopsis>
<para>
Execute an SQL select <option>request</option> and iteratively
fill the array named <option>arrayName</option>
with elements named with the matching field names, and
values containing the matching values, repeatedly executing
the specified code <option>body</option>
for each row returned.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>host</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current host value. If
<option>value</option> is specified, it sets a new
value for the host.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>insert</arg>
<arg><replaceable>table</replaceable></arg>
<arg><replaceable>arrayName</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Insert fields from <option>arrayName</option> into the specified <option>table</option> in the database.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>interface</arg>
</cmdsynopsis>
<para>
Return the database interface type, such as
<literal>Postgresql</literal> or <literal>Mysql</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>keyfield</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current keyfield. If
<option>value</option> is specified, it sets a new
value for the keyfield. <option>Value</option> can contain
multiple key fields as a Tcl list, if the table has multiple
key fields.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>keys</arg>
<arg choice="opt"><replaceable>pattern</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Return a list of keys in the database. If
<option>pattern</option> is specified, only the keys
matching will be returned.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>lastkey</arg>
</cmdsynopsis>
<para>
Return the last key that was used from
<option>sequence</option>. If sequence has not been
specified, this command returns an empty string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>list</arg>
<arg>request</arg>
</cmdsynopsis>
<para>
Execute <option>request</option> as a SQL query and
return a list of the first column of each record
found.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>makekey</arg>
<arg><replaceable>arrayName</replaceable></arg>
<arg choice="opt"><replaceable>keyfield</replaceable></arg>
</cmdsynopsis>
<para>
Given an array containing key-value pairs and an optional
list of key fields (we use the object's keyfield if
none is specified), if we're doing auto keys, create
and return a new key, otherwise if it's a single key,
just return its value from the array, else if there are
multiple keys, return all the keys' values from the
array as a list.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>nextkey</arg>
</cmdsynopsis>
<para>Increment <option>sequence</option> and return the
next key to be used. If sequence has not been
specified, this command returns an empty
string.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>open</arg>
</cmdsynopsis>
<para>Open the connection to the current database. This
command is automatically called from any command which
accesses the database.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>pass</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current pass value. If
<option>value</option> is specified, it sets a new
value for the password.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>port</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>Return the current port value. If <option>value</option> is
specified, it sets a new value for the port.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>quote</arg>
<arg><replaceable>string</replaceable></arg>
</cmdsynopsis>
<para>Return the specified <option>string</option> quoted in
a way that makes it acceptable as a value in a SQL statement.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>search</arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Search the current table, or the specified table if
-table tableName is specified, for rows matching
one or more fields as key-value pairs, and return
a query result handle.
See <link linkend="resultobj">Result Object Commands</link>
</para>
<para>
For example,
<programlisting>set res [DIO search -table people -firstname Bob]</programlisting>
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>sequence</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current sequence value. If <option>value</option> is
specified, it sets a new value for the sequence.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>store</arg>
<arg><replaceable>arrayName</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Store the contents of <option>arrayName</option> in the
database, where the keys are the field names and the
array's values are the corresponding values. Do an SQL insert
if the corresponding row doesn't exist, or an update
if it does.
</para>
<para>
The table name must have been previously set
or specified with <arg>-table</arg>, and the key field(s) must
have been previously set or specified with
<arg>-keyfield</arg>.
</para>
<para>
Please note that the store method has significantly higher
overhead than
the update or insert methods, so if you know you are
inserting a row rather than updating one, it is advisable
to use the insert method and, likewise, if you know you
are updating rather than inserting, to use the
update method.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>string</arg>
<arg><replaceable>request</replaceable></arg>
</cmdsynopsis>
<para>
Execute <option>request</option> as a SQL query and
return a string containing the first record
found.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>table</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>Return the current table. If
<option>value</option> is specified, it sets a new
value for the table.</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>update</arg>
<arg><replaceable>arrayName</replaceable></arg>
<group choice="opt">
<arg>-option</arg>
<arg><replaceable>option</replaceable></arg>
<arg>...</arg>
</group>
</cmdsynopsis>
<para>
Updates the row matching the contents of
<option>arrayName</option> in the database. The matching
row must already exist. The table can have already been
set or can be specified with <arg>-table</arg>, and
the key field(s) must either have been set or
specified with <arg>-keyfield</arg>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>objectName</replaceable></arg>
<arg>user</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current user value. If
<option>value</option> is specified, it sets a new
value for the user.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="resultobj">
<title>Result Object Commands</title>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>autocache</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current autocache value. If
<option>value</option> is specified, it sets a new
value for autocache.
</para>
<para>
If autocache is true, the result object will
automatically cache rows as you use them. This means
that the first time you execute a forall command, each
row is being cached in the result object itself and
will no longer need to access the SQL result.
<emphasis>Default is true</emphasis>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>cache</arg>
</cmdsynopsis>
<para>
Cache the results of the current SQL result in the
result object itself. This means that even if the
database connection is closed and all the results of
the DIO object are lost, this result object will still
maintain a cached copy of its records.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>errorcode</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current errorcode value. If <option>value</option>
is specified, it sets a new value for errorcode.
</para>
<para>
<option>errorcode</option> contains the current code from the
SQL database which specifies the result of the query
statement which created this object. This variable
can be used to determine the success or failure of a
query.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>errorinfo</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current errorinfo value. If <option>value</option>
is specified, it sets a new value for errorinfo.
</para>
<para>
If an error occurred during the SQL query, DIO
attempts to set the value of <option>errorinfo</option> to the
resulting error message.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>fields</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current fields value. If
<option>value</option> is specified, it sets a new
value for fields.
</para>
<para>
<option>fields</option> contains the list of fields
used in this query. The fields are in order of the
fields retrieved for each row.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>forall</arg>
<arg><replaceable>-type</replaceable></arg>
<arg><replaceable>varName</replaceable></arg>
<arg><replaceable>body</replaceable></arg>
</cmdsynopsis>
<para>
Execute <option>body</option> over each record in the
result object.
</para>
<para>Types:</para>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-array</arg>
</cmdsynopsis>
<para>
Create
<option><replaceable>varName</replaceable></option>
as an array where the indexes are the names of
the fields in the table and the values are the
values of the current row.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-keyvalue</arg>
</cmdsynopsis>
<para>
Set
<option><replaceable>varName</replaceable></option>
to a list containing key-value pairs of fields
and values from the current row. (-field value
-field value)
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-list</arg>
</cmdsynopsis>
<para>
Set
<option><replaceable>varName</replaceable></option>
to a list that contains the values of the
current row.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>next</arg>
<arg><replaceable>-type</replaceable></arg>
<arg choice="opt"><replaceable>varName</replaceable></arg>
</cmdsynopsis>
<para>
Retrieve the next record in the result object.
</para>
<para>Types:</para>
<variablelist>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-array</arg>
</cmdsynopsis>
<para>
Create
<option><replaceable>varName</replaceable></option>
as an array where the indexes are the names of
the fields in the table and the values are the
values of the current row.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-dict</arg>
</cmdsynopsis>
<para>
Set <option><replaceable>varName</replaceable></option>
to a list containing ordinary key-value pairs of fields
and values from the current row. This form is naturally
intepreted as dictionary where each key corresponds
to a column.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-keyvalue</arg>
</cmdsynopsis>
<para>
Set
<option><replaceable>varName</replaceable></option>
to a list containing key-value pairs of fields
and values from the current row (-field value
-field value). This form is handy to build query
arguments for the <command>search</command> method
of a DIO object
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain">-list</arg>
</cmdsynopsis>
<para>
Set
<option><replaceable>varName</replaceable></option>
to a list that contains the values of the
current row.
</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>numrows</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current numrows value. If <option>value</option> is
specified, it sets a new value for numrows.
</para>
<para>
<option>numrows</option> is the number of rows in this result.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>resultid</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current resultid value. If <option>value</option> is
specified, it sets a new value for resultid.
</para>
<para>
<option>resultid</option> in most databases is the result
pointer which was given us by the database. This
variable is not generic and should not really be used,
but it's there if you want it.
</para>
</listitem>
</varlistentry>
<varlistentry>
<listitem>
<cmdsynopsis>
<arg choice="plain"><replaceable>resultObj</replaceable></arg>
<arg>rowid</arg>
<arg choice="opt"><replaceable>value</replaceable></arg>
</cmdsynopsis>
<para>
Return the current rowid value. If <option>value</option> is
specified, it sets a new value for rowid.
</para>
<para>
<option>rowid</option> contains the number of the
current result record in the result object. This
variable should not really be accessed outside of the
result object, but it's there if you want it.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
</refentry>
</section>
|