Professional Documents
Culture Documents
Table of Contents
Introduction
SQL
Tables
Scalable SQL for Windows
Definition of Database
Tables used by Solomon IV
Reading the Reports
SQLScope
The Menu Bar
The View Option
Database in Use
Conventions Used in this Guide
Errors
Creating Tables
Importing Data
Retrieving All Data
Retrieving a Single Column
Retrieving Multiple Columns
Formatting Numbers
Ordering Rows
Displaying Rows in Descending Order
Ordering Multiple Columns
Retrieving Specific Rows
Multiple Conditions
Joining Tables
Updating Tables
Deleting Rows
Inserting Rows
Pervasive SQL
If you are interested in learning about Pervasive SQL, this is the site. Our
online tutorial provides a basic introduction to Pervasive SQL. It covers the
create, import, retrieve, order, update, delete, insert, and join commands.
Introduction
To find a list of the tables used by Solomon IV, follow the steps
outlined below:
The first column of the report lists field names. The second column
indicates field types. The third column indicates field lengths. The
fourth and final column provides a description of the field
contents.
The tables just described are similar to the ones used by Solomon
IV. We will create these tables later and use them in our exercises.
Field Type
Field types define the kind of data the field can contain. Scalable
SQL supports four major field types:
String
Numeric
Date and time
Boolean
String -- A string field stores characters. It can also store numbers;
however, a number cannot be used in mathematical calculations
unless it is first converted to a numeric. Scalable SQL supports the
following types of strings:
character
lstring1
zstring1
note1
lvar 1
Numeric -- A numeric field stores numbers. You can use the field to
perform mathematical calculations. Scalable SQL supports the
following types of numeric fields:
Decimal1
Float1
Integer1
Numeric1
Date and time -- Date and time fields accept the date and time.
Length
1. To log in to SQLScope:
2. Open SQLScope.
3. In the Database Name field, enter the name of the database
you wish to open.
The View options on the Menu bar control how the SQL Scope
interface displays to the user. The Lists option displays table
names, field names, and templates. The Status Bar displays
messages and is located at the very bottom of the screen. Move To
buttons display to the left of the SQL text box; use Move To
buttons to move around your SQL text screen quickly. Run buttons
display to the right of the SQL text box; use Run buttons to run
your SQL statement. For these lessons, you should turn on all of
these options by following these instructions:
1. Click on View.
2. Click on any item that does not have a checkmark next to it.
Note: You might have to perform this process several times,
because only one option can be selected at a time. So click on
View and then click on any item that does not have a
checkmark next to it. Then click on View again and click on
any additional item that does not have a checkmark next to it.
Continue until all items are checked.
Database in Use
Directly below the Menu bar is the Database field. The name of the
current database is displayed in this field.
Tables
The Tables box lists all of the tables in the database. Clicking on a
table name will place the table name in the SQL text box.
Fields
The Fields box lists all of the fields in a particular table. Clicking
on a field name will place the field name in the SQL text box.
Templates
Errors
SQL consists of commands you type into the SQLScope text box.
If you receive an error message after entering a SQL command,
check your spelling and syntax.
1
Explanation of these terms is beyond the scope of this course.
You must create your tables before you can enter data into them.
Use the Create Table command.
Syntax:
Explanation:
Examples:
Char -- a character string
Float -- a number
Date -- a date field
Logical -- a logical field
Example:
Create tables TrnVendor and TrnAPDoc. We will use these tables
in the exercises that follow:
Importing Data
You can import data into SQLScope from another data source by
using the Insert command. Before completing the following
exercises, you must import data into the tables you created. The
example given in this section will step you through the process.
Syntax:
Explanation:
• Before you can import, you must create a data file in one of
the following formats:
o Btreive unformatted (.unf) -- File layout.
Logical, date, and time fields are in binary format.
Each row is preceded by its length, followed by a
comma.
Each row is terminated with a carriage return.
o Standard Data Format (.sdf) -- File layout.
All data is represented in ASCII characters.
A comma is used to separate fields.
Character fields are enclosed in double quotes.
Each row is terminated with a carriage return.
o ASCII
Each row is preceded by a comma or a space.
Each field and each row is a specified length.
Each row is terminated with a carriage return.
o DIF (.dif)
Each file is made up of two sections: header and
data.
Each row has a standard length.
Each field has a standard length.
• The Values clause is used to specify substitution variables.
• Substitution variables must be preceded by an @ sign.
• Each field in the Insert statement must be in the same order
as the corresponding field in the data file.
To import data:
Choose Import from the File menu to open the Import dialog box.
1. In the File Type box, specify the type of file you want to
import.
2. In the Drive box, specify the appropriate drive.
3. In the Directories box, specify the appropriate directory.
4. In the File Name box, specify the name of the file from
which to import.
5. If you would like the process to run in the background
while you continue working, click on the Background
field.
6. Click on Import to begin the import process.
Example:
SQL Select
SQL select statements are used to retrieve data from SQL databases. Take
our free online SQL tutorial and learn SQL. Among the many commands we
teach you are the SQL commands used to select and order data contained
in a SQL database.
Select statements are used to retrieve data from SQL tables. The
Select statement illustrated below retrieves all of the columns and
rows from the named table.
Syntax:
Select *
from tablename;
Explanation:
Example:
Select *
from TrnVendor;
Results:
SQL Language
The SQL language is used to access data. With SQL, you can query your
database in a variety of ways, using English-like statements. Learning SQL
is easy. Our online tutorial teaches you SQL commands.
Syntax:
Select fieldname
from tablename;
Explanation:
Example:
Retrieve the vendor name from each record:
Select Name
from TrnVendor;
Results:
Name
Wet Off Towels
The Games All Here
BedMakers Linen
Bed Room Furniture, Inc.
Ray Block
Mosquito No Bite
Spot Out
Big Tree Landscaping
Hit the Deck
The Soda Factory
The Freelance
Paper People
Softer Software
Counter Productive
No Waste Disposal
Music Maker
Food Four
Computer Bytes
Bayshore Consulting
BayCon Group
Cooperative Operatives
Legal Lookup
World Wide Learning U
Enterprise Transport
Against the Tide
Clampett Oil
Narrow Nest
Distant Horizons
Paltry Play
Make Shift Tilts
Learn SQL
Want to learn SQL? Our free online SQL tutorial teaches you the SQL
commands you need to query your SQL database. We provide examples of
SQL syntax so you can learn SQL quickly. Our SQL tutorial is a great SQL
command reference.
Syntax:
Explanation:
Example:
Retrieve the vendor ID, name, and current balance for each
record:
Results:
Learning SQL
Learning SQL is easy. Our free online SQL tutorial teaches you the SQL
commands you need. We provide examples of SQL syntax so you can learn
SQL quickly. Our SQL tutorial is a great SQL command reference.
Formatting Numbers
Syntax:
Explanation:
9 Display number.
Example:
Retrieve the vendor ID, name, and current balance for all vendors.
Format the current balance:
Results:
VendId Name CurrBal
TV001 Wet Off Towels $13.13
TV002 The Games All Here $453.17
TV003 BedMakers Linen $500.00
TV004 Bed Room Furniture, Inc. $321.70
TV005 Ray Block $1,001.23
TV006 Mosquito No Bite $967.24
TV007 Spot Out $1,606.54
TV008 Big Tree Landscaping $342.98
TV009 Hit the Deck $23.45
TV010 The Soda Factory $0.00
TV011 The Freelance ($109.23)
TV012 Paper People $617.00
TV013 Softer Software $9,873.67
TV014 Counter Productive $42.89
TV015 No Waste Disposal $1,720.98
TV016 Music Maker $4,109.14
TV017 Food Four $642.98
TV018 Computer Bytes $345.09
TV019 Bayshore Consulting $498.05
TV020 BayCon Group $51.00
TV021 Cooperative Operatives $20.00
TV022 Legal Lookup $3,215.16
TV023 World Wide Learning U $771.06
TV024 Enterprise Transport $1,234.98
TV025 Against the Tide $64.72
TV026 Clampett Oil $0.00
TV027 Narrow Nest $1,609.00
TV028 Distant Horizons $26.98
TV029 Paltry Play $1,000.00
TV030 Make Shift Tilts $1,793.23
SQL Tutor
Looking for a SQL tutor? Our free online SQL tutorial teaches you SQL. We
provide examples of SQL syntax so you can learn SQL quickly. Our SQL
tutorial is also a great SQL command reference.
Ordering Rows
Syntax:
Explanation:
Example:
Retrieve the city, vendor Id, and name from the TrnVendor table.
Order your data by city:
Syntax:
Explanation:
Example:
Retrieve the city, vendor ID, and name from the TrnVendor table.
Order your data by city in descending order:
Results
When ordering your data, you can have multiple sort levels. For
example, you can order your data by city and then by name within
the city.
Syntax:
Explanation:
Example:
Retrieve the city, name, and vendor ID from the TrnVendor table.
Order your data by city and then by name within city:
So far, you have been retrieving all of the rows in the table. You
can, however, specify which rows you wish to retrieve. For
example, you could retrieve only those vendors who are in
Chicago.
Syntax:
Explanation:
Logical Operators
= Equal to
is null Is blank
Example:
where City = 'Chicago'
Examples:
Results:
Retrieve all vendors who are not located in Chicago. Order the
results by city.
Results:
Results:
Retrieve all vendors whose city ends with the letters "do."
1. In the SQL text box, type:
Results:
Retrieve all vendors with a current balance between 500 and 1000
dollars.
Results:
SQL Syntax
Need help with your SQL syntax? Our free online SQL tutorial provides
examples of SQL commands and SQL syntax. Bookmark our site, learn
SQL, and use our SQL tutorial as a SQL command reference.
Multiple Conditions
You can add multiple criteria to your Where clauses by using "and"
or "or."
Syntax:
Explanation:
Examples:
Results:
The next two SQL statements use exactly the same syntax except
that the order of precedence is different (note parentheses in
second example).
Results:
SQL Join
The SQL join command is used to join two or more tables. At times you
may need to join two or more tables to retrieve the information you need
from your SQL database. Our online SQL tutorial covers joining tables and
much more.
Joining Tables
So far, you have worked exclusively with a single table -- the TrnVendor table. You might have
noticed that each module within Solomon IV consists of several tables. Within the Accounts
Payable module, you will find the following tables: APAdjust, APDoc, APHist, APRefNbr, APSetup,
APTran, and Vendor. Each table contains specific information. At times, you might need to join
two or more tables to retrieve the information you need. For example, if you look at the TrnAPDoc
table, you will see that it contains the vendor ID; however, it does not contain the vendor name. If,
when retrieving information from the APDoc table, you want to see the vendor name, you have to
join the TrnVendor table to the TrnAPDoc table.
Syntax:
When you join two or more tables, a good idea is to precede the field names with the
table names. This is not mandatory unless the same field name is found in more than
one table.
If you precede the field name with a table name, place a period between the two
names. For example, tablename.fieldname.
You must specify which fields are being joined.
If you do not specify which fields are being joined, the result is what is commonly
referred to as a "Cartesian join" in which all rows in the first table are joined with all
rows in the second table.
You can give each table name an alias, or alternative table name. When you assign
an alias, you can then refer to the table by using its alias.
Examples:
Retrieve the vendor ID, the vendor name, and the original document amount from the TrnAPDoc
and TrnVendor tables.
Results:
Results:
Retrieve the vendor ID, vendor name, reference number, and original document amount from the
APDoc and Vendor tables for Vendor V00104. Order the results by RefNbr.
SQL Update
The SQL update command is used to change data in your SQL database. If
you are unsure of SQL syntax or you just need help with SQL commands,
this is the site. Our online tutorial covers many SQL commands.
Updating Tables
Syntax:
Start transaction;
Update tablename
set fieldname = value
where fieldname = value;
Rollback work;
Commit work;
Explanation:
Example:
Start transaction;
Update TrnVendor
Set Name = 'Genie R Corp.'
Where VendId = 'TV001';
Rollback work;
Update TrnVendor
Set Name = 'Vanix'
Where VendId = 'TV001';
Commit work;
Note: You can run multiple SQL statements at the same time, as in
the following example.
To run all of the SQL statements in the previous exercise, type all
of the commands in the SQL text box as shown here. Then click on
First to execute the first statement and Next to execute each
subsequent statement.
Start transaction;
Select VendId, Name
from TrnVendor
where VendId = 'TV001';
Update TrnVendor
Set Name = 'Genie R Corp.'
Where VendId = 'TV001';
Select VendId, Name
from TrnVendor
where VendId = 'TV001';
Rollback work;
Select VendId, Name
from TrnVendor
where VendId = 'TV001';
Update TrnVendor
Set Name = 'Vanix Corp.'
Where VendId = 'TV001';
Select VendId, Name
from TrnVendor
where VendId = 'TV001';
SQL Statement
Need help with your SQL statements? Our SQL tutorial provides the help
you need to learn SQL. It covers the create, import, retrieve, order, update,
delete, insert, and join SQL commands.
Deleting Rows
Syntax:
Explanation:
Examples:
Delete vendor TV011 by executing the following commands.
Select *
from TrnVendor
where VendId = 'TV011';
Start transaction;
Select *
from TrnVendor
where VendId = 'TV011';
Rollback work;
Rollback work;
SQL Insert
The SQL insert command is used to insert data into your SQL database.
Our SQL tutorial teaches you SQL commands. It covers the insert, create,
join,� import, retrieve, order, update, and delete commands.
Inserting Rows
You can insert new rows into a table by using Scalable SQL.
Syntax:
Explanation:
When inserting data, use the Start Transaction command so
that any errors can be rolled back.
You must specify the values to be inserted.
When performing an insert, enclose character values in
single quotes.
Do not enclose numeric values in single quotes.
Use the Rollback Work command to undo changes.
Use the Commit Work command to finalize changes.
Example:
Start transaction;
Rollback work;
Reference:
http://baycongroup.com/tocsql.htm