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
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<sect1 id="isql" >
<title>Interactive SQL Utility</title>
<para>ISQL/ISQLO/ISQLU/isql-iodbc/isql-udbc</para>
<para>
The Virtuoso ISQL utility allows users to execute queries & scripts against
the Virtuoso or other SQL servers (depending on the suffix).
It also supports a large number of options and it's own commands.
</para>
<para>
ISQL parses it's input for CREATE (PROCEDURE|TRIGGER|FUNCTION), '{', '}', ';',
double and single quotes and comments to detect where the current command starts and finishes.
If it's in a PROCEDURE|TRIGGER|FUNCTION declaration it changes it's command line prompt to
'<procedure_name>(<curly_brace_nesting_level>)' to help the user enter the correct command.
Otherwise it considers semicolon (;) as the statement end and executes the statement.
</para>
<para>
ISQL also has a form of script language by itself.
</para>
<sect2 id="invokingisql">
<title>Invoking ISQL</title>
<para>
ISQL is invoked from the command line of the operating system. It is a text-mode application with support
of readline library (where available).
</para>
<para>
Specify the --help or the -? option to view the usage:
</para>
<programlisting><![CDATA[
bash$ ./bin/isql --help
OpenLink Interactive SQL (Virtuoso), version 0.9849b.
Usage :
isql <HOST>[:<PORT>] <UID> <PWD> file1 file2 ...
isql -H <server_IP> [-S <server_port>] [-U <UID>] [-P <PWD>]
[-E] [-X <pkcs12_file>] [-K]
[-u <name>=<val>]* [-i <param1> <param2>]
isql -?
Connection options:
-? - This help message
-U username - Specifies the login user ID
-P password - Specifies the login password
-H server_addr - Specifies the Server address (IP)
-S server port - Specifies the TCP port to connect to
-E - Specifies that encryption will be used.
If no PK is specified, then anonymous connection is established.
-C - Specifies that password will be sent in cleartext
-X pkcs12_file - Specifies that encryption & X509 certificates will
be used i.e the client PK <pksc12 file>
-T server_cert - Specifies the CA certificate(s) file to be used i.e. the list
of trusted issuers: a PEM (base64) file of all the X509 certificates
of the Certification Authorities (CA) which the client will use for
verifying the server's certificate. This is used on client side to
verify the server certificate.
-b size - Specifies the size of the command buffer to be used (in KBytes)
-K - Shuts down the virtuoso on connecting to it
Parameter passing options:
-u name1=val1... - Everything after -u is stored to associative array U,
until -i is encountered. If no equal sign then value
is NULL
-i - Ignore everything after the -i option, after which
comes arbitrary input parameter(s) for isql procedure,
which can be referenced with $ARGV[$I] by the
ISQL-commands.
<OPT>=<value> - Sets the ISQL options
Note that if none of the above matches then the non-options go as
<HOST>[:<PORT>] <UID> <PWD> file1 file2 ...
]]></programlisting>
<para>
If the command line option is not one of the above it is considered a "non-option" parameter.
If the non-option parameter contains the equal sign ('=') then it's considered an ISQL option value assignment.
For example 'MAXROWS=10' limits the number of rows returned for a resultset to 10 instead of the default 0.
</para>
<para>
Otherwise ISQL treats the "non-option" parameters (identified by their position) as follows :
</para>
<simplelist>
<member>Position 1 - <Host> or <port> or <Host:port> (native), DSN (ISQLO/ISQLU/isql-iodbc/isql-udbc)</member>
<member>Position 2 - <user_id></member>
<member>Position 3 - <password></member>
<member>Position 4 and later - script file name to load</member>
</simplelist>
<para>
Let us consider the following command line:
</para>
<programlisting>
isql 1111 dba dba VERBOSE=OFF 'EXEC=status()' test.sql test2.sql -i arg1 arg2
</programlisting>
<para>
The '1111' is the first "non-option", so it represents the connection host:port (This is all digits
so the virtuoso CLI prepends this with 'localhost', i.e. this is an shortcut for 'localhost:1111').
</para>
<para>
The first 'dba' is the second "non-option", so it is used as User ID.
</para>
<para>
The second 'dba' is the third "non-option", so it is used as Password.
</para>
<para>
'VERBOSE=OFF' is a "non-option", but it has an equal sign in it, so this becomes an ISQL option SET statement.
In this particular case this disables the output of "Done xxx msec" messages after each command.
</para>
<para>
'EXEC=status()' is a "non-option", but again has again an equal sign in it. EXEC is a special option.
Setting it to a value means executing that value as an SQL command. The result of this is that
status() gets executed and it's results shown.
</para>
<para>
'test.sql' is the fourth "non-option" and it specifies a file name to load a script from and execute.
</para>
<para>
'test2.sql' is the fifth "non-option" and it again specifies a file name to load a script from and execute.
</para>
<para>
'-i' specifies that the script argument list starts. So every option after the -i is filled in the ISQL $ARGV[] array.
</para>
<para>
The order of execution is:
</para>
<para>
<orderedlist>
<listitem>Connect to 'localhost:1111' using UserID/Password dba/dba.</listitem>
<listitem>Set the VERBOSE ISQL flag to OFF.</listitem>
<listitem>Set the $ARGV[0]=arg1 and $ARGV[1]=arg2.</listitem>
<listitem>Execute status() and display the results.</listitem>
<listitem>Execute the script in test.sql and display the results.</listitem>
<listitem>Execute the script in test2.sql and display the results.</listitem>
<listitem>Disconnect and exit the ISQL</listitem>
</orderedlist>
</para>
</sect2>
<sect2 id="isqlcommands">
<title>ISQL Commands</title>
<programlisting>
<SQL_command> &
</programlisting>
<para>
Spawns a new copy of ISQL as a background OS process to execute the command.
The new copy will make its own connection and will terminate after the
command completes. The isql instance which received the command prompts
for the next command without waiting for the spawned isql instance
</para>
<programlisting>
! <command> (;|&)
</programlisting>
<para>
Executes an OS command
</para>
<programlisting>
SET <ISQL_OPTION>( |=)<VALUE>
</programlisting>
<para>
sets the ISQL variable or associative array U value, if it is recognized as
such. Otherwise passed to the server.
</para>
<example><title>Examples</title>
<programlisting>
SET U{test} 5; sets the associative array U's 'test' to have value of 5
</programlisting>
</example>
<programlisting>
SHOW [<ISQL_OPTION>]
</programlisting>
<para>
shows the value of an ISQL option, if it is recognized as such. Otherwise passed to the server.
</para>
<programlisting>
NOP
</programlisting>
<para>
no-operation. Useful sometimes in an $IF command.
</para>
<programlisting>
(ECHO|ECHOLN) [STDOUT|STDERR|ERROR_STREAM|BOTH] string1 string2 ...
</programlisting>
<para>
echoes it's arguments into the specifies output stream (defaults to STDOUT if not specified)
If ECHOLN is used it appends a new line after the last character printed.
</para>
<programlisting>
WAIT_FOR_CHILDREN
</programlisting>
<para>
Waits for background ISQL subcommands spawned by specifying an & instead of ; at the end of the statement.
</para>
<programlisting>
LOAD <file_name>
</programlisting>
<para>
Executes each statement of the specified file. Statements end in a
semicolon or at the closing curly brace for procedure or trigger definitions.
</para>
<programlisting>
HELP [<isql-command>]
</programlisting>
<para>
Prints general or command specific help texts.
</para>
<programlisting>
(EXIT|QUIT) [NOT]
</programlisting>
<para>
Exits ISQL
</para>
<para>
EXIT NOT is a NO-OP, allowing statements like:
EXIT $IF $EQU $ARGV[0] 10 $ARGV[0] NOT;
which exits with exit code 10 if $ARGV[0] is ten
(presumably keeping a some-kind of failure counter)
but otherwise does nothing special, and continues
from the next statement.
</para>
<programlisting>
SLEEP [<seconds>]
</programlisting>
<para>
sleeps for the specified number of seconds or until an OS signal arrives.
If seconds is not specified it's considered 0 and the behavior is OS dependent
(the OS sleep function on Unixes, Sleep() in the Windows API).
</para>
<programlisting>
CONNECT [<conn_str>]
</programlisting>
<para>
Without arguments forces the connection to be made with an ordinary
way with SQLConnect and so-far specified connection details.
With an argument uses SQLDriverConnect, giving that argument as
a connection string (e.g. "DSN=Virtuoso;UID=DBA,PWD=DBA")
If we are already connected, then is just NO-OP which is silently
ignored.
</para>
<programlisting>
TableQualifiers
</programlisting>
<para>Returns all defined table qualifiers.
</para>
<programlisting>
TableOwners
</programlisting>
<para>
Returns existing table owners list.
</para>
<programlisting>
TableTypes
</programlisting>
<para>
Returns list of current table types.
</para>
<programlisting>
RECONNECT [<User_ID>]
</programlisting>
<para>
If the ISQL is already connected then disconnects.
After that it tries connecting to the same data source, but with
using its argument as a user name. If none specified it gets
the user name/password from the UID and PWD ISQL variables.
</para>
<programlisting>
FOREACH [LINE|INTEGER|BLOB|TIMESTAMP|DATE|TIME]
[FOLLOWING|IN (-|-b|<file_name>)|BETWEEN <n1> <n2>]
<statement_with_params> <statement_with_params> ... [END]
</programlisting>
<para>
This command executes the <statement_with_params> in a loop, after binding the parameters specified in it to
values specified in the command.
</para>
<para>
Parameters are specified as follows :
</para>
<simplelist>
<member>? - an ordinary parameter bound to the foreach value</member>
<member>?C - the count of successful operations</member>
</simplelist>
<simplelist>
<member>LINE processes the input line by line</member>
<member>INTEGER converts the input into integer and then processes it.</member>
<member>BLOB reads the entire input and sets it as an blob parameter using SQLPutData</member>
<member>TIMESTAMP is the same as LINE, bit binds to a TIMESTAMP SQL Type</member>
<member>DATE is the same as LINE, but binds to a DATE SQL Type</member>
<member>TIME is the same as LINE, bit binds to a TIME SQL Type</member>
</simplelist>
<simplelist>
<member>IN specifies a set of items terminated by an END</member>
<member>BETWEEN specifies integer set starting from n1 and ending on n2</member>
<member>FOLLOWING as as IN but skips the input till the END keyword</member>
</simplelist>
<example><title>Examples:</title>
<programlisting>
foreach integer between 1 10 insert into num_tb values (?);
</programlisting>
<para>Inserts 10 rows from 1 to 10 into the num_tb</para>
<programlisting>
foreach line in my_text_file.txt insert into str_tb (line_no, data) values (?C, ?);
</programlisting>
<para>
Inserts each line of the text file my_text_file.txt into str_tb's
data column and puts line number in line_no column
</para>
<programlisting>
foreach blob in my_text_file.txt insert into file_tb values (?);
</programlisting>
<para>
inserts a row into the file_tb with the contents of the my_text_file.txt
as a single blob value.
</para>
</example>
<programlisting>
SHUTDOWN
</programlisting>
<para>
Passes this through to the server as a command
</para>
<programlisting>
CALL <SQL statement>
</programlisting>
<para>
Tries to bind & print the SQL_RETURN_VALUE and display multiple resultsets (if any) after executing the statement.
</para>
<programlisting>
COLUMNS [<table_mask>][/<column_mask>]
</programlisting>
<para>
Calls SQLColumns ODBC
</para>
<programlisting>
TABLES [<table_mask>]
</programlisting>
<para>
Calls SQLTables ODBC
</para>
<programlisting>
PRIMARYKEYS [<table_mask>]
</programlisting>
<para>
Calls SQLPrimaryKeys ODBC
</para>
<programlisting>
COLUMNPRIVILEGES [<table_mask>]/[<procedure_column_mask>]
</programlisting>
<para>
Calls SQLColumnPrivileges ODBC
</para>
<programlisting>
PROCEDURES [<procedure_mask>]
</programlisting>
<para>
Calls SQLProcedures ODBC
</para>
<programlisting>
PROCEDURECOLUMNS [<procedure_mask>]/[<procedure_column_mask>]
</programlisting>
<para>
Calls SQLProcedureColumns ODBC
</para>
<programlisting>
TABLEPRIVILEGES [<table_mask>]
</programlisting>
<para>
Calls SQLTablePrivileges ODBC
</para>
<programlisting>
GETTYPEINFO
</programlisting>
<para>
Calls SQLGetTypeInfo (SQL_ALL_TYPES) ODBC
</para>
<programlisting>
STATISTICS [<table_mask>] [/U]
</programlisting>
<para>
Calls SQLStatistics ODBC. U means show only unique indexes otherwise all
</para>
<programlisting>
SPECIALCOLUMNS [<table_mask>] [/(B?S?T?N?)]
</programlisting>
<para>
Calls SQLSpecialColumns ODBC.
</para>
<simplelist>
<member>B means BEST_ROWID, otherwise ROWVER.</member>
<member>S means Session scope, T means transaction scope, otherwise current row.</member>
<member>N means No Nulls, otherwise Nullable.</member>
</simplelist>
</sect2>
<sect2 id="isqlmacrodef">
<title>ISQL Macro Substitution</title>
<para>
Before executing commands ISQL expands macros in statement text.
The following macros and macro related commands are available:
</para>
<simplelist>
<member>$LOADEXPR - the current script startup command</member>
<member>$LINENO - the current line number</member>
<member>$YYYYMMDD - the current date in the same format</member>
<member>$HHMMSS - the current time in the same format</member>
</simplelist>
<programlisting>
$IF <cond> <THEN_RESULT> [<ELSE_RESULT>]
</programlisting>
<para>
If the condition evaluates to non-empty and is not the literal 0 the value of the $IF
is the <THEN_RESULT> else the <ELSE_RESULT>.
</para>
<programlisting>
$(+|-) <arg1> <arg2>
</programlisting>
<para>
result is the addition or substitution of the arg1 and arg2
</para>
<programlisting>
$LAST[<n>]
</programlisting>
<para>
an array of the last resultset row
</para>
<programlisting>
$ARGV[<n>]
</programlisting>
<para>
an array of the command line arguments
</para>
<programlisting>
$U[<name>]
</programlisting>
<para>
prints the user associative array U value for the name <name>
</para>
<programlisting>
$<ISQL_Variable>
</programlisting>
<para>
returns the value of that variable
</para>
<programlisting>
$LT <v1> <v2>
</programlisting>
<para>
returns 1 if the <v1> is lower that <v2>, empty otherwise
</para>
<programlisting>
$GT <v1> <v2>
</programlisting>
<para>
returns 1 if the <v1> is greater than <v2>, empty otherwise
</para>
<programlisting>
$GTE <v1> <v2>
</programlisting>
<para>
returns 1 if the <v1> is greater or equal than <v2>, empty otherwise
</para>
<programlisting>
$LTE <v1> <v2>
</programlisting>
<para>
returns 1 if the <v1> is lower or equal than <v2>, empty otherwise
</para>
<programlisting>
$EQU <v1> <v2>
</programlisting>
<para>
returns 1 if the <v1> is equal to <v2>, empty otherwise
</para>
<programlisting>
$NEQ <v1> <v2>
</programlisting>
<para>
returns 1 if the <v1> is not equal to <v2>, empty otherwise
</para>
<example><title>Examples:</title>
<programlisting>
ECHO $IF $EQU 1 2 "True" "False";
</programlisting>
<para>prints "False" to the standard output</para>
<programlisting>
EXIT $IF $NEQ 1 2 NOT;
</programlisting>
<para>never exits</para>
<programlisting>
ECHO $IF $EQU $ARGV[1] 1 "One" $IF $EQU $ARGV[1] "Two" "Unknown;
</programlisting>
<para>prints the "one" on 1 as arg 1, "two" on 2 as arg 1 otherwise "Unknown"</para>
</example>
</sect2>
<sect2 id="isqlvariables">
<title>ISQL Variables</title>
<para>
These variables are sometimes set as a side effect of executing statements, e.g. rowcnt
and sometimes should be explicitly set by the user to control the operation of isql, e.g. maxrows.
</para><para>
The variable names are case insensitive. Like in UNIX shells, the variable name
in an expression must be prefixed by a $ to return its value.
Variables do not have an explicit data type. Like Unix shell variables they have string
values which are sometimes interpreted as numbers and sometimes as booleans.
Generally an on/off choice is represented by the values ON/OFF. The ON/OFF values are case insensitive.
</para>
<example><title>Example:</title>
<programlisting>
SQL> SET AUTOCOMMIT ON;
SQL> echo $autocommit;
ON
SQL> set U{var} foo;
SQL> echo $u{VAR};
foo
</programlisting>
<para>
Note that the $u{<var>} notation is a general purpose text substitution macro
without arguments. The expansion takes place regardless of SQL syntactic context.
</para>
</example>
<example><title>Example:</title>
<programlisting>
set u{table} SYS_KEYS;
select count (*) from $u{table};
</programlisting>
</example>
<sect3 id="varref">
<title>Variable Reference</title>
<programlisting>
RETVAL
</programlisting>
<para>
Function called return value
</para>
<programlisting>
RETVALLEN
</programlisting>
<para>
Function called return value length
</para>
<programlisting>
ROWCNT
</programlisting>
<para>
Number of rows in the last result set. If the statement was an insert, update or delete this is the number of rows affected.
</para>
<programlisting>
COLCNT
</programlisting>
<para>
Number of columns in the last resultset
</para>
<programlisting>
ARGC
</programlisting>
<para>
Number of ISQL command line arguments
</para>
<programlisting>
I
</programlisting>
<para>
Number of script arguments (after -i)
</para>
<programlisting>
LIF
</programlisting>
<para>
Result of the last $IF
</para>
<programlisting>
INPUTLINE
</programlisting>
<para>
Current executed line
</para>
<programlisting>
STATE
</programlisting>
<para>
SQL State (defaults to OK)
</para>
<programlisting>
SQLSTATE
</programlisting>
<para>
Same as state.
</para>
<programlisting>
MESSAGE
</programlisting>
<para>
the SQL error message from the last operation.
</para>
<programlisting>
DRIVER
</programlisting>
<para>
The Driver name
</para>
<programlisting>
LWE
</programlisting>
<para>
Last ECHO output
</para>
<programlisting>
DSN
</programlisting>
<para>
The DSN or host address used/to be used in connecting to the server.
Use this with uid and pwd before the connect or reconnect command to change the connected server.
This is useful for scripts which access multiple servers.
</para>
<programlisting>
UID
</programlisting>
<para>
The User ID used/to be used in connecting to the server
</para>
<programlisting>
PWD
</programlisting>
<para>
The Password used/to be used in connecting to the server
</para>
<programlisting>
ERRORS
</programlisting>
<para>
The current stream for errors (STDIN, STDOUT, STDERR or a file name)
</para>
<programlisting>
PROMPT
</programlisting>
<para>
Prints the PROMPT or not
</para>
<programlisting>
EMPTY
</programlisting>
<para>
The current empty string value
</para>
<programlisting>
VERSION
</programlisting>
<para>
ISQL version
</para>
<programlisting>
BLOBS
</programlisting>
<para>
When ON binds prints the BLOB resultset values when printing the resultset. Otherwise prints 'BLOB x chars'
</para>
<programlisting>
ECHO
</programlisting>
<para>
When ON prints the commands to the standard output before executing
</para>
<programlisting>
BANNER
</programlisting>
<para>
When ON prints the column names & types banner when printing the resultset
</para>
<programlisting>
TYPES
</programlisting>
<para>
When ON prints the Type information in the resultset's banner
</para>
<programlisting>
VERBOSE
</programlisting>
<para>
When ON Prints the Timing row after the resultset output
</para>
<programlisting>
TIMESTOSTRINGS
</programlisting>
<para>
When ON binds the SQL_DATE, SQL_TIME & SQL_TIMESTAMP columns to strings
</para>
<programlisting>
TRAILING_NEWLINES
</programlisting>
<para>
When ON prints new line after the row's end
</para>
<programlisting>
DEADLOCK_RETRIES
</programlisting>
<para>
How many times to retry the statement if deadlock occurred
</para>
<programlisting>
MACRO_SUBSTITUTION
</programlisting>
<para>
When ON ISQL does understand & process $ macros
</para>
<programlisting>
IGNORE_PARAMS
</programlisting>
<para>
When ON passes the ? through to the server instead of returning an error for unbound ?
</para>
<programlisting>
BIND_RETURN_VALUES
</programlisting>
<para>
When ON binds a buffer to SQL_RETURN_VALUE
</para>
<programlisting>
AUTOCOMMIT
</programlisting>
<para>
When ON ISQL executes statements in autocommit mode. By default isql executes statements in
manual commit mode, following each execution with a SQLTransact call to commit.
The difference is not visible most of the time.
</para>
<programlisting>
ACCESSMODE
</programlisting>
<para>
Sets the ODBC access mode (RW, RO)
</para>
<programlisting>
TIMEOUT
</programlisting>
<para>
ODBC Query timeout
</para>
<programlisting>
MAXROWS
</programlisting>
<para>
Print only the first so many rows. If 0 - unlimited.
</para>
<programlisting>
CURRENT_QUALIFIER
</programlisting>
<para>
Prints the current ODBC SQLGetInfo client Qualifier
</para>
<programlisting>
INFO_DATABASE_NAME
</programlisting>
<para>
Prints the current ODBC SQLGetInfo Database name
</para>
<programlisting>
INFO_USER_NAME
</programlisting>
<para>
Prints the current ODBC SQLGetInfo user name
</para>
<programlisting>
INFO_GETDATA_EXTENSTIONS
</programlisting>
<para>
Prints the current ODBC SQLGetInfo SQLGetData extensions flag
</para>
<programlisting>
COMMAND_TEXT_ON_ERROR
</programlisting>
<para>
When OFF ISQL does not print the text of the command in the error messages
</para>
</sect3>
</sect2>
<sect2 id="isqlgentesttool">
<title>Using isql as a General Purpose Test Driver</title>
<para>
isql can be used to automatically run SQL scripts which execute statements, perform
simple tests on the results and generate a report. This can be used to automate tests of stored
procedures or to benchmark them.
</para>
<para>
Also note the use of & at the end of a command to spawn multiple isql instances
on the background. This is useful for automatically creating concurrency situations for testing.
</para>
<para>
Consider the script:
</para>
<programlisting>
drop table tt;
create table tt (id int identity not null primary key, ctr int);
create procedure tt_fill (in n int)
{
declare ctr int;
ctr := 0;
while (ctr < n){
insert into tt (ctr) values (ctr);
ctr := ctr + 1;
}
}
tt_fill (10000) &
tt_fill (10000) &
tt_fill (10000) &
tt_fill (10000) &
wait_for_children;
select count (*), count (distinct ctr) from tt;
echo both $if $equ $last[1] 40000 "PASSED" "***FAILED";
echo both " Inserted " $last[1] " rows\n";
echo both $if $equ $last[2] 10000 "PASSED" "***FAILED";
echo both " Inserted " $last[2] " distinct ctr values\n";
</programlisting>
<para>
Now suppose the above text were in the file test.sql.
The command
</para>
<programlisting>
isql 1111 errors=stdout <test.sql >test.out
</programlisting>
<para>
would print the diagnostics to the standard error and the full trace to
test.out. Note the errors=stdout would
direct the error message for no table in the initial drop table to the text.out file,
so the console would just print:
</para>
<programlisting>
PASSED Inserted 40000 rows
PASSED Inserted 10000 distinct ctr values
</programlisting>
</sect2>
</sect1>
|