home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / d / dtu11b.zip / QSQLDEMO.EXE / QSQL.DOC < prev    next >
Text File  |  1992-09-24  |  46KB  |  1,546 lines

  1. COPYRIGHT (C) 1991, 1992 Cook Database Design,
  2. Inc.
  3.    ╔═════════════════════════════════╗
  4.    ║            QSQL(TM)             ║
  5.    ║                                 ║
  6.    ║          Version 2.0            ║
  7.    ║                                 ║
  8.    ║            01/15/92             ║
  9.    ║                                 ║
  10.    ║   Cook Database Design, Inc.    ║
  11.    ║      619 Woodduck Lane          ║
  12.    ║    Georgetown Kentucky 40324    ║
  13.    ║                                 ║
  14.    ║    Order Desk: (800) 282-2302   ║
  15.    ║   Information: (502) 863-1957   ║
  16.    ║           Fax: (502) 863-2086   ║
  17.    ║ When sending a Fax, please      ║
  18.    ║ start as soon as you hear the   ║
  19.    ║ first ring.                     ║
  20.    ╚═════════════════════════════════╝
  21.  
  22.  
  23.  
  24. This is a demo version and may be freely distributed.
  25. The difference between this version and the real version
  26. is that this will only display the first 5 records of
  27. your query and updates are not available.   The rest of
  28. the records are suppressed.
  29.  
  30. Have fun learning SQL and enjoy!
  31.  
  32.                     - 1 -
  33. Introduction
  34.  
  35. QSQL is a standalone query program for the
  36. Clarion database environment.  It provides a
  37. powerful subset of the ANSI SQL language with
  38. special enhancements which were made to
  39. support the Clarion environment.
  40.  
  41. Highlights
  42.  
  43. QSQL is a powerful subset of ANSI SQL
  44.  
  45. QSQL can perform a join on any number of
  46. tables only limited by memory
  47.  
  48. QSQL can use keys to speed up its operation
  49.  
  50. QSQL is a state of the art SQL implementation
  51. using advanced relational database techniques
  52. in order to provide an extremely small and
  53. fast SQL implementation.
  54.  
  55. QSQL can be used to perform mass updates of
  56. your databases by using the UPDATE command.
  57.  
  58. Installation
  59.  
  60. To install QSQL, copy the programs into a
  61. directory on your fixed disk.  The Clarion
  62. directory would be a good place.
  63.  
  64.        COPY A:*.* C:\CLARION
  65.  
  66. That's it!  Note that it is assumed that the
  67. Clarion directory is in your path statement.
  68.  
  69. Included on the distribution diskette are the
  70. sailors, boats, and res database which are
  71. used in the SQL tutorial.  These databases are
  72. a good set of databases with which to learn
  73. SQL.                     - 2 -
  74. Using QSQL
  75.  
  76. The simplest way to use QSQL is via the QSQL
  77. interactive query program. To use the program,
  78. get into the directory which contains your
  79. application data files and type: QSQL
  80.  
  81. A data entry screen will appear in which you
  82. can enter your SQL queries.  There are twelve
  83. lines in which to enter your queries. From
  84. this screen the following keys can be pressed:
  85.  
  86. CTRL-ENTER
  87. Once you have entered your query, you can
  88. execute it and see the results by pressing
  89. CTRL-ENTER (press the Ctrl key and while
  90. holding it down press the Enter key and then
  91. release both of them).  Your query will be
  92. processed and the results will be displayed on
  93. the screen.
  94.  
  95. You can scroll your query result one line at a
  96. time with the up and down arrows.  Using the
  97. PgUp and PgDn keys you can scroll up and down
  98. one page at a time.
  99.  
  100. If you requested enough fields to be displayed
  101. so that the output is longer than 80
  102. characters, you can scroll to the right or
  103. left if required by pressing the left and
  104. right arrows.
  105.  
  106. Note: QSQL can only scroll to see the first
  107. 255 characters of the record.  If your output
  108. is longer, you will not be able to see the
  109. results which are past column 255.
  110.  
  111. While viewing your results, you can print the
  112. output on your printer by pressing the CTRL-L
  113. key.                     - 3 -
  114. CTRL-ESC
  115. This will terminate QSQL and return you back
  116. to DOS.
  117.  
  118. CTRL-V
  119. This will re-display the results of your last
  120. query.
  121.  
  122. CTRL-C
  123. This will clear the screen so you can enter
  124. your query from scratch.
  125.  
  126. CTRL-L
  127. The will permit you to load a previously saved
  128. query.  You will be given a list of saved
  129. queries.  Move the cursor to the one you want
  130. to load and press enter.
  131.  
  132. While viewing the list of queries, you can
  133. press the DEL key to delete them.
  134.  
  135. CTRL-S
  136. Will permit you to save your current query.
  137. You will be prompted for the name of the
  138. query.  If this is a previously loaded query,
  139. then the name of the query will be already
  140. filled in.  Change the name to what you want
  141. to save the query as and press enter to save
  142. it.
  143.  
  144. CTRL-F
  145. Will list all the databases (.DAT) files in
  146. your directory                     - 4 -
  147. SQL TUTORIAL
  148.  
  149. This section will give you a brief tutorial on
  150. how to use SQL.  This section is intended for
  151. those who have had no previous experience in
  152. SQL, or those who need a refresher.
  153.  
  154. SQL is a query language which was developed by
  155. IBM during their Systems R research project in
  156. the late 70's.  It now has wide spread
  157. popularity and as such, is considered as the
  158. standard query language for relational
  159. databases.  The main power in SQL is that it
  160. is a non-navigational query language.  That
  161. is, you specify what data you want to display,
  162. but not how to navigate the databases in order
  163. to answer your query.
  164.  
  165. Before we get into any details about SQL
  166. queries, lets examine a few simple ones to
  167. give you the flavor of the query language.
  168. These queries are on the sailors database.
  169. Refer to Appendix A for a schema listing of
  170. the sailors database. Appendix A also has a
  171. listing of all the records in the databases.
  172. The query number e.g. (Query 1) is used to
  173. identify the query so you can easily load and
  174. execute it in the example databases which
  175. accompany QSQL.                     - 5 -
  176. (Query 1)
  177.  
  178. SELECT * FROM sailors;
  179.  
  180. SID        SNAME                RATING
  181. ────────── ──────────────────── ──────
  182.          1 George Bush             100
  183.          2 Ronald Regan             50
  184.          3 Jimmy Carter            255
  185.          4 Gerald Ford             230
  186.          5 Richard Nixon           124
  187.          6 Lyndon Johnson          250
  188.          7 John Kennedy             75
  189.          8 Dwight Eisenhower         5
  190.          9 Harry Truman              4
  191.         10 Franlin Roosevelt         8
  192.         11 Herbert Hoover          124
  193.  
  194.  
  195. This query will display all records and fields
  196. from the sailors.dat database.  It will also
  197. display all records.  The SELECT tells SQL
  198. that a query is to follow.  The * is a
  199. wildcard character and tells QSQL to display
  200. all fields which are contained in the
  201. database. FROM tells QSQL the database(s)
  202. which need to be processed.  In the above
  203. query, the database is sailors.
  204.  
  205. After the databases are listed in the FROM
  206. clause, the WHERE clause can be used to
  207. restrict which records from the database are
  208. to be displayed. Since the WHERE clause was
  209. not part of QUERY 1, this tells QSQL to
  210. display all records in the database.  The next
  211. query will demonstrate the use of the where
  212. clause.
  213.                     - 6 -
  214. (Query 2)
  215.  
  216. SELECT * FROM sailors WHERE sid = 5;
  217.  
  218. SID        SNAME             RATING
  219. ────────── ───────────────── ──────
  220.          5 Richard Nixon        124
  221.  
  222. This query will display all fields from the
  223. sailors.dat database.  It will only display
  224. the records in which the SID field has the
  225. value of 5.  This query is similar to query 1
  226. with the exception of the WHERE clause sid =
  227. 5.  The where clause restricts what is
  228. displayed to only those records in the
  229. database which matches the clause.
  230.  
  231. (Query 3)
  232.  
  233. SELECT sname, rating
  234.   FROM sailors
  235.  WHERE rating > 100;
  236.  
  237.      SNAME                RATING
  238.      ──────────────────── ──────
  239.      Jimmy Carter            255
  240.      Gerald Ford             230
  241.      Richard Nixon           124
  242.      Lyndon Johnson          250
  243.      Herbert Hoover          124
  244.  
  245.  
  246. This query will display the sailors name and
  247. their rating of all sailors in the SAILORS.DAT
  248. database who have a rating greater than 100.
  249.  
  250. This completes the introduction to SQL. We
  251. will now explicitly describe every aspect of
  252. QSQL with examples.  Now would be a good time
  253. to try QSQL on your own databases to practice
  254. what you have learned.                     - 7 -
  255. SQL SELECT SYNTAX
  256.  
  257. The syntax of SQL queries is as follows:
  258.  
  259.        SELECT [DISTINCT] fieldnames
  260.          FROM filenames
  261.        [WHERE clause1 AND clause2 AND etc...]
  262.        [GROUP BY fieldnames]
  263.        [ORDER BY fieldnames] ;
  264.  
  265. Clauses enclosed in brackets [  ] are
  266. optional.
  267.  
  268. The SELECT clause describes the fields you
  269. wish to display.
  270.  
  271. The DISTINCT keyword is used to insure that no
  272. duplicate information is displayed.
  273.  
  274. The FROM clause describes the files which are
  275. to be processed.
  276.  
  277. The WHERE clause describes which records from
  278. the database(s) are to be displayed. It is
  279. also used to specity how files are to be
  280. joined together.
  281.  
  282. The GROUP BY clause is used to group
  283. information together.
  284.  
  285. The ORDER BY clause is used to sort the
  286. information being presented.
  287.  
  288.                     - 8 -
  289. Fieldnames
  290.  
  291. Fieldnames are the name of the fields that are
  292. to be displayed. The names are separated by
  293. commas.  The names can be qualified with a
  294. file alias (e.g. alias.fieldname) to
  295. distinguish among same field names in several
  296. files. Two special field names exist.  The *
  297. field name specifies all fields in the first
  298. file in the FROM clause.  The * can also be
  299. qualified with an alias to specify the file if
  300. more than one exists.  The # field name
  301. corresponds to the physical record number. It
  302. too can be qualified with a file alias.
  303.  
  304. When fields are displayed, they are displayed
  305. according to there type (i.e. strings are
  306. displayed as strings and numbers are displayed
  307. as numbers).  There are two exceptions to this
  308. rule.  If a field is of type LONG and has the
  309. substring DATE contained in the field name, it
  310. is converted to a date and displayed in the
  311. form: mm/dd/yy.  If a field is of type long
  312. and has the substring TIME contained in the
  313. field name, it is converted to a time and
  314. displayed in the form: HH:MM:SS.
  315.  
  316. You can override the output format by
  317. suffixing the field name with an @ followed by
  318. the format with which you would like the data
  319. to be displayed.  Valid suffixes are:
  320.  
  321. @D - display the field as a date. Used when
  322.        you have a date field which does not
  323.        contain the substring DATE in the field.
  324. @T - Display the field as a time. Used when
  325.        you have a time field which does not
  326.        contain the substring TIME in the field.
  327. @N - Display the field as a number.  Used when
  328.        you want to display a date or time as its
  329.        numeric value.                     - 9 -
  330. @Nw - Used to change the width of the field in
  331.        which the number is displayed. w is the
  332.        size.
  333. @Nw.d - Used to specify the width as well as
  334.        the number of decimal places to display.
  335.        This only works on REAL or DECIMAL
  336.        fields.
  337.  
  338. @Sw - Display the string field with a given
  339.        width.
  340.  
  341. Some examples are:
  342.  
  343. DTFLD@D - Display the field DTFLD as a date.
  344.  
  345. MONEY@N10.2 - Display the money field as a
  346. number with two decimal places.
  347.  
  348. Note: QSQL will always display the number.  If
  349. the number is too large to  fit within the
  350. field width, it will expand the width of the
  351. field appropriately, but only for the line(s)
  352. in which the number is too large. This will
  353. cause the line to not be aligned with the
  354. lines above or below it on the report. So, be
  355. sure to specify a width in which all numbers
  356. for the field can fit.  The width field used
  357. with strings do truncate any characters which
  358. cannot be displayed.
  359.  
  360. Here is a sample query:
  361.  
  362. SELECT sname@s5, rating@n15
  363.   FROM sailors
  364.  WHERE rating > 200;
  365.  
  366. SNAME RATING
  367. ───── ───────────────
  368. Jimmy             255
  369. Geral             230
  370. Lyndo             250                                 - 10 -
  371. Filenames
  372.  
  373. filenames are the names of the files from
  374. which the fields of the files are to be
  375. selected. The files are separated by a comma.
  376.  
  377. Example:
  378.  
  379. filename1, filename2
  380.  
  381. You can assign an alias to a file by entering
  382. the alias name after the filename seperating
  383. the two by a space.  Example:
  384.  
  385. filename1 xxx, filename2 yyy
  386.  
  387. This assigns the alias of xxx to filename1 and
  388. yyy to filename2.  When refering to fields,
  389. you can prefix then with the alias name.  For
  390. example, suppose field1 is contained in the
  391. file filename1.  Then, you could refer to
  392. field1 by xxx.field1.   Aliases are important
  393. when the same field name is contained in
  394. several files in order to uniquely identify
  395. the field.  For Clarion files, the alias
  396. defaults to the file 3 character prefix.
  397.  
  398. If your file is contained in another
  399. directory, you can specify the directory
  400. information.  Example:
  401.  
  402. \directory\filename
  403.  
  404. If your file is contained on another drive and
  405. directory, you specify this as follows:
  406.  
  407. d:\directory\filename
  408.  
  409. where d: is the drive letter.                    - 11 -
  410. Where clauses
  411.  
  412. clause1, clause2, etc... are the clauses with
  413. which records are selected from the databases.
  414. These clauses are used to specify which
  415. records are to be printed and how two files
  416. are to be joined.
  417.  
  418. Where clauses are of the form:
  419.  
  420.        field op value
  421.        field op field
  422.        clause or clause
  423.  
  424. The valid operators are:
  425.  
  426.        =     Equals (begins with)
  427.        <>    Not Equals
  428.        <     Less Than
  429.        <=    Less Than Or Equal
  430.        >     Greater Than
  431.        >=    Greater Than Or Equal
  432.        LIKE  pattern matching - strings only
  433.  
  434. Note:  The equals operator (=) acts like a
  435. begins operator.  For example: name = 'j' will
  436. match all records in which the name field
  437. begins with the letter 'j'.  If you want only
  438. the name field which has exactly J, pad the
  439. string with blanks to the length of the field
  440. to which it is compared against.
  441.  
  442. In addition, comparisons against strings are
  443. case insensitive.  That is, corresponding
  444. lower case and upper case letters are
  445. considered equivalent. For example, if you
  446. search for 'qsql' it will match 'qsql',
  447. 'QSQL', 'Qsql', 'QsQL', etc...
  448.                    - 12 -
  449. Like Operator
  450.  
  451. The above operators are pretty self
  452. explanatory except for the  LIKE operator. The
  453. LIKE operator is a powerful pattern matching
  454. operator which can be used on string fields.
  455. It can be use to find substrings, begins with
  456. strings and ends with strings.  The syntax of
  457. the LIKE operator is:
  458.  
  459.         field LIKE 'pattern'
  460.  
  461. where pattern can contain characters which are
  462. to be matched or two special characters:
  463.  
  464.        % - The percent sign (%) is used to
  465.              indicate any string of zero or more
  466.              characters.
  467.  
  468.        _ - The underscore (_) is used to
  469.              indicate any single character
  470.  
  471. The LIKE operator is a case insensitive
  472. operator.  That is, when matching a lower case
  473. character with an upper case character, the
  474. LIKE operator will result in a match.
  475.  
  476. Here are some examples:
  477.  
  478. 1) Names which begin with the letter J
  479.  
  480.        name LIKE 'j%'
  481.  
  482. Note that this performs the same function as
  483. NAME = 'j'. You should use the name = value
  484. syntax when you want to perform a begins with
  485. as it is much faster than the LIKE operator.
  486.  
  487. 2) Names which begin with J and end with S
  488.  
  489.        name LIKE 'j%s'                    - 13 -
  490. 3) Names which are three characters long and
  491. end with IM
  492.  
  493.        name LIKE '_im'
  494.  
  495. 4) Names which start with B, and have a LY
  496. somewhere in it
  497.  
  498.        name LIKE 'B%LY%'
  499.  
  500. 5) Names which contain the word LEE
  501.  
  502.        name LIKE '%LEE%'
  503.  
  504. 6) Names which have the initials HH
  505.        name LIKE 'H% H%'
  506.  
  507. Other interesting patterns include:
  508.  
  509.   '__'    Matches strings which are exactly 2
  510.           characters long
  511.   '____%' Matches strings which are at least 4
  512.           characters long
  513.  
  514.                    - 14 -
  515. Strings
  516.  
  517. String constants are entered enclosed in
  518. apostrophe (') symbols.  For example, to enter
  519. the string YELLOW, you would code:
  520.  
  521.        'YELLOW'
  522.  
  523. Note: Null strings '' don't have any meaning
  524. and can product un-predictable results.
  525.  
  526. Numbers
  527.  
  528. Numbers are entered as usual.  Commas are
  529. permitted and ignored.  If you wish to start
  530. your number with a $ to signify money, that is
  531. acceptable as well.  Some numeric examples
  532. are:
  533.        1234
  534.        $1,234
  535.        1234.56
  536.        $1,234.56
  537.        -$1234.56
  538.  
  539. Dates and Times
  540.  
  541. When dealing with dates and times, you can
  542. enter the values as: mm/dd/yy or hh:mm:ss.
  543.  
  544. For example, you can enter a query clause:
  545.  
  546.        DATEFIELD = 06/01/91
  547.  
  548. To find dates which match June 1st, 1991.
  549.  
  550. For times you can enter:
  551.  
  552.        TIMEFIELD = 13:30:00
  553.  
  554. To find times which match 1:30 P.M..                     - 15 -
  555. Joins
  556.  
  557. One of the powerful features of QSQL is the
  558. ability to combine (join) various databases
  559. together in order to obtain related
  560. information. In order to motivate the reasons
  561. for doing a join, a demonstration of a query
  562. which needs to do a join is in order. Suppose
  563. you want to know the names of the sailors who
  564. have reserved a boat on 06/01/91.  To solve
  565. the query, you could enter a query as
  566. follows:
  567.  
  568. (Query 4)
  569. SELECT * FROM res WHERE date = 06/01/91;
  570.  
  571. BID        SID        DATE
  572. ────────── ────────── ────────
  573.          4          5 06/01/91
  574.          4          7 06/01/91
  575.          9          1 06/01/91
  576.  
  577.  
  578. This query would list out the sid, bid, and
  579. date fields from the database.  However, the
  580. query you want is to display the sailor's
  581. names, not their sid numbers.  The names of
  582. the sailors are in the sailors.dat database,
  583. but their reservation information is not so we
  584. cannot just do a simple query on the sailors
  585. database.
  586.  
  587. In order to obtain both pieces of information,
  588. we need to join the two tables together.  To
  589. join the two tables, you need to specify two
  590. pieces of information: the tables to be
  591. joined, and the fields on which they are
  592. joined.  In our example, the two databases
  593. are: res and sailors.   The field on which
  594. they are to be joined is the field which they
  595. share, the sid field.                    - 16 -
  596. To specify the shared (joined) field, you add
  597. a statement to the where clause: alias1.field
  598. = alias2.field where alias1 and alias2 are the
  599. aliases of the two files which are to be
  600. joined.  Note that usually the field names are
  601. the same, but do not have to be.  Therefore to
  602. answer our query, the SQL command would be:
  603.  
  604. (Query 5)
  605.  
  606. SELECT sai.sname
  607.   FROM sailors sai, res res
  608.  WHERE date = 06/01/91
  609.    AND sai.sid = res.sid;
  610.  
  611. SAI.SNAME
  612. ────────────────────
  613. Richard Nixon
  614. John Kennedy
  615. George Bush
  616.  
  617.  
  618. You can join any number of tables together by
  619. just listing them in the FROM clause and
  620. adding N-1 WHERE clauses where N is the number
  621. of databases to be joined.
  622.  
  623. Lets augment the above query to include not
  624. only the sailor's name, but to also include
  625. the color of the boat they reserved.  The boat
  626. color is contained in the boats database.  The
  627. res and boats both have the bid field for
  628. which to perform the join on.  Here is the SQL
  629. query to answer that question:
  630.                    - 17 -
  631. (Query 6)
  632.  
  633. SELECT sai.sname, boa.color
  634.   FROM sailors, res, boats
  635.  WHERE date = 06/01/91
  636.    AND sai.sid = res.sid
  637.    AND boa.bid = res.bid;
  638.  
  639. SAI:SNAME            BOA:COLOR
  640. ──────────────────── ──────────
  641. Richard Nixon        GREEN
  642. John Kennedy         GREEN
  643. George Bush          BLUE
  644.  
  645.  
  646. Some points to note:
  647.  
  648. - Order of the were clauses does not matter
  649.  
  650.   sai.sid = res.sid and boa.bid = res.bid
  651.  
  652.      is equivalent to:
  653.  
  654.   boa.bid = res.bid and sai.sid = res.sid
  655.  
  656. - Order of the join fields does not matter
  657.  
  658.   sai.sid = res.sid
  659.  
  660.      is equivalent to:
  661.  
  662.   res.sid = sai.sid
  663.                    - 18 -
  664. Rename and Joins
  665.  
  666. With the alias function, you can have multiple
  667. instances of the same file. This is useful if
  668. you would like to join a file with itself.
  669. Having multiple instances of the same file is
  670. know as a rename of the file.
  671.  
  672. Suppose you want to display the sailors who
  673. have reserved a boat on 06/01/91 and 06/02/91.
  674. In order to solve this type of query, the
  675. sailors database needs to be joined against
  676. the reservations database, twice.  Here is the
  677. query:
  678.  
  679. (Query 7)
  680.  
  681. SELECT sai.sname
  682.   FROM  sailors sai, res rs1, res rs2
  683.  WHERE  rs1.date = 06/01/91
  684.    AND rs2.date = 06/02/91
  685.    AND rs1.sid = rs2.sid
  686.    AND rs1.sid = sai.sid;
  687.  
  688. SNAME
  689. ────────────────────
  690. George Bush
  691.  
  692.  
  693. This query needs to rename the reservations
  694. database so that it could have two instances
  695. active at once.  The rs1 instance is for all
  696. reservations for 06/01/91 and the rs2 instance
  697. is for all reservations on 06/02/91.  The
  698. clause rs1.sid = rs2.sid insures that the
  699. sailor who reserved the boat on 06/01/91 is
  700. the same one who reserved the boat on
  701. 06/02/91.  And finally the rs1.sid = sai.sid
  702. is used to relate the sid found with the name
  703. of the sailor.
  704.                    - 19 -
  705. You may be wondering if the query:
  706.  
  707.        SELECT sailors.sname
  708.          FROM sailors sailors, res res
  709.         WHERE res.date = 06/01/91
  710.           AND res.date = 06/02/91
  711.           AND res.sid = sailors.sid;
  712.  
  713. would solve the problem.  It does not.  This
  714. is because there is only one instance of the
  715. res database active in the query.  Therefore
  716. there is only one date value active when the
  717. comparison is made.  No records would be
  718. selected as there is no date which is equal to
  719. both 06/01/91 and 06/02/91.
  720.  
  721. Another example in which you would need to use
  722. a rename is a follows:
  723.  
  724. Suppose you had a database, employee, with
  725. three fields:
  726.  
  727.   name - the name of the employee
  728.   salary - the salary of the employee
  729.   mgrname - the name of the employee's manager
  730.  
  731. To answer the query, list all employees who
  732. earn more than their manager, the following
  733. query is used:
  734.  
  735.        SELECT emp.name
  736.          FROM employee emp, employee mgr
  737.         WHERE emp.mgrname = mgr.name
  738.          AND emp.salary > mgr.salary;
  739.  
  740.                    - 20 -
  741. SELECT DISTINCT
  742.  
  743. The distinct keyword is used to eliminate
  744. duplicates from your result.  To motivate its
  745. use, here is a query we want to answer
  746.  
  747. What types of boats does the club own?
  748.  
  749. The boat types are in the bname field of the
  750. boats relation.  So, we could issue the
  751. following simple query to get the list:
  752.  
  753.   SELECT bname FROM boats;
  754.  
  755. BNAME
  756. ────────────────────
  757. Interlake
  758. Interlake
  759. Interlake
  760. M20
  761. M20
  762. M20
  763. Keel
  764. Interlake
  765. Guppy
  766. Guppy
  767.  
  768. But as you can see, all boat records are
  769. displayed an as such, you have several
  770. INTERLAKE, M20, etc... displayed.  Just think
  771. if this boat club had hundreds or thousands of
  772. boats.                      - 21 -
  773. To solve the problem in a more appropriate
  774. fashion, we need to remove duplicate types
  775. (bname's).  This can be accomplished with the
  776. DISTINCT keyword. Here is a revised query:
  777.  
  778. SELECT DISTINCT bname FROM boats;
  779.  
  780. BNAME
  781. ────────────────────
  782. Guppy
  783. Interlake
  784. Keel
  785. M20
  786.  
  787. This removes the duplicates and gives you the
  788. answer you want.  Note that duplicate
  789. elimination is performed by sorting the data.
  790. This slows down your query and as such you
  791. should only specify DISTINCT when it is
  792. required.                    - 22 -
  793. ORDER BY
  794.  
  795. The order by clause is used to sort the output
  796. in ascending order. The clause is used to
  797. specify the fields in which the sort order is
  798. to be performed.
  799.  
  800. For example, in QUERY 1 we displayed all the
  801. sailors in the database via the query:
  802.  
  803. SELECT * FROM sailors;
  804.  
  805. The sailor information was printed in the
  806. order it is in the database.
  807.  
  808. If we wanted them printed in order of their
  809. rating, we could use the query:
  810.  
  811. SELECT * FROM sailors ORDER BY rating;
  812.  
  813. SID        SNAME                RATING
  814. ────────── ──────────────────── ──────
  815.          9 Harry Truman           4
  816.          8 Dwight Eisenhower      5
  817.         10 Franlin Roosevelt      8
  818.          2 Ronald Regan          50
  819.          7 John Kennedy          75
  820.          1 George Bush          100
  821.         11 Herbert Hoover       124
  822.          5 Richard Nixon        124
  823.          4 Gerald Ford          230
  824.          6 Lyndon Johnson       250
  825.          3 Jimmy Carter         255
  826.  
  827.  
  828.                    - 23 -
  829. AGGREGATES
  830.  
  831. Aggregate functions (or sometimes known as
  832. column functions) are used to perform
  833. operations on a particular field.  There are 5
  834. aggregate functions:
  835.  
  836. AVG - Computes the average value.
  837.  
  838. COUNT - Counts the number of records.
  839.  
  840. SUM - Computes the sum (total) of the field.
  841.  
  842. MIN - Finds the minimum value.
  843.  
  844. MAX - Finds the the maximum value.
  845.  
  846. All of the above aggregates takes a field name
  847. as its argument. The COUNT aggregate is
  848. special in that it does not require a field
  849. because it is just counting occurances.  As
  850. such, you can code the COUNT aggregate as
  851. COUNT(*) which is a common practice.
  852.  
  853. For example, to find the average rating of all
  854. sailors in the sailing club, you would use the
  855. query:
  856.  
  857. SELECT AVG(rating) FROM sailors;
  858.  
  859. AVG(RATING)
  860. ───────────
  861. 111                             - 24 -
  862. Suppose that you want to know the average
  863. rating of all sailors who reserved an
  864. interlake boat.  To get the list of sailors
  865. who served an interlake boat, you could enter
  866. the query:
  867.  
  868.        SELECT *
  869.          FROM sailors sai, res res, boats boa
  870.         WHERE res.bid = boa.bid
  871.           AND res.sid = sai.sid
  872.           AND boa.bname = 'interlake';
  873.  
  874. SID     SNAME                RATING
  875. ─────── ──────────────────── ──────
  876.       1 George Bush          100
  877.       3 Jimmy Carter         255
  878.       2 Ronald Regan          50
  879.  
  880. To get the average value, you would enter the
  881. query:
  882.  
  883.        SELECT AVG(rating)
  884.          FROM sailors sai, res res, boats boa
  885.         WHERE res.bid = boa.bid
  886.           AND res.sid = sai.sid
  887.           AND boa.bname = 'interlake';
  888.  
  889. AVG(RATING)
  890. ───────────
  891. 135                             - 25 -
  892. GROUP BY
  893.  
  894. The GROUP BY clause is used in conjunction
  895. with aggregate functions in order to produce
  896. statistics by groups, instead of a single
  897. number for the whole database.  For example,
  898. suppose we wanted to find out how many boats
  899. we have of each color.  We could display all
  900. the boats with the
  901.  
  902.  SELECT color FROM boats;
  903.  
  904. query and count them.  Or, we could count all
  905. the red boats by entering the query:
  906.  
  907.  SELECT count(*) FROM boats WHERE color='red';
  908.  
  909. COUNT(COLOR)
  910. ────────────
  911.      3
  912.  
  913. Then repeat the above query for each color of
  914. boat.
  915.  
  916. But, the best way is to use the GROUP BY
  917. clause as demonstrated by the following query:
  918.  
  919.   SELECT color, COUNT(*)
  920.     FROM boats
  921.    GROUP BY color;
  922.  
  923. COLOR      COUNT(COLOR)
  924. ────────── ────────────
  925. BLACK               2
  926. BLUE                4
  927. GREEN               1
  928. RED                 3
  929.                         - 26 -
  930. Now suppose we want the number of boats of
  931. each type which has the same color. (i.e. how
  932. many red interlake boats are there?, green
  933. interlakes? etc...)  The query is:
  934.  
  935.   SELECT bname, color, COUNT(*)
  936.     FROM boats
  937.    GROUP BY bname, color;
  938.  
  939. BNAME                COLOR      COUNT(*)
  940. ──────────────────── ────────── ──────────
  941. Guppy                BLUE                2
  942. Interlake            BLACK               1
  943. Interlake            BLUE                1
  944. Interlake            RED                 2
  945. Keel                 BLUE                1
  946. M20                  BLACK               1
  947. M20                  GREEN               1
  948. M20                  RED                 1
  949.  
  950. Now lets answer the question: What type of
  951. boats are the most popular? By popular we mean
  952. which ones get reserved most often.  To answer
  953. this question, we want to know how often each
  954. type of boat get reserved. This can be
  955. accomplished by the following query:
  956.  
  957. SELECT bname, count(*)
  958.   FROM boats boa, res res
  959.  WHERE boa.bid = res.bid
  960. GROUP BY bname;
  961.  
  962. BNAME                COUNT(*)
  963. ──────────────────── ──────────
  964. Guppy                         1
  965. Interlake                     3
  966. M20                           9
  967.  
  968. As you can see, the M20 boats are the most
  969. popular type of boats to be reserved.                         - 27 -
  970. SQL UPDATE SYNTAX
  971.  
  972. The syntax of the update command is:
  973.  
  974. UPDATE filenames
  975.    SET expressions
  976. [WHERE where clauses];
  977.  
  978. Note: The update command in QSQL does not
  979. update the key files.  If you update a field
  980. which has a key on it, you will need to
  981. rebuild the key in order for it to obtain the
  982. new value.  In addition, you cannot update
  983. decimal fields.  These restrictions will be
  984. removed in a future version of QSQL.
  985.  
  986.  
  987. Structure of Update command
  988.  
  989. The structure of the SQL update command
  990. consists of three clauses: UPDATE, SET, WHERE.
  991.  
  992. The UPDATE clause describes the databases
  993. which are to be used or updated in the
  994. command.
  995.  
  996. The SET clause describes what fields are to be
  997. changed and to what values.
  998.  
  999. The WHERE clause describes which records from
  1000. the database(s) are to be updated.
  1001.  
  1002. filenames
  1003.  
  1004. Specifies the file names which are used in the
  1005. update command.  Refer to the select command
  1006. for more information on the file names.                    - 28 -
  1007. expression
  1008.  
  1009. Specifies the fields which are to be updated
  1010. and to what value they are to be set. The
  1011. syntax of the expression is:
  1012.  
  1013.        field = value
  1014.  
  1015. where field is the field to be updated and
  1016. value is the value the field is to be changed
  1017. to.  Value can be a constant or another field.
  1018. Some examples are:
  1019.  
  1020.        name = 'jones'
  1021.        date = 01/01/91
  1022.        age = 14
  1023.        name = newname
  1024.  
  1025. where clauses
  1026.  
  1027. The where clauses are similar to those of the
  1028. select command. The clauses describes which
  1029. records are to be updated.  A simple where
  1030. clause would be:
  1031.  
  1032.        field = value
  1033.  
  1034. More complex where clauses can be used which
  1035. involves joins in order to perform complex
  1036. updates.
  1037.  
  1038. For more information on the where clause,
  1039. refer back to the SELECT command where clause
  1040. section of the manual for more information.
  1041.                    - 29 -
  1042. Here are some sample updates and a discussion
  1043. about what they do.
  1044.  
  1045. (Update 1)
  1046.  
  1047.        UPDATE sailors SET rating = 100;
  1048.  
  1049. This update changes every record in the
  1050. sailors database and sets the rating to 100.
  1051.  
  1052. (Update 2)
  1053.  
  1054.        UPDATE sailors
  1055.           SET rating = 200
  1056.         WHERE sname = 'Jimmy Carter";
  1057.  
  1058. This update changes Jimmy Carter's rating to
  1059. 200.
  1060.  
  1061. Now for a more complex update which involves a
  1062. join. Suppose we want to set the rating to 200
  1063. of anyone who has reserved a boat on 06/01/91
  1064. and 06/02/91.  In (Query 7) we found the
  1065. sailors who reserved boats on those dates.
  1066. Using the same where clauses, we can perform
  1067. the update as follows:
  1068.  
  1069. (Update 3)
  1070.  
  1071.        UPDATE sailors sai, res rs1, res rs2
  1072.           SET rating = 200
  1073.         WHERE rs1.date = 06/01/91
  1074.           AND rs2.date = 06/02/91
  1075.           AND rs1.sid = rs2.sid
  1076.           AND rs1.sid = sai.sid;
  1077.                    - 30 -
  1078. Next, suppose we sold boat 4 which was a green
  1079. M20 and bought a new boat M30 which is yellow
  1080. to replace it.  The following update can be
  1081. used to change the database:
  1082.  
  1083. (Update 4)
  1084.  
  1085.        UPDATE boats
  1086.           SET bname = 'M30',
  1087.               color = 'YELLOW'
  1088.         WHERE BID = 4;
  1089.  
  1090. Please note that the comma between bname =
  1091. 'M30' and color = 'YELLOW' is required to
  1092. separate the set expressions.
  1093.  
  1094. And a final reminder, if you update a field
  1095. which has a key on it, you need to rebuild the
  1096. key with the clarion BUILD command or the
  1097. Clarion utility filer (CFIL.EXE).                     - 31 -
  1098. The SQLTABLE Model File
  1099.  
  1100. The SQLTABLE model file is a model file which
  1101. can be used to execute SQL commands directly
  1102. from your designer application. The records
  1103. which match the query are then displayed in a
  1104. table.  The SQLTABLE.MDL file only contains
  1105. the model file for the SQL tables.  This model
  1106. is based on the STANDARD.MDL file which is
  1107. distributed by Clarion.  As such, it is not
  1108. intended for network applications.  Also, if
  1109. you are using a 3rd party model file, (e.g.
  1110. Mike Hanson's Super Model files), this model
  1111. may or may not work.  It is only intended to
  1112. work with the STANDARD.MDL.   If you would
  1113. like to use this capability with other 3rd
  1114. party model files, please contact the model
  1115. file vendor and request that they support QSQL
  1116. directly in their model files.
  1117.  
  1118. Installation
  1119.  
  1120. Before you can use the SQLTABLE.MDL file in
  1121. your application, you need to combine it with
  1122. the STANDARD.MDL file in order to create a
  1123. complete model file.  This can be accomplished
  1124. with the command:
  1125.  
  1126.        COPY SQLTABLE.MDL+STANDARD.MDL QSQL.MDL
  1127.  
  1128. This will create a new model, QSQL.MDL which
  1129. contains both the standard model and sqltable
  1130. models.
  1131.  
  1132. To install this into your designer
  1133. application, you need to select designer from
  1134. your main clarion menu and follow the steps
  1135. below:
  1136.  
  1137. 1) On the initial designer screen, enter your
  1138.        application name.                    - 32 -
  1139. 2) Change the model file name to the new
  1140.        QSQL.MDL file you created.
  1141.  
  1142. 3) Once at the designer application display,
  1143.        you need to add an other procedure by
  1144.        moving the cursor to the procedure side
  1145.        of the screen and then press the INS key.
  1146.        Then add the following information:
  1147.  
  1148.         PROCEDURE NAME: BLDSQL
  1149.            MODULE NAME: XBLDSQL
  1150.                 BINARY: NO
  1151.           RETURN VALUE: NO
  1152.  
  1153. 4) Now you are ready to add your SQL table.
  1154.        Select the menu you want to have the SQL
  1155.        option on.
  1156.  
  1157. 5) Add a menu item which calls a new
  1158.        procedure.  Any procedure name you like
  1159.        will be fine.  Save the menu by pressing
  1160.        ctrl-enter.
  1161.  
  1162. 6) Next select the procedure you just added
  1163.        which should be labeled as TODO. Create
  1164.        the procedure type as a TABLE and then
  1165.        build the table just like you would if
  1166.        you were normally building a table to
  1167.        view/update the file with one exception,
  1168.        the model name should be SQLTABLE.
  1169.  
  1170. 7) You are now done.  Press SHIFT-F7 to create
  1171.        and test your application.
  1172.                    - 33 -
  1173. SQLTABLE Usage
  1174.  
  1175. When you invoke the table from your
  1176. application, you will be first prompted to
  1177. enter the query.  This is the where clause
  1178. part of the SQL statement.  The SQLTABLE model
  1179. automatically creates:
  1180.  
  1181. SELECT # FROM filename WHERE
  1182.  
  1183. and tacks on what you enter on this form. Once
  1184. you have entered the query, press CTRL-ENTER
  1185. and the query will execute and only the fields
  1186. which match the query will be displayed on the
  1187. table.
  1188.  
  1189. If you like, after the where clauses, you can
  1190. enter the ORDER BY clause to specify the sort
  1191. order of your query.
  1192.  
  1193. Join Queries
  1194.  
  1195. If you need to perform joins to solve your
  1196. query, you will need to modify XBLDSQL.CLA to
  1197. suit your needs.  For joins, the form of the
  1198. query needs to be: SELECT # FROM filename1,
  1199. etc... where filename1 is the file to be
  1200. displayed on the table. I.E. The table file
  1201. needs to be specified first in the list of
  1202. files.                     - 34 -
  1203. Appendix A - Sailors/Boats/Res Schema and
  1204.              listing
  1205.  
  1206. Throughout this document, the sailors, boats,
  1207. res databases are used for examples. Here is a
  1208. list of the fields and their descriptions in
  1209. the databases. The three databases are used to
  1210. model a sailing club who has sailors, boats
  1211. and reservations.
  1212.  
  1213. Sailors: Describes Sailors in the sailing
  1214. club.
  1215.  
  1216.    SID    - LONG   - A Sailor ID Number
  1217.    SNAME  - STRING - The name of the sailor
  1218.    RATING - LONG   - The sailor's rating
  1219.  
  1220. SID        SNAME                RATING
  1221. ────────── ──────────────────── ──────
  1222.          1 George Bush          100
  1223.          2 Ronald Regan          50
  1224.          3 Jimmy Carter         255
  1225.          4 Gerald Ford          230
  1226.          5 Richard Nixon        124
  1227.          6 Lyndon Johnson       250
  1228.          7 John Kennedy          75
  1229.          8 Dwight Eisenhower      5
  1230.          9 Harry Truman           4
  1231.         10 Franlin Roosevelt      8
  1232.         11 Herbert Hoover       124
  1233.                    - 35 -
  1234. Boats: Describes Boats in sailing club.
  1235.  
  1236.    BID    - LONG   - A boat ID number
  1237.    BNAME  - STRING - The type of the boat
  1238.    COLOR  - STRING - The color of the boat
  1239.  
  1240. BID        BNAME                COLOR
  1241. ────────── ──────────────────── ──────────
  1242.          1 Interlake            RED
  1243.          2 Interlake            RED
  1244.          3 Interlake            BLUE
  1245.          4 M20                  GREEN
  1246.          5 M20                  BLACK
  1247.          6 M20                  RED
  1248.          7 Keel                 BLUE
  1249.          8 Interlake            BLACK
  1250.          9 Guppy                BLUE
  1251.         10 Guppy                BLUE
  1252.                    - 36 -
  1253. Res: Reservations database - Describes which
  1254. boats are reserved, by which sailor, on which
  1255. date.
  1256.  
  1257.    SID  - LONG - The sailor who reserved boat
  1258.    BID  - LONG - The boat id of reserved boat
  1259.    DATE - LONG - The date the boat is reserved
  1260.  
  1261. Res Database
  1262. BID        SID        DATE
  1263. ────────── ────────── ────────
  1264.          1          1 06/13/91
  1265.          2          2 06/13/91
  1266.          4          1 06/02/91
  1267.          4          5 06/01/91
  1268.          4          7 06/01/91
  1269.          1          3 06/10/91
  1270.          9          1 06/01/91
  1271.          5          9 06/02/91
  1272.          4          2 06/08/91
  1273.          6          3 06/02/91
  1274.          4          8 05/31/91
  1275.          6          1 05/28/91
  1276.          5          3 05/28/91
  1277.                    - 37 -
  1278. Appendix B - SQL.EXE
  1279.  
  1280. The SQL.EXE program is the main SQL processor.
  1281. It accepts SQL commands as a parameter:
  1282.  
  1283.        SQL "select * from sailors;"
  1284.  
  1285. From the keyboard
  1286.  
  1287.        SQL
  1288.  
  1289. the program will prompt you to enter a SQL
  1290. query
  1291.  
  1292. Or via re-direction
  1293.  
  1294.        SQL <query.in
  1295.  
  1296. where query.in is the file which contains a
  1297. SQL query.
  1298.  
  1299. The output is displayed on the terminal. If
  1300. you want the output to be sent to a file, you
  1301. can re-direct the output to a file via the dos
  1302. re-direction facility.  The following examples
  1303. send the output to a file called query.out.
  1304.  
  1305.        SQL <query.in >query.out
  1306.  
  1307. or
  1308.  
  1309.        SQL "select * from sailors;" >query.out
  1310.                    - 38 -
  1311. Appendix C - How to execute SQL from your
  1312.              Clarion application
  1313.  
  1314. If you would like to execute SQL from your
  1315. Clarion application and process the output,
  1316. you will need to code the interface by hand.
  1317. To run QSQL from your application you need to
  1318. use the RUN or RUNSMALL command.  RUNSMALL
  1319. executes much faster than the RUN command, but
  1320. may not work if there is not enough available
  1321. memory.   When you call SQL.EXE from your
  1322. application, you should code the following:
  1323.  
  1324.        RUNSMALL('SQL <q.in >q.out')
  1325.        IF RUNCODE() = -2 THEN
  1326.                           RUN('SQL <q.in >q.out').
  1327.  
  1328. This code will first try the RUNSMALL command
  1329. and if there is not enough memory, it will
  1330. then execute the RUN command to execute the
  1331. SQL query.  The above queries assume that the
  1332. query was loaded into a file called q.in and
  1333. the results of the sql query is to be placed
  1334. into the q.out file.
  1335.  
  1336. In most cases you will probably just want a
  1337. list of record numbers which match the query
  1338. to be placed into the q.out file.  Using the #
  1339. as the field name displays the record number
  1340. (e.g. "select # from ...).  If you have more
  1341. than one file the query is being processed
  1342. against, you can prefix the # with the prefix
  1343. of the file (e.g. PRE:#).
  1344.  
  1345. The -U option may be helpful in accessing the
  1346. data directly from Clarion.  Refer to the
  1347. XBLDSQL.CLA and SQLTABLE.MDL files for and
  1348. example on how to implement this as that is
  1349. exactly what they do.                      - 39 -
  1350. Appendix D - QSQL Version 2.0 Limitations
  1351.  
  1352. Here are a set of limitations which are
  1353. currently imposed.
  1354.  
  1355. 1) Does not support BETWEEN  - Is equivalent
  1356. to: field >= low and field <= high
  1357.  
  1358. 2) Does not support nested (correlated)
  1359. queries  - Most nested queries can be written
  1360. into non-nested queries with joins.
  1361.  
  1362. 3) Does not support SQL HAVING statement.
  1363.  
  1364. 4) Only the SELECT and UPDATE statements have
  1365. been implemented.  UPDATES do not update key
  1366. files. If you update a field on which there is
  1367. a key, you will need to perform a clarion
  1368. BUILD or run the filer utility (CFIL.EXE) on
  1369. the database in order to use the key with the
  1370. updated values. In addition, you cannot update
  1371. decimal fields.
  1372.  
  1373. 5) Does not use keys for fields of type REAL
  1374. or DECIMAL.  QSQL does not use keys for
  1375. strings which are defined to be case
  1376. sensitive.  Will use decimal keys for join
  1377. operations when both are the same size.
  1378.  
  1379. 6) Does not support arithmetic operators (e.g.
  1380. +, -, *, /).
  1381.  
  1382. 7) Does not support encrypted files.
  1383.  
  1384. 8) On networks, updates does not support
  1385. record locking.                    - 40 -
  1386. Appendix E - Join Performance
  1387.  
  1388. Joins are a terribly slow process in
  1389. relational databases. While QSQL performs them
  1390. fast, as joins go, they are still slow.  To
  1391. speed up joins, insure that there is an index
  1392. on the join fields.  QSQL will use this index
  1393. to speed up the join processing.
  1394.                    - 41 -
  1395. Appendix F - Processing Options
  1396.  
  1397.  
  1398. You can alter the way SQL processes by passing
  1399. processing options to the SQL processor.  The
  1400. options are:
  1401.  
  1402.  
  1403. -C     Output should be in ascii, comma
  1404.        delimited format.  The first row of the
  1405.        output is the column headings.  The rest
  1406.        of the rows is the actual data. The -C
  1407.        option will probably be used in
  1408.        conjuction with the -O option.
  1409.  
  1410. -Offff       Send the output to the file ffff.
  1411.  
  1412. -Q     Don't display column headings.
  1413.  
  1414. -Rnnn        Where nnn is the number of sort
  1415.        runs.  nnn determines the largest file
  1416.        which can be sorted. The larges file size
  1417.        which can be sorted is 10,000 times the
  1418.        value on nnn.  The default value is 100,
  1419.        so a 1 megabyte file is the largest which
  1420.        can be sorted.
  1421.  
  1422. -S     Display some processing statistics
  1423.  
  1424. -U     Display the output as uninterpreted data.
  1425.        For example, a long is stored in the
  1426.        computer as a 4 byte binary number.  If
  1427.        you display a long field with the -U
  1428.        option turned on, the 4 byte number will
  1429.        be display in the internal format. -U
  1430.        should be used in conjunction with the -O
  1431.        operand in order to specify the output
  1432.        file.  The -U option is for exporting the
  1433.        results to another program.                     - 42 -
  1434. -Wx    Specifies that sort workfiles should be
  1435.        placed on drive x: (where x is the drive
  1436.        letter).  When sorting, two temorary
  1437.        files are required which is equal in size
  1438.        of the data to be displayed.  If you have
  1439.        a ram drive which is large enough to hold
  1440.        these workfiles, use it as that will
  1441.        greatly enhance the speed of the sorting
  1442.        process.  The default drive is the
  1443.        current drive.
  1444.  
  1445.  
  1446. Example usage:
  1447.  
  1448. You want to create a file called EXPORT.SQL
  1449. which contains the comma delimited output of
  1450. the query. In addition, you want to specify
  1451. the E drive as the temporary sort work drive.
  1452.  
  1453. The SQL options would be:
  1454.  
  1455. SQL -C -OEXPORT.SQL -WE "select * etc..."                    - 43 -
  1456. Appendix G - Revision History
  1457.  
  1458. 07/01/91 V1.0 - Never released.  Beta testing
  1459.        went so well, we immediately went to
  1460.        version 1.1 as our initial release of the
  1461.        product.
  1462.  
  1463. 07/19/91 V1.1 - Added UPDATE command
  1464.  
  1465. 10/09/91 V2.0
  1466.        - Supports directory information for
  1467.              files
  1468.        - Supports DISTINCT keyword to eliminate
  1469.              duplicates
  1470.        - Supports ORDER BY to specify sort order
  1471.              (ascending only)
  1472.        - Supports GROUP BY to group output
  1473.        - Supports aggregate functions AVG,
  1474.              COUNT, MIN, MAX, SUM
  1475.        - Supports output formats for data
  1476.        - Supports output to a different file
  1477.        - Supports comma delimited output
  1478.        - Supports Uninterpreted data output
  1479.        - Add temp file specification for sorting
  1480.        - Add a SQLTABLE model file so that SQL
  1481.              can be incorporated into DESIGNER
  1482.              apps
  1483.        - Limited support for xbase files -- does
  1484.              not use an index on them.                    - 44 -
  1485. Appendix H - Creating Clarion Files
  1486.  
  1487. If you would like to create a Clarion file
  1488. from the output of your SQL query, you can
  1489. perform the following two steps:
  1490.  
  1491. 1) Execute your SQL query with the options -C
  1492.        and -Ofilename to create an ascii, comma
  1493.        delimited file of the output.  Be sure to
  1494.        include the suffix .BAS for the file
  1495.        name. This will become apparent in the
  1496.        next step.
  1497.  
  1498. 2) Execute the Clarion converter utility,
  1499.        CCVT.EXE to convert the file into a
  1500.        Clarion database.  The Clarion converter
  1501.        utility requires that the file have a
  1502.        suffix of .BAS .
  1503.  
  1504. These two steps can be consolidated into a
  1505. single .BAT file.                     - 45 -
  1506. Appendix I - License Agreement
  1507.  
  1508. Cook Database Design, Inc. hereby disclaims
  1509. all warranties relating to this software,
  1510. whether express or implied, including without
  1511. limitation any implied warranties of
  1512. merchantability or fitness for a particular
  1513. purpose. Cook Database Design, Inc. will not
  1514. be liable for any special, incidental,
  1515. consequential, indirect or similar damages due
  1516. to loss of data or any other reason, even if
  1517. Cook Database Design, Inc. or an agent of Cook
  1518. Database Design, Inc. has been advised of the
  1519. possibility of such damages.  In no event
  1520. shall Cook Database Design, Inc.'s liability
  1521. for any damages ever exceed the price paid for
  1522. the license to use software, regardless of the
  1523. form of the claim.  The person using the
  1524. software bears all risk as to the quality and
  1525. performance of the software.
  1526.  
  1527. This software is protected by both United
  1528. States copyright law and international treaty
  1529. provisions. You are licensed to use this
  1530. software under the provision that only one
  1531. copy will be in use at a time.  That is, the
  1532. software can reside in many places, (eg.
  1533. backup diskette, work computer, home computer)
  1534. as long as there is no possibility that it is
  1535. being used at one location while it is being
  1536. used at another.
  1537.  
  1538. If you require multiple copies of QSQL to be
  1539. executing simultaneously, then you need to
  1540. purchase addition copies of QSQL.
  1541.  
  1542. If you want to distribute SQL.EXE with your
  1543. applications, you need to purchase a SQL.EXE
  1544. runtime license, 1 for each SQL.EXE
  1545. distributed.
  1546.