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 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565
|
<HTML>
<HEAD>
<TITLE></TITLE>
<LINK REL="ToC" HREF="httoc.htm">
<LINK REL="Index" HREF="htindex.htm">
<LINK REL="Next" HREF="aguide14.htm">
<LINK REL="Previous" HREF="aguide12.htm"></HEAD>
<BODY BGCOLOR="#FFFFFF">
<P ALIGN=CENTER>
<A HREF="aguide12.htm" TARGET="_self"><IMG SRC="gaguide/graprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="httoc.htm" TARGET="_self"><IMG SRC="gaguide/gratop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="htindex.htm" TARGET="_self"><IMG SRC="gaguide/graindex.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Index"></A>
<A HREF="aguide14.htm" TARGET="_self"><IMG SRC="gaguide/granext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
<A NAME="E9E13"></A>
<H1>
<FONT FACE="Arial"><B>APPENDIX D SOLID SQL SYNTAX</B></FONT></H1>
<BR>
<BLOCKQUOTE>
<P>The SOLID <I>Server</I> SQL syntax is based on the ANSI X3.135-1989 level 2 standard including important ANSI X3.135-1992 (SQL2) extensions. User and role management services missing from previous standards are based on the ANSI SQL3 draft.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>This appendix presents a simplified description of the SQL statements including some examples. The same information is included in the<B> SOLID </B><B><I>Server</I></B><B> Programmer's Guide</B> <B>and Reference.</B>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The description syntax uses these conversions:
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>SQL keywords appear in all UPPERCASE letters
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>syntax elements are specified in lowercase
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>syntax elements specified in <I>lowercase italics</I> are explained in the end of this appendix
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>the notation ... indicates that elements can be repeated
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>vertical bars | indicates a choice between two or more alternative syntax elements
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>square brackets [ ] indicate an optional syntax element
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>braces { } indicate a choice among required syntax elements
</BLOCKQUOTE></UL>
<A NAME="E10E70"></A>
<P>
<FONT FACE="Arial"><B>ADMIN COMMAND</B></FONT>
<BLOCKQUOTE>
<PRE>ADMIN COMMAND 'command-name'
<BR>command-name ::= EXIT | HELP | SHUTDOWN | OPEN |
<BR> CLOSE | THROWOUT | USERLIST | MAKECP | BACKUP |
<BR> BACKUPLIST | STATUS | REPORT | MESSAGES |
<BR> MONITOR | VERSION | ERRORCODE | HOTSTANDBY</PRE></BLOCKQUOTE>
<H4> Usage</H4>
<BLOCKQUOTE>
<P>This SQL extension executes administrator commands. Syntax for the extension is
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>ADMIN COMMAND 'command-name'</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>where command-name is a SOLID <I>Remote Control</I> (Teletype) command string. The result set contains two columns: RC INTEGER and TEXT VARCHAR(254). Integer column RC is a command return code (0 if success), varchar column TEXT is the command reply. The TEXT field contains same lines that a displayed on SOLID <I>Remote Control</I> (Teletype) screen, one line per one result row.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>ADMIN COMMAND 'USERLIST';</PRE></BLOCKQUOTE>
<A NAME="E10E71"></A>
<P>
<FONT FACE="Arial"><B>ALTER TABLE</B></FONT>
<BLOCKQUOTE>
<PRE>ALTER TABLE base-table-name
<BR> {ADD [COLUMN] column-identifier <I>data-type</I> |
<BR> DROP [COLUMN] column-identifier |
<BR> RENAME [COLUMN]
<BR> column-identifier column-identifier |
<BR> MODIFY [COLUMN]
<BR> column-identifier <I>data-type</I>} |
<BR> MODIFY SCHEMA schema-name |
<BR> SET {OPTIMISTIC | PESSIMISTIC}</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The structure of a table may be modified through the ALTER TABLE statement. Within the context of this statement, columns may be added, modified, or removed.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The owner of a table can be changed using the
<BR>ALTER TABLE base-table-name MODIFY SCHEMA schema-name statement. This statement gives all rights to the new owner of the table including creator rights. The old owner’s access rights to the table, excluding the creator rights, are preserved.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Individual tables can be set to optimistic or pessimistic with the command
<BR>ALTER TABLE base-table-name SET {OPTIMISTIC | PESSIMISTIC}. By default, all tables are optimistic. A database-wide default can be set in the General section of the configuration file with the parameter Pessimistic = yes.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>If transaction early validate is used, update and delete operations use locks for the early validation. Read operations do not lock, but update and delete operations lock the updated or deleted row.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>ALTER TABLE TEST ADD X INTEGER;
ALTER TABLE TEST RENAME COLUMN X Y;
ALTER TABLE TEST MODIFY COLUMN X SMALLINT;
ALTER TABLE TEST DROP COLUMN X;</PRE></BLOCKQUOTE>
<A NAME="E10E72"></A>
<P>
<FONT FACE="Arial"><B>ALTER USER</B></FONT>
<BLOCKQUOTE>
<PRE>ALTER USER user-name IDENTIFIED BY password</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The password of a user may be modified through the ALTER USER statement.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>ALTER USER MANAGER IDENTIFIED BY O2CPTG;</PRE></BLOCKQUOTE>
<A NAME="E10E73"></A>
<P>
<FONT FACE="Arial"><B>CALL</B></FONT>
<BLOCKQUOTE>
<PRE>CALL procedure-name [parameter ...]</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Stored procedures are called with statement CALL.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CALL proctest;</PRE></BLOCKQUOTE>
<A NAME="E10E74"></A>
<P>
<FONT FACE="Arial"><B>COMMIT</B></FONT>
<BLOCKQUOTE>
<PRE>COMMIT WORK</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The changes made in the database are made permanent by COMMIT statement. It terminates the transaction.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>COMMIT WORK;</PRE></BLOCKQUOTE>
<A NAME="E10E75"></A>
<P>
<FONT FACE="Arial"><B>CREATE EVENT</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE EVENT event-name
<BR> [(parameter-definition
<BR> [, parameter-definition ...])]</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Event alerts are used to signal an event in the database. Events are simple objects with a name. The use of event alerts removes resource consuming database polling from applications.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>An event object is created with the SQL statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>CREATE EVENT event-name [parameter-list]
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The name can be any user-specified alphanumeric string. The parameter list specifies parameter names and parameter types. The parameter types are normal SQL types.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Events are dropped with the SQL statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>DROP EVENT event-name
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Events are triggered and received inside stored procedures. Special stored procedure statements are used to trigger and receive events.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The event is triggered with the stored procedure statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>POST EVENT event-name [parameters]
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Event parameters must be local variables or parameters in the stored procedure where the event is triggered. All clients that are waiting for the posted event will receive the event.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>To make a procedure wait for an event to happen, the WAIT EVENT construct is used in a stored procedure:
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>wait-event-statement ::=
<BR> WAIT EVENT
<BR> [event-specification ...]
<BR> END WAIT
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>event-specification ::=
<BR> WHEN event-name (parameters) BEGIN
<BR> statements
<BR> END EVENT
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Example of a procedure that waits for an event:
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>create procedure "event-wait(i1 integer)
<BR>returns (result varchar)
<BR>begin
<BR>declare i integer;
<BR>declare c char(4);
<BR>
<BR>i := 0;
<BR>
<BR>wait event
<BR> when test1 begin
<BR> result := 'event1';
<BR> return;
<BR> end event
<BR>
<BR> when test2(i) begin
<BR> end event
<BR>
<BR> when test3(i, c) begin
<BR> end event
<BR>end wait
<BR>
<BR>if i <> 0 then
<BR> result := 'if';
<BR> post event test1;
<BR>else
<BR> result := 'else';
<BR> post event test2(i);
<BR> post event test3(i, c);
<BR>end if
<BR>end";
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The creator of an event or the database administrator can grant and revoke access rights. Access rights can be granted to users and roles. The select access right gives waiting access to an event. The insert access right gives triggering access to an event.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CREATE EVENT ALERT1(I INTEGER, C CHAR(4));</PRE></BLOCKQUOTE>
<A NAME="E10E76"></A>
<P>
<FONT FACE="Arial"><B>CREATE INDEX</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE [UNIQUE] INDEX index-name
<BR> ON base-table-name
<BR> (column-identifier [ASC | DESC]
<BR> [, column-identifier [ASC | DESC]] ...)</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Creates an index for a table based on the given columns. Keyword UNIQUE specifies that columns being indexed must contain unique values. Keywords ASC and DESC specify whether the given columns should be indexed in ascending or descending order. If not specified ascending order is used.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CREATE UNIQUE INDEX UX_TEST ON TEST (I);
CREATE INDEX X_TEST ON TEST (I, J);</PRE></BLOCKQUOTE>
<A NAME="E10E77"></A>
<P>
<FONT FACE="Arial"><B>CREATE PROCEDURE</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE PROCEDURE procedure-name
<BR> [(parameter-definition
<BR> [, parameter-definition ...])]
<BR> [RETURNS (parameter-definition
<BR> [, parameter-definition ...])]
<BR> BEGIN procedure-body END;
parameter-definition ::= parameter-name data-type
procedure-body ::= [declare-statement; ...]
<BR> procedure-statement; [procedure-statement; ...]
declare-statement ::= DECLARE variable-name
<BR> data-type
procedure-statement ::= prepare-statement |
<BR> exec-statement | fetch-statement |
<BR> control-statement | post-statement |
<BR> wait-event-statement
prepare-statement ::= EXEC SQL PREPARE
<BR> cursor-name sql-statement
execute-statement ::=
<BR> EXEC SQL EXECUTE
<BR> cursor-name
<BR> [USING (variable [, variable ...])]
<BR> [INTO (variable [, variable ...])] |
<BR> EXEC SQL {COMMIT | ROLLBACK} WORK |
<BR> EXEC SQL SET TRANSACTION {READ ONLY | READ WRITE} |
<BR> EXEC SQL WHENEVER SQLERROR [ROLLBACK [WORK],] ABORT |
<BR> EXEC SEQUENCE sequence-name.CURRENT INTO variable |
<BR> EXEC SEQUENCE sequence-name.NEXT INTO variable |
<BR> EXEC SEQUENCE sequence-name SET VALUE USING variable
fetch-statement ::= EXEC SQL FETCH cursor-name
post-statement ::= POST EVENT event-name [parameters]
wait-event-statement ::=
<BR> WAIT EVENT
<BR> [event-specification ...]
<BR> END WAIT
event-specification ::=
<BR> WHEN event-name (parameters) BEGIN
<BR> statements
<BR> END EVENT
control-statement ::=
<BR> SET variable-name = value |
<BR> variable-name := value |
<BR> WHILE expression
<BR> LOOP procedure-statement... END LOOP |
<BR> LEAVE |
<BR> IF expression THEN procedure-statement ...
<BR> [ ELSEIF procedure-statement ... THEN] ...
<BR> ELSE procedure-statement ... END IF |
<BR> RETURN | RETURN SQLERROR OF cursor-name | RETURN ROW</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Stored procedures are simple programs, or procedures, that are executed in the server. The user can create a procedure that contains several SQL statements or a whole transaction and execute it with a single call statement. Usage of stored procedures reduces network traffic and allows more strict control to access rights and database operations.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Procedures are created with the statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>CREATE PROCEDURE name body
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>and dropped with the statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>DROP PROCEDURE name
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Procedures are called with the statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>CALL name [parameter ...]
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Procedures can take several input parameters and return a single row or several rows as a result. The result is built from specified output parameters. Procedures are thus used in ODBC in the same way as the SQL SELECT statement.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Procedures are owned by the creator of the procedure. Specified access rights can be granted to other users. When the procedure is run, it has the creator's access rights to database objects.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The stored procedure syntax is a proprietary syntax modeled from SQL3 specifications and dynamic SQL. Procedures contain control statements and SQL statements.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The following control statements are available in the procedures:
</BLOCKQUOTE>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=240 VALIGN=top >
<P><B>Control statement</B>
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E728"></A>
<P>Description</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>set <I>variable</I> = <I>expression</I>
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E729"></A>
<P>Assigns a value to a variable. The value can be either a literal value (e.g., 10 or 'text') or another variable. Parameters are considered as normal variables.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P><I>variable</I> := <I>expression</I>
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E730"></A>
<P>Alternate syntax for assigning values to variables.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>while
<BR> <I>expr</I>
<BR>loop
<BR> <I>statement-list</I>
<BR>end loop
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E731"></A>
<P>Loops while expression is true.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>leave
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E732"></A>
<P>Leaves the innermost while loop and continues executing the procedure from the next statement after the keyword end loop.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>if
<BR> <I>expr</I>
<BR>then
<BR> <I>statement-list1</I>
<BR>else
<BR> <I>statement-list2</I>
<BR>end if
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E733"></A>
<P>Executes <I>statements-list1</I> if expression <I>expr</I> is true,;otherwise, executes <I>statement-list2</I>.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>if
<BR> <I>expr1</I>
<BR>then
<BR> <I>statement-list1</I>
<BR>elseif
<BR> <I>expr2</I>
<BR>then
<BR> <I>statement-list2</I>
<BR>end if
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E734"></A>
<P>If <I>expr1</I> is true, executes <I>statement-list1</I>. If <I>expr2</I> is true, executes <I>statement-list2</I>. The statement can optionally contain multiple <I>elseif</I> statements and also an <I>else</I> statement.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>return
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E735"></A>
<P>Returns the current values of output parameters and exits the procedure. If a procedure has a one <I>return row</I> statement, <I>return</I> behaves like <I>return </I><I>norow</I>.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>return sqlerror of <I>cursor-name</I>
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E736"></A>
<P>Returns the sqlerror associated with the cursor and exits the procedure.</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>return row
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E737"></A>
<P>Returns the current values of output parameters and continues execution. (requires SOLID <I>Server</I> Version 2.2 or later)</TD>
</TR>
<TR>
<TD WIDTH=240 VALIGN=top >
<P>return norow
</TD><TD WIDTH=216 VALIGN=top >
<A NAME="E7E738"></A>
<P>Returns the end of the set and exits the procedure. (requires SOLID <I>Server</I> Version 2.2 or later)</TD></TR>
</TABLE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>All SQL DML and DDL statements can be used in procedures. Thus the procedure can, e.g., create tables or commit a transaction. Each SQL statement in the procedure is atomic.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Preparing SQL Statements</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The SQL statements are first prepared with the statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>EXEC SQL PREPARE <I>cursor</I> <I>sql-statement</I></PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>The <I>cursor</I> specification is a cursor name that must be given. It can be any unique cursor name inside the transaction. Note that if the procedure is not a complete transaction, other open cursors outside the procedure may have conflicting cursor names.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Executing Prepared SQL Statements</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The <I>SQL statement</I> is executed with the statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>EXEC SQL EXECUTE <I>cursor </I>[<I>opt-using </I>] [<I>opt-into </I>]</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>The optional <I>opt-using</I> specification has the syntax
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>USING (<I>variable-list</I>)</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>where <I>variable-list</I> contains a list of procedure variables or parameters separated by a comma. These variables are input parameters for the SQL statement. The SQL input parameters are marked with the standard question mark syntax in the prepare statement. If the SQL statement has no input parameters, the USING specification is ignored.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The optional <I>opt-into</I> specification has the syntax
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>INTO (<I>variable-list</I>)</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>where <I>variable-list</I> contains the variables that the column values of the SQL SELECT statement are stored into. The INTO specification is effective only for SQL SELECT statements.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Fetching Results</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Rows are fetched with the statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>EXEC SQL FETCH <I>cursor</I></PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>If the fetch completed successfully, the column values are stored into the variables defined in the <I>opt-into</I> specification.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Checking for Errors</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The result of each EXEC SQL statement executed inside a procedure body is stored into the variable SQLSUCCESS. This variable is automatically generated for every procedure. If the previous SQL statement was successful, a value one is stored into SQLSUCCESS. After a failed SQL statement, a value zero is stored into SQLSUCCESS.
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>EXEC SQL WHENEVER SQLERROR [ROLLBACK [WORK],] ABORT</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>is used to decrease the need for IF NOT SQLSUCCESS THEN tests after every executed SQL statement in a procedure. When this statement is included in a stored procedure all return values of executed statements are checked for errors. If statement execution returns an error, the procedure is automatically aborted. Optionally the transaction can be rolled back.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>This statement can be used with SOLID <I>Server</I> Version 2.2 or later.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Using Transactions</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>EXEC SQL {COMMIT | ROLLBACK} WORK</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>is used to terminate transactions.
</BLOCKQUOTE>
<BLOCKQUOTE>
<PRE>EXEC SQL SET TRANSACTION {READ ONLY | READ WRITE}</PRE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>is used to control the type of transactions.
</BLOCKQUOTE>
<BLOCKQUOTE>
<H4>
<FONT FACE="Arial"><B>Using Sequencer Objects and Event Alerts</B></FONT></H4>
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Refer to the usage of the CREATE SEQUENCE and CREATE EVENT statements.
</BLOCKQUOTE>
<H4>Example 1</H4>
<BLOCKQUOTE>
<PRE>create procedure "test2(tableid integer)
<BR> returns (cnt integer)
<BR>begin
<BR> exec sql prepare c1 select count(*) from
<BR> sys_tables where id > ?;
<BR> exec sql execute c1 using (tableid) into
<BR> (cnt);
<BR> exec sql fetch c1;
<BR>end";</PRE></BLOCKQUOTE>
<H4>Example 2</H4>
<BLOCKQUOTE>
<PRE>-- This procedure can only be used with SOLID Server -- version 2.2 or later.
create procedure "return_tables
<BR>returns (name varchar)
<BR>begin
<BR> exec sql whenever sqlerror rollback, abort;
<BR> exec sql prepare c1 select table_name
<BR> from sys_tables;
<BR> exec sql execute c1 into (name);
<BR> while sqlsuccess loop
<BR> exec sql fetch c1;
<BR> return row;
<BR> end loop;
<BR>end";</PRE></BLOCKQUOTE>
<A NAME="E10E78"></A>
<P>
<FONT FACE="Arial"><B>CREATE ROLE</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE ROLE role-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Creates a new user role.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CREATE ROLE GUEST_USERS;</PRE></BLOCKQUOTE>
<A NAME="E10E79"></A>
<P>
<FONT FACE="Arial"><B>CREATE SEQUENCE</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE [DENSE] SEQUENCE sequence-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Sequencer objects are objects that are used to get sequence numbers.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Using a dense sequence guarantees that there are no holes in the sequence numbers. The sequence number allocation is bound to the current transaction. If the transaction rolls back, also the sequence number allocations are rolled back. The drawback of dense sequences is that the sequence is locked out from other transactions until the current transaction ends.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Using a sparse sequence guarantees uniqueness of the returned values, but they are not bound to the current transaction. If a transaction allocates a sparse sequence number and later rolls back, the sequence number is simply lost.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The advantage of using a sequencer object instead of a separate table is that the sequencer object is specifically fine-tuned for fast execution and requires less overhead than normal update statements.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Sequences are accessed from stored procedures. The current sequence value can be retrieved using the following stored procedure statement:
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>EXEC SEQUENCE sequence-name.CURRENT INTO variable
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The new sequence value can be retrieved using the following stored procedure statement:
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>EXEC SEQUENCE sequence-name.NEXT INTO variable
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Sequence values can be set with the following stored procedure statement:
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>EXEC SEQUENCE sequence-name SET VALUE USING variable
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>Select access rights are required to retrieve the current sequence value. Update access rights are required to allocate new sequence values. These access rights are granted and revoked in the same way as table access rights.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CREATE DENSE SEQUENCE SEQ1;</PRE></BLOCKQUOTE>
<A NAME="E10E80"></A>
<P>
<FONT FACE="Arial"><B>CREATE TABLE</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE TABLE base-table-name
<BR> (column-element [, column-element] ...)
base-table-name ::= base-table-identifier |
<BR> schema-name.base-table-identifier
column-element ::= column-definition |
<BR> table-constraint-definition
column-definition ::= column-identifier
<BR> <I>data-type</I>
<BR> [column-constraint-definition
<BR> [column-constraint-definition] ...]
column-constraint-definition ::=
<BR> NOT NULL | NOT NULL UNIQUE |
<BR> NOT NULL PRIMARY KEY | CHECK (<I>check-condition</I>)
table-constraint-definition ::=
<BR> UNIQUE (column-identifier
<BR> [, column-identifier] ...) |
<BR> PRIMARY KEY (column-identifier
<BR> [, column-identifier] ...) |
<BR> CHECK (<I>check-condition</I>) |
<BR> FOREIGN KEY (column-identifier
<BR> [, column-identifier] ...)
<BR> REFERENCES <I>table-name</I>
<BR> (column-identifier [, column-identifier] ...)</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Tables are created through the CREATE TABLE statement. The CREATE TABLE statement requires a list of the columns created, the data types, and, if applicable, sizes of values within each column, in addition to other related alternatives (such as whether or not null values are permitted).
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CREATE TABLE DEPT (DEPTNO INTEGER NOT NULL, DNAME VARCHAR, PRIMARY KEY(DEPTNO));
CREATE TABLE DEPT2 (DEPTNO INTEGER NOT NULL PRIMARY KEY, DNAME VARCHAR);
CREATE TABLE DEPT3 (DEPTNO INTEGER NOT NULL UNIQUE, DNAME VARCHAR);
CREATE TABLE DEPT4 (DEPTNO INTEGER NOT NULL, DNAME VARCHAR, UNIQUE(DEPTNO));
CREATE TABLE EMP (DEPTNO INTEGER, ENAME VARCHAR, FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO));
CREATE TABLE EMP2 (DEPTNO INTEGER, ENAME VARCHAR, CHECK (ENAME IS NOT NULL), FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO));</PRE></BLOCKQUOTE>
<A NAME="E10E81"></A>
<P>
<FONT FACE="Arial"><B>CREATE USER</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE<I> </I>USER user-name IDENTIFIED BY password</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Creates a new user with a given password.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>CREATE USER HOBBES IDENTIFIED BY CALVIN;</PRE></BLOCKQUOTE>
<A NAME="E10E82"></A>
<P>
<FONT FACE="Arial"><B>CREATE VIEW</B></FONT>
<BLOCKQUOTE>
<PRE>CREATE VIEW viewed-table-name
<BR> [(column-identifier
<BR> [, column-identifier]... )]
<BR> AS <I>query-specification</I></PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>A view can be viewed as a virtual table; that is, a table that does not physically exist, but rather is formed by a query specification against one or more tables.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>CREATE VIEW TEST_VIEW
<BR> (VIEW_I, VIEW_C, VIEW_ID)
<BR> AS SELECT I, C, ID FROM TEST;</PRE></BLOCKQUOTE>
<A NAME="E10E83"></A>
<P>
<FONT FACE="Arial"><B>DELETE</B></FONT>
<BLOCKQUOTE>
<PRE>DELETE FROM <I>table-name</I>
<BR> [WHERE <I>search-condition</I>]</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>Depending on your search condition the specified row(s) will be deleted from a given table.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DELETE FROM TEST WHERE ID = 5;
DELETE FROM TEST;</PRE></BLOCKQUOTE>
<A NAME="E10E84"></A>
<P>
<FONT FACE="Arial"><B>DELETE (positioned)</B></FONT>
<BLOCKQUOTE>
<PRE>DELETE FROM <I>table-name</I> WHERE CURRENT OF cursor-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The positioned DELETE statement deletes the current row of the cursor.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>DELETE FROM TEST WHERE CURRENT OF MY_CURSOR;</PRE></BLOCKQUOTE>
<A NAME="E10E85"></A>
<P>
<FONT FACE="Arial"><B>DROP EVENT</B></FONT>
<BLOCKQUOTE>
<PRE>DROP EVENT event-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP EVENT statement removes the specified event from the database.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DROP EVENT EVENT-TEST;</PRE></BLOCKQUOTE>
<A NAME="E10E86"></A>
<P>
<FONT FACE="Arial"><B>DROP INDEX</B></FONT>
<BLOCKQUOTE>
<PRE>DROP INDEX index-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP INDEX statement removes the specified index from the database.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DROP INDEX UX_TEST;</PRE></BLOCKQUOTE>
<A NAME="E10E87"></A>
<P>
<FONT FACE="Arial"><B>DROP PROCEDURE</B></FONT>
<BLOCKQUOTE>
<PRE>DROP PROCEDURE procedure-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP PROCEDURE statement removes the specified procedure from the database.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DROP PROCEDURE PROCTEST;</PRE></BLOCKQUOTE>
<A NAME="E10E88"></A>
<P>
<FONT FACE="Arial"><B>DROP ROLE</B></FONT>
<BLOCKQUOTE>
<PRE>DROP ROLE role-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP ROLE statement removes the specified role from the database.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>DROP ROLE GUEST_USERS;</PRE></BLOCKQUOTE>
<A NAME="E10E89"></A>
<P>
<FONT FACE="Arial"><B>DROP SEQUENCE</B></FONT>
<BLOCKQUOTE>
<PRE>DROP SEQUENCE sequence-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP SEQUENCE statement removes the specified sequence from the database.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DROP SEQUENCE SEQ1;</PRE></BLOCKQUOTE>
<A NAME="E10E90"></A>
<P>
<FONT FACE="Arial"><B>DROP TABLE</B></FONT>
<BLOCKQUOTE>
<PRE>DROP TABLE base-table-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP TABLE statement removes the specified table from the database.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DROP TABLE TEST;</PRE></BLOCKQUOTE>
<A NAME="E10E91"></A>
<P>
<FONT FACE="Arial"><B>DROP USER</B></FONT>
<BLOCKQUOTE>
<PRE>DROP USER user-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP USER statement removes the specified user from the database.
</BLOCKQUOTE>
<H4>Example </H4>
<BLOCKQUOTE>
<PRE>DROP USER HOBBES;</PRE></BLOCKQUOTE>
<A NAME="E10E92"></A>
<P>
<FONT FACE="Arial"><B>DROP VIEW</B></FONT>
<BLOCKQUOTE>
<PRE>DROP VIEW viewed-table-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The DROP VIEW statement removes the specified view from the database.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>DROP VIEW TEST_VIEW;</PRE></BLOCKQUOTE>
<A NAME="E10E93"></A>
<P>
<FONT FACE="Arial"><B>EXPLAIN PLAN FOR</B></FONT>
<BLOCKQUOTE>
<PRE>EXPLAIN PLAN FOR sql-statement</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The EXPLAIN PLAN FOR statement shows the selected search plan for the specified SQL statement.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>EXPLAIN PLAN FOR select * from tables;</PRE></BLOCKQUOTE>
<A NAME="E10E94"></A>
<P>
<FONT FACE="Arial"><B>GRANT</B></FONT>
<BLOCKQUOTE>
<PRE>GRANT {ALL | grant-privilege
<BR> [, grant-privilege]...}
<BR> ON <I>table-name</I>
<BR> TO {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }
[WITH GRANT OPTION]
GRANT role-name TO user-name
grant-privilege<I> </I>::= DELETE | INSERT | SELECT |
<BR> UPDATE [( column-identifier
<BR><I> </I>[, column-identifier]...<I> </I>)] |
<BR> REFERENCES [( column-identifier
<BR><I> </I>[, column-identifier]...<I> </I>)]
GRANT EXECUTE ON procedure-name
<BR> TO {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }
GRANT {SELECT | INSERT} ON event-name
<BR> TO {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }
GRANT {SELECT | UPDATE} ON sequence-name
<BR> TO {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The GRANT statement is
</BLOCKQUOTE>
<UL>
<BLOCKQUOTE>
<LI>1. used to grant privileges to the specified user or role.
</BLOCKQUOTE>
<BLOCKQUOTE>
<LI>2. used to grant privileges to the specified user by giving
<BR>the user the privileges of the specified role.
</BLOCKQUOTE></UL>
<BLOCKQUOTE>
<P>If you do use the optional WITH GRANT OPTION, you give permission for the user(s) to whom you are granting the privilege to pass it on to other users.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>GRANT GUEST_USERS TO CALVIN;
GRANT INSERT, DELETE ON TEST TO GUEST_USERS;</PRE></BLOCKQUOTE>
<A NAME="E10E95"></A>
<P>
<FONT FACE="Arial"><B>INSERT</B></FONT>
<BLOCKQUOTE>
<PRE>INSERT INTO <I>table-name</I> [(column-identifier
<BR> [, column-identifier]...)]
<BR> VALUES (insert-value[, insert-value]... )</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>There are several variations of the INSERT statement. In the simplest instance, a value is provided for each column of the new row in the order specified at the time the table was defined (or altered). In the preferable form of the INSERT statement the columns are specified as part of the statement and they needn’t to be in any specific order as long as the orders of the column and value lists match with one another.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>INSERT INTO TEST (C, ID) VALUES (0.22, 5);
INSERT INTO TEST VALUES (0.35, 9);</PRE></BLOCKQUOTE>
<A NAME="E10E96"></A>
<P>
<FONT FACE="Arial"><B>INSERT (Using Query)</B></FONT>
<BLOCKQUOTE>
<PRE>INSERT INTO <I>table-name</I> [( column-identifier
<BR> [, column-identifier]... )]
<BR> <I>query-specification</I></PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The query specification creates a virtual table. Using the INSERT statement the rows of created virtual table are inserted into the specified table (the degree and data types of the virtual table and inserted columns must match).
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>INSERT INTO TEST (C, ID) SELECT A, B FROM INPUT_TO_TEST;</PRE></BLOCKQUOTE>
<A NAME="E10E97"></A>
<P>
<FONT FACE="Arial"><B>REVOKE (Role from User)</B></FONT>
<BLOCKQUOTE>
<PRE>REVOKE {role-name [, role-name]... }
<BR> FROM {PUBLIC | user-name [, user-name]... }</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The REVOKE statement is used to take a role away from users.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>REVOKE GUEST_USERS FROM HOBBES;</PRE></BLOCKQUOTE>
<A NAME="E10E98"></A>
<P>
<FONT FACE="Arial"><B>REVOKE (Privilege from Role or User)</B></FONT>
<BLOCKQUOTE>
<PRE>REVOKE
<BR> {revoke-privilege [, revoke-privilege]... }
<BR> ON <I>table-name</I>
<BR> FROM {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }
revoke-privilege ::= DELETE | INSERT |
<BR> SELECT | UPDATE | REFERENCES
REVOKE EXECUTE ON procedure-name
<BR> FROM {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }
REVOKE {SELECT | INSERT} ON event-name FROM
<BR> {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }
REVOKE {SELECT | INSERT} ON sequence-name
<BR> FROM {PUBLIC | user-name [, user-name]... |
<BR> role-name [, role-name]... }</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The REVOKE statement is used to take privileges away from users and roles.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>REVOKE INSERT ON TEST FROM GUEST_USERS;</PRE></BLOCKQUOTE>
<A NAME="E10E99"></A>
<P>
<FONT FACE="Arial"><B>ROLLBACK</B></FONT>
<BLOCKQUOTE>
<PRE>ROLLBACK WORK</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The changes made in the database are discarded by ROLLBACK statement. It terminates the transaction.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>ROLLBACK WORK;</PRE></BLOCKQUOTE>
<A NAME="E10E100"></A>
<P>
<FONT FACE="Arial"><B>SELECT</B></FONT>
<BLOCKQUOTE>
<PRE>SELECT [ALL | DISTINCT] <I>select-list</I>
<BR> FROM <I>table-reference-list</I>
<BR> [WHERE <I>search-condition</I>]
<BR> [GROUP BY column-name [, column-name]... ]
<BR> [HAVING <I>search-condition</I>]
<BR> [[UNION | INTERSECT | EXCEPT] [ALL]
<BR> select-statement]...
<BR> [ORDER BY {unsigned integer | column-name}
<BR> [ASC|DESC]]</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The SELECT statement is used to retrieve information.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>SELECT ID FROM TEST;
SELECT DISTINCT ID, C FROM TEST WHERE ID = 5;
SELECT DISTINCT ID FROM TEST ORDER BY ID ASC;
SELECT NAME, ADDRESS FROM CUSTOMERS UNION SELECT NAME, DEP FROM PERSONNEL;</PRE></BLOCKQUOTE>
<A NAME="E10E101"></A>
<P>
<FONT FACE="Arial"><B>SET</B></FONT>
<BLOCKQUOTE>
<PRE>SET SQL INFO {ON | OFF} [FILE {file-name |
<BR> "file-name" | 'file-name'}]
<BR> [LEVEL info-level]
SET SQL SORTARRAYSIZE {array-size | DEFAULT}
SET SQL JOINPATHSPAN {path-span | DEFAULT}
SET SQL CONVERTORSTOUNIONS
<BR> {YES [COUNT value] | NO | DEFAULT}
SET LOCK TIMEOUT timeout-in-seconds
SET STATEMENT MAXTIME minutes
SET TRANSACTION READ ONLY
SET TRANSACTION READ WRITE
SET TRANSACTION CHECK WRITESET
SET TRANSACTION CHECK READSET
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
SET TRANSACTION ISOLATION LEVEL
<BR> REPEATABLE READ
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>All the settings a re per user settings unlike the settings in the solid.ini file.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>In SQL INFO the default file is a global soltrace.out shared by all users. If the file name is given, all future INFO ON settings will use that file unless a new file is set. It is recommended that the file name is given in single quotes, because otherwise the file name is converted to uppercase. The info output is appended to the file and the file is never truncated, so after the info file is not needed anymore, the user must manually delete the file. If the file open fails, the info output is silently discarded.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The default SQL INFO LEVEL is 4. A good way to generate useful info output is to set info on with a new file name and then execute the SQL statement using EXPLAIN PLAN FOR syntax. This method gives all necessary estimator information but does not generate output from the fetches which may generate a huge output file.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The sort array is used for in memory sorts in the SQL interpreter. The minimum value for SORTARRAYSIZE is 100. If a smaller value is given, minimum value 100 will be used. If large sorts are needed, it is recommended that the external sorter facility is used (in Sorter section in solid.ini) instead on using very large SORTARRAYSIZE.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The COUNT parameter in SQL CONVERTORSTOUNIONS tells how many ors are converted to unions. The default is 10 which should be enough in most cases.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>SET STATEMENT MAXTIME sets connection specific maximum execution time in minutes. Setting is effective until a new maximum time if set. Zero time means no maximum time, which is also the default.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The SET TRANSACTION settings are borrowed from ANSI SQL. It sets the transaction isolation level.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>SET SQL INFO ON FILE 'sqlinfo.txt' LEVEL 5</PRE></BLOCKQUOTE>
<A NAME="E10E102"></A>
<P>
<FONT FACE="Arial"><B>SET SCHEMA</B></FONT>
<BLOCKQUOTE>
<PRE>SET SCHEMA {USER | 'user-name'}</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>From version 2.2 SOLID <I>Server</I> supports SQL89 style schemas for database entity name qualifying. All created database entities belong to a schema, and different schemas may contain entities with same name.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The default schema can be changed with the SET SCHEMA statement. Schema can be change to the current user name by using the SET SCHEMA USER statement. Alternatively schema can be set to ‘user-name’ which must be a valid user name in the database.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The algorithm to resolve entity names [schema-name.]table-identifier is the following:
<BR>
<BR>1. If schema-name is given then table-identifier is searched only from that schema.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>2. If schema-name is not given, then
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>a. First table-identifier is searched from default schema. Default schema is initially the same as user name, but can be changed with SET SCHEMA statement
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>b. Then table-identifier is searched from all schemas in the database. If more than one entity with same table-identifier and type (table, procedure, ...) is found, a new error code 13110 (Ambiguous entity name table-identifier ) is returned.
</BLOCKQUOTE>
<BLOCKQUOTE>
<P>The SET SCHEMA statement effects only to default entity name resolution and it does not change any access rights to database entities. It sets the default schema name for unqualified names in statements that are prepared in the current session by an execute immediate statement or a prepare statement.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>SET SCHEMA 'CUSTOMERS'</PRE></BLOCKQUOTE>
<A NAME="E10E103"></A>
<P>
<FONT FACE="Arial"><B>UPDATE (Positioned)</B></FONT>
<BLOCKQUOTE>
<PRE>UPDATE <I>table-name</I>
<BR> SET [<I>table-name.</I>]column-identifier = {<I>expression</I> |
<BR> NULL}
<BR> [, [<I>table-name.</I>]column-identifier = {<I>expression</I> |
<BR> NULL}]...
<BR> WHERE CURRENT OF cursor-name</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The positioned UPDATE statement updates the current row of the cursor. The name of the cursor is defined using ODBC API function named SQLSetCursorName.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>UPDATE TEST SET C = 0.33
<BR>WHERE CURRENT OF MYCURSOR</PRE></BLOCKQUOTE>
<A NAME="E10E104"></A>
<P>
<FONT FACE="Arial"><B>UPDATE (Searched)</B></FONT>
<BLOCKQUOTE>
<PRE>UPDATE <I>table-name</I>
<BR> SET [<I>table-name.</I>]column-identifier = {<I>expression</I> |
<BR> NULL}
<BR> [, [<I>table-name.</I>]column-identifier = {<I>expression</I> |
<BR> NULL}]...
<BR> [WHERE <I>search-condition</I>]</PRE></BLOCKQUOTE>
<H4>Usage</H4>
<BLOCKQUOTE>
<P>The UPDATE statement is used to modify the values of one or more columns in one or more rows, according the search conditions.
</BLOCKQUOTE>
<H4>Example</H4>
<BLOCKQUOTE>
<PRE>UPDATE TEST SET C = 0.44 WHERE ID = 5</PRE></BLOCKQUOTE>
<A NAME="E10E105"></A>
<P>
<FONT FACE="Arial"><B>Table-reference</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Table-reference</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>table-reference-list
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E739"></A>
<P>::= table-reference [ , table-reference … ] </TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>table-reference
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E740"></A>
<P>::= table-name [[AS] correlation-name] | outer-join
<BR><I>( A SELECT statement can contain only one </I>
<BR><I>table-reference that is an outer-join.)</I></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>table-name
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E741"></A>
<P>::= table-identifier | schema-name.table-identifier</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>outer-join
</TD><TD WIDTH=300 VALIGN=top >
<P>::= table-name LEFT [OUTER] JOIN
<BR><!--{-->table-name<!-- | outer-join} --> ON search-condition</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E106"></A>
<P>
<FONT FACE="Arial"><B>Query-specification</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Query-specification</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>query-specification
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E742"></A>
<P>::= SELECT [DISTINCT | ALL] select-list
<BR>table-expression</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>select-list
</TD><TD WIDTH=300 VALIGN=top >
<P>::= * | select-sublist
<BR>[ {, select-sublist} ... ]</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>select-sublist
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E743"></A>
<P>::= derived-column |
<BR>[table-name | table-identifier].*</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>derived-column
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E744"></A>
<P>::= expression [ [AS] column-alias] ] </TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>table-expression
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E745"></A>
<P>::= FROM table-reference-list
<BR>[WHERE search-condition]
<BR>[GROUP BY column-name [, column-name] ...]
<BR>[[UNION | INTERSECT | EXCEPT] [ALL]
<BR>query-specification]
<BR>[HAVING search-condition]</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E107"></A>
<P>
<FONT FACE="Arial"><B>Search-condition</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Search-condition</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>search-condition
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E746"></A>
<P>::= search-item | search-item { AND | OR }
<BR>search-item</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>search-item
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E747"></A>
<P>::= [NOT] { search-test |
<BR>(search-condition) }</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>search-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E748"></A>
<P>::= comparison-test | between-test |
<BR>like-test | null-test | set-test |
<BR>quantified-test | existence-test</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>comparison-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E749"></A>
<P>::= expression { = | <> | < | <= | > | >= }
<BR>{ expression | subquery }</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>between-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E750"></A>
<P>::= column-identifier [NOT] BETWEEN
<BR>expression AND expression</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>like-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E751"></A>
<P>::= column-identifier [NOT] LIKE value
<BR>[ESCAPE value]</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>null-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E752"></A>
<P>::= column-identifier IS [NOT] NULL</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>set-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E753"></A>
<P>::= expression [NOT] IN ( { value
<BR>[,value]... | subquery } )</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>quantified-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E754"></A>
<P>::= expression { = | <> | < | <= | > | >= }
<BR>[ALL | ANY | SOME] subquery</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>existence-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E755"></A>
<P>::= EXISTS subquery</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>subquery
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E756"></A>
<P>::= (query-specification)</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E108"></A>
<P>
<FONT FACE="Arial"><B>Check-condition</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Check-condition</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>check-condition
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E757"></A>
<P>::= check-item | check-item { AND | OR }
<BR>check-item</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>check-item
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E758"></A>
<P>::= [NOT] { check-test |
<BR>(check-condition) }</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>check-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E759"></A>
<P>::= comparison-test | between-test |
<BR>like-test | null-test | list-test</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>comparison-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E760"></A>
<P>::= expression { = | <> | < | <= | > | >= }
<BR>{ expression | <I>subquery</I> }</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>between-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E761"></A>
<P>::= column-identifier [NOT] BETWEEN
<BR>expression AND expression</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>like-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E762"></A>
<P>::= column-identifier [NOT] LIKE value
<BR>[ESCAPE value]</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>null-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E763"></A>
<P>::= column-identifier IS [NOT] NULL</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>list-test
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E764"></A>
<P>::= expression [NOT] IN ( { value
<BR>[,value]...} )</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E109"></A>
<P>
<FONT FACE="Arial"><B>Expression</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Expression</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>expression
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E765"></A>
<P>::= expression-item | expression-item
<BR>{ + | - | * | / } expression-item</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>expression-item
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E766"></A>
<P>::= [ + | - ] { value | column-identifier | function |
<BR>( expression ) }</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>value
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E767"></A>
<P>::= literal | USER | variable</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E768"></A>
<P>::= COUNT(*) | distinct-function | all-function |
<BR>null-function | scalar-function | case-expression</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>distinct-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E769"></A>
<P>::= { AVG | MAX | MIN | SUM | COUNT }
<BR>( DISTINCT column-identifier )</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>all-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E770"></A>
<P>::= { AVG | MAX | MIN | SUM | COUNT }
<BR>( [ ALL ] expression )</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>null-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E771"></A>
<P>::= { NULLVAL_CHAR( ) | NULLVAL_INT( ) } </TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>scalar-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E772"></A>
<P>::= string-function | numeric-function |
<BR>timedate-function | system-function | datatypeconversion-function</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>string-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E773"></A>
<P>::= ASCII(str-exp) | CHAR(ascii-code) |
<BR>CONCAT(str-exp1, str-exp2) |
<BR>str-exp1 { + | || } str-exp2 |
<BR>{FN INSERT(str-exp1, start, length, str-exp2)} | LCASE(str-exp) | {FN LEFT(str-exp)} |
<BR>LENGTH(str-exp) |
<BR>LOCATE(str-exp1, strexp2 [, start]) | LTRIM(str-exp) | REPEAT(str-exp, count) | RIGHT(str-exp, count) | REPLACE(str-exp1, str-exp2, str-exp3) |
<BR>RTRIM(str-exp) | SPACE(count) |
<BR>SUBSTRING(str-exp, start, length) | UCASE(str-exp)</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>numeric-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E774"></A>
<P>::= ABS(num-exp) | ACOS(float-exp) |
<BR>ASIN(float-exp) | ATAN(float-exp) |
<BR>ATAN2(float-exp1, float-exp2) | CEILING(num-exp) | COS(float-exp) | COT(float-exp) | DEGREES(num-exp) | EXP(float-exp) | FLOOR(num-exp) |
<BR>LOG(float-exp) | LOG10(float-exp) |
<BR>MOD(int-exp1, int-exp2) | PI() |
<BR>POWER(num-exp, int-exp) | RADIANS(num-exp) | ROUND(num-exp, int-exp) | SIGN(num-exp) | SQRT(float-exp) | TAN(float-exp) |
<BR>TRUNCATE(num-exp, int-exp)</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>datetime-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E775"></A>
<P>::= CURDATE() | CURTIME() |
<BR>DAYNAME(date-exp) | DAYOFMONTH(date-exp) | DAYOFWEEK(date-exp) | DAYOFYEAR(date-exp) | HOUR(time-exp) | MINUTE(time-exp) | MONTH(date-exp) | MONTHNAME(date-exp) | NOW() | QUARTER(date-exp) | SECOND(time-exp) | TIMESTAMPADD(interval, int-exp, timestamp-exp) |
<BR>TIMESTAMPDIFF(interval, timestamp-exp1, timestamp-exp2) | WEEK(date_exp) |YEAR(date_exp)</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>system-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E776"></A>
<P>::= IFNULL(exp, value) | {FN USER()}</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>datatypeconversion-function
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E777"></A>
<P>::= CONVERT_CHAR(value-exp) | CONVERT_DATE(value-exp) | CONVERT_DECIMAL(value-exp) | CONVERT_DOUBLE(value-exp) | CONVERT_FLOAT(value-exp) | CONVERT_INTEGER(value_exp) | CONVERT_LONGVARCHAR(value-exp) | CONVERT_NUMERIC(value-exp) | CONVERT_REAL(value-exp) | CONVERT_SMALLINT(value-exp) | CONVERT_TIME(value-exp) | CONVERT_TIMESTAMP(value-exp) | CONVERT_TINYINT(value-exp) | CONVERT_VARCHAR(value-exp)</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>case-expression
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E778"></A>
<P>CASE value-exp
<BR> WHEN value-exp
<BR> THEN {value-exp}
<BR> [WHEN value-exp
<BR> THEN {value-exp} …]
<BR> ELSE {value-exp}</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E110"></A>
<P>
<FONT FACE="Arial"><B>Data-type</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Data-type</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>data-type
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E779"></A>
<P>::= {BINARY |
<BR> CHAR [ length ] |
<BR> DATE |
<BR> DECIMAL [ ( precision [ , scale ] ) ] |
<BR> DOUBLE PRECISION |
<BR> FLOAT [ ( precision ) ] |
<BR> INTEGER |
<BR> LONG VARBINARY |
<BR> LONG VARCHAR |
<BR> NUMERIC [ ( precision [ , scale ] ) ] |
<BR> REAL |
<BR> SMALLINT |
<BR> TIME |
<BR> TIMESTAMP [ ( timestamp precision ) ] |
<BR> TINYINT |
<BR> VARBINARY |
<BR> VARCHAR [ ( length ) ] }</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E111"></A>
<P>
<FONT FACE="Arial"><B>Dat</B><B>e and Time Literal</B><B>s</B></FONT>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Date/time literal</B>
</TD><TD WIDTH=300 VALIGN=top ><BR></TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>date-literal
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E780"></A>
<P>´YYYY-MM-DD´</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>time-literal
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E781"></A>
<P>´HH:MM:SS´</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>timestamp-literal
</TD><TD WIDTH=300 VALIGN=top >
<A NAME="E7E782"></A>
<P>´YYYY-MM-DD HH:MM:SS´</TD></TR></TABLE></BLOCKQUOTE><A NAME="E10E112"></A>
<P>
<FONT FACE="Arial"><B>Pseudo Columns</B></FONT>
<BLOCKQUOTE>
<P>The following pseudo columns may also be used in the select-list of a SELECT statement:
</BLOCKQUOTE>
<BLOCKQUOTE><TABLE>
<TR>
<TD WIDTH=156 VALIGN=top >
<P><B>Pseudo column</B>
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E783"></A>
<P>Type
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E783"></A>
<P>Explanation</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>ROWVER
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E784"></A>
<P>VARBINARY(254)
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E784"></A>
<P>Version of the row in a table. </TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>ROWID
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E785"></A>
<P>VARBINARY(10)
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E785"></A>
<P>Persistent id for a row in a table.</TD>
</TR>
<TR>
<TD WIDTH=156 VALIGN=top >
<P>ROWNUM
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E786"></A>
<P>DECIMAL(16,2)
</TD><TD WIDTH=150 VALIGN=top >
<A NAME="E7E786"></A>
<P>Row number indicates the sequence in which a row was selected from a table or set of joined rows. The first row selected has a ROWNUM of 1, the second row has 2, etc. ROWNUM is chiefly useful for limiting the number of rows returned by a query (e.g., WHERE ROWNUM < 10).</TD></TR></TABLE></BLOCKQUOTE>
<BLOCKQUOTE>
<P>NOTE! Since ROWID and ROWVER refer to a single row, they may only be used with queries that return rows from a single table.
</BLOCKQUOTE><P ALIGN=CENTER>
<A HREF="aguide12.htm" TARGET="_self"><IMG SRC="gaguide/graprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="httoc.htm" TARGET="_self"><IMG SRC="gaguide/gratop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="htindex.htm" TARGET="_self"><IMG SRC="gaguide/graindex.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Index"></A>
<A HREF="aguide14.htm" TARGET="_self"><IMG SRC="gaguide/granext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
<center><p><font SIZE=-2>Copyright © 1992-1997 Solid Information Technology Ltd All rights reserved.</font></p></center>
</BODY></HTML>
|