Business Solution-Navision ODBC
Business Solution-Navision ODBC
This material is for informational purposes only. Microsoft Business Solutions ApS
disclaims all warranties and conditions with regard to use of the material for other
purposes. Microsoft Business Solutions ApS shall not, at any time, be liable for any
special, direct, indirect or consequential damages, whether in an action of contract,
negligence or other action arising out of or in connection with the use or performance
of the material. Nothing herein should be construed as constituting any kind of
warranty.
COPYRIGHT NOTICE
Copyright © 2004 Microsoft Business Solutions ApS, Denmark. All rights reserved.
TRADEMARK NOTICE
DocID: NA-400-DVG-011-v01.00-W1W1
PREFACE
® ®
This book is a manual for Microsoft Business Solutions–Navision . This book is part
of a comprehensive set of documentation and Help materials for the Navision
enterprise business solution.
The manual describes how to install and run Microsoft Business Solutions–Navision
ODBC Driver 4.0. It also contains a reference guide to SQL statements.
You should also be familiar with the symbols and typographical conventions used in
the Navision manuals. In the list below, you can see how various elements of the
program are distinguished by special typefaces and symbols:
Appearance Element
Address Field names. They appear in bold and start with a capital
letter.
Hansen Text that you must enter, for example: "...enter Yes in
this field." It is written in italics.
fin.flf File names. They are written with the Courier font and
lowercase letters.
Chapter 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
What is the Navision ODBC Driver? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Navision ODBC functions largely in the same way as ordinary clients in Navision.
An explanation of how the Navision ODBC Driver works with a Navision database can
be found on page 13.
Special Terminology
There are a number of terms used in this book that are not used in Navision. The
following is a short explanation of these terms. If you need a more detailed
explanation, see the documentation for the product in which the term is used:
Visual Basic Microsoft Excel A programming language used for programming macros in
Microsoft Excel, among other things.
2
Chapter 2
Installation and Configuration
· Installation
· Configuration
Chapter 2. Installation and Configuration
2.1 INSTALLATION
To install the Navision ODBC Driver under Windows 2000, Windows XP or Windows
2003 Server, follow this procedure:
1 Start the Navision ODBC Driver setup program. You find this in the NODBC
subfolder on the Navision product CD.
The Welcome window appears. This is the first of three windows in a standard
Windows Installer wizard.
Cancelling the You can cancel the installation at any time. If you choose to cancel the installation, a
Installation dialog box appears asking you to confirm your decision. If you click No, the installation
process will continue. If you click Yes, Windows Installer will perform a full rollback and
restore the computer to the state it was in before the installation process began.
Uninstalling and You can also use Windows Installer to repair or remove the Navision ODBC Driver.
Repairing the
Navision ODBC 1 In the Control Panel, select Add/Remove Programs.
Driver
2 Select Microsoft® Business Solutions–Navision® ODBC Driver 4.0.
3 Click the Change button to change your installation of the Navision ODBC Driver, or
click the Remove button to remove the driver from your system.
Windows Installer will repair or remove the Navision ODBC Driver automatically,
depending on your choice.
4
2.2 Configuration
2.2 CONFIGURATION
After you have installed the driver, you can set up the sample data source that has
been created by the installation program, and you can add new data sources. This is
done from the Control Panel.
1 In the Control Panel, click Administrative Tools, Data Sources (ODBC). The
following window appears, displaying a list of the data sources that are available on
your system:
A data source contains information about where to find the data and how the driver
formats the data when it is returned to an application. Each data source is identified by
a unique name followed by the name of the driver. You can read about adding,
changing and deleting data sources on page 10, and the online Help for the ODBC
Data Source Adminstrator explains about User, System and File Data Sources.
5
Chapter 2. Installation and Configuration
2 Click Navision Database, and click Configure. The Navision ODBC Setup window
appears:
Field Comments
Data Source The field is already filled in with a default data source
name. You can change this name, as explained on page
10.
Database Name Enter the name of the database you want to connect to.
You can see a list of available databases by clicking
Database. Browse to the relevant folder, click the
database file name, and then click Open to copy the
name to the field.
6
2.2 Configuration
Field Comments
Company Name Enter the company name from which you want to retrieve
data. You can see a list of available company names by
clicking Company. Click the company name, and then
click OK to copy it to the field.
Windows Login Place a check mark in this field if you want to use your
Windows login to access the database. Using a Windows
login means that you do not have a separate user ID and
password.
User ID Enter the user ID that you use when logging in.
About... Opens the About dialog for the driver and displays your
license information (if a database and a company are
available),
Specifying Options
In the Navision ODBC Setup window, click the Options button to specify the data
source options. The Options box appears:
7
Chapter 2. Installation and Configuration
Field Comments
Identifiers In this field, select one of four options. The options in this
field and their implications are described in detail on page
9.
Option Field Type Click the AssistButton to select one of two ways that
option field values can be transferred:
DBMS Cache (KB) Enter the size of the cache (0–30,000 KB)
Enable BLOB Fields Specifies whether BLOB fields should be visible from
ODBC:
No Access is read/write.
(unchecked)
8
2.2 Configuration
Field Comments
Converting Identifiers
The option you select in the Identifiers field controls the way identifiers such as table
names and field names are transferred from Navision to an external program. The
choice you make affects the way you use identifiers in external programs and the way
you must write SQL statements. You can read about this on page 10.
Option Comments
All Except Dot Letters, numbers, symbols and spaces are transferred
unchanged. Dots and question marks are converted to
underscores (_).
EXAMPLE
This table shows how the names of the No., Sales (LCY), Profit % and Shelf/Bin No. fields from
the Item table are converted with the four different options:
9
Chapter 2. Installation and Configuration
and/or symbols in identifiers (this may differ from program to program). You specify
the kind of conversion that is necessary by choosing one of the options described in
the preceding table.
As an example, Microsoft Query does not support identifiers with dots (for example,
the No. field in many tables). To have Microsoft Query handle these names correctly,
use a data source with the All Except Dot option in the Identifiers field.
If you have chosen the All Characters, All Except Space or All Except Dot option in
the Identifiers field, you must use quoted identifiers, that is, include field names in
quotation marks. For example, if you have chosen the All Except Space option, the
Sales_(LCY) field name must be written as "Sales_(LCY)".
If you have chosen the a-z,A-Z,0-9,_ option, you do not have to use quoted identifiers.
2 In the ODBC Data Source Administrator window, click the User DSN tab and
then click Add.
2 Select the data source you want to change, and click Configure.
10
2.2 Configuration
3 Change the necessary fields in the Navision ODBC Setup window by typing or
selecting the new names or values.
2 Select the data source you want to delete, and click Remove.
11
Chapter 2. Installation and Configuration
12
Chapter 3
Technical Documentation
· Overview
· Establishing a Connection
· Navision ODBC Driver Functionality
· Data Types
· Multilanguage Functionality
Chapter 3. Technical Documentation
3.1 O VERVIEW
Open Database Connectivity (ODBC) is an interface defined by Microsoft Corporation
as a standard interface to database management systems in the Windows 2000,
Windows XP and Windows 2003 Server environments. Applications using the ODBC
interface can work with many different database systems.
The Navision ODBC Driver opens a Navision Database Server or local database to
ODBC-enabled applications so that they can retrieve data from and write data to the
database.
The Navision ODBC Driver operates in the Windows 2000, Windows XP and
Windows 2003 Server environments. In these environments, it can function either as a
stand-alone or as a client in a client/server configuration. You do not need to have a
Navision client installed to use the the Navision ODBC Driver.
Note that you cannot use the Navision ODBC Driver with the SQL Server Option for
Navision.
14
3.2 Establishing a Connection
Using C# When using C# to connect, you could use the following example:
Using Visual Basic The following is an example of how you could connect to a Navision ODBC data
.NET source when using Visual Basic .NET:
Using C++ The following gives an example of how you could connect to a Navision ODBC data
source when using C++:
SQLHENV henv;
SQLHDBC hdbc;
SQLHSTMT hstmt;
SQLRETURN retcode;
15
Chapter 3. Technical Documentation
16
3.3 Navision ODBC Driver Functionality
SQL Conformance
The Navision ODBC Driver is developed using ODBC version 2.5. The specification
for this version provides three levels of SQL grammar conformance: Minimum, Core,
and Extended. Each higher level provides more fully-implemented data definition and
data manipulation language support. ODBC version 2.5 fully supports the Minimum
SQL grammar, as well as many Core and Extended grammar statements. The
Navision ODBC Driver’s support for SQL grammar is summarized in the following
table.
Create Table o
Create View o
Delete (searched) o
Drop Index o
Drop Table o
Drop View o
Insert o
Select o
- between predicate o
- correlation name o
- date arithmetic o
- date literal o
- extended predicates o
- in predicate o
- set function o
- time literal o
- timestamp literal o
Subqueries o
Unions o
Update (searched) o
17
Chapter 3. Technical Documentation
SQLAllocConnect Core
SQLAllocEnv Core
SQLAllocStmt Core
SQLBindCol Core
SQLBindParameter Level 1
SQLBrowseConnect Level 2
SQLCancel Core
SQLColAttributes Core
SQLColumns Level 1
SQLColumnPrivileges Level 2
SQLConnect Core
SQLDataSources Level 2
SQLDescribeCol Core
SQLDescribeParam Level 2
SQLDisconnect Core
SQLDriverConnect Level 1
SQLDrivers Level 2
SQLError Core
SQLExecDirect Core
SQLExecute Core
SQLFetch Core
SQLForeignKeys Level 2
SQLFreeConnect Core
SQLFreeEnv Core
SQLFreeStmt Core
SQLGetConnectOption Level 1
SQLGetCursorName Core
18
3.3 Navision ODBC Driver Functionality
SQLAllocConnect Core
SQLGetData Level 1
SQLGetFunctions Level 1
SQLGetInfo Level 1
SQLGetStmtOption Level 1
SQLGetTypeInfo Level 1
SQLMoreResults Level 2
SQLNativeSql Level 2
SQLNumResultCols Core
SQLNumParams Level 2
SQLParamData Level 1
SQLPrepare Core
19
Chapter 3. Technical Documentation
BIGINTEGER SQL_VARCHAR
BINARY SQL_VARBINARY
BLOB SQL_LONGVARBINARY
BOOLEAN SQL_BIT
CODE SQL_VARCHAR
DATEFORMULA SQL_VARCHAR
DATETIME SQL_TIMESTAMP
DECIMAL SQL_DECIMAL
DURATION SQL_VARCHAR
GUID SQL_VARCHAR
INTEGER SQL_INTEGER
RECORDID SQL_VARCHAR
TABLEFILTER SQL_VARCHAR
TEXT SQL_VARCHAR
TIME SQL_TIME
When using the SQL statement CREATE TABLE, the Navision ODBC Driver supports
the following data types:
· Binary
· Boolean
· BLOB
· String
· Code
· BCD
· S32
· Date
· Time
· Timestamp
20
3.4 Data Types
The following rules apply to entering search conditions in the <whereclause> – see
page 33.
Navision Rules
Data Types
BIGINT Use this data type to store very large whole numbers. This data type
is a 64 bit integer. Note that the SQL data type is SQL_VARCHAR,
so you must enter data as a string using single quotes, for example
’123456789’.
OPTION If you have selected Text in the Option Field Type field in the
Options box in the Navision ODBC Setup window, then enter
option fields as the option string (in single quotes). If you have
selected Integer as the Option Field Type, then you should enter
option fields as the numerical option value. Thus, if the first option
string is Open, this value will be entered as Open if the Option
Field Type is Text, or as 0 (zero) if the Option Field Type is
Integer. Option strings in a set are numbered from 0 (zero)
upwards.
DATETIME Use this data type to store timestamps in this format: {ts ‘yyyy-mm-
dd hh:mm:ss’} where y=year, m=month, d=day, h=hour, m=minute
and s=second. The timestamp is always shown in local time.
DATETIME is always stored in the same format regardless of
closing date support.
DURATION Use this data type to represent the difference between two
datetimes, in milliseconds. This value can be negative. It is a 64 bit
integer, and you must enter data as a string using single quotes.
You can enter the data either as a number, such as ’122’, or as text,
such as ’2 min 2 sec’.
Note that the data type has a property Standard date time unit
where you can set the standard unit of measure. Navision ODBC
users must know this unit of measure if they enter data as a
number, since Navision interprets input such as 60 as 60
milliseconds, seconds, minutes, hours or days depending on the
standard date time unit.
The duration will always be displayed in a readable format such as
2 min, 2 sec rather than the number 122.
21
Chapter 3. Technical Documentation
Navision Rules
Data Types
GUID Use this data type to give a unique identification number to any
database object in this format: {’12345678-1234-1234-1234-
1234567890AB’}. Each character denotes a hexadecimal
character.
Comparison Operators
The Navision ODBC Driver uses the following comparison operators:
Operator Function
= Equals
Operator Precedence
An important property of an operator is its precedence. Precedence determines the
order in which the Navision ODBC Driver evaluates different operators in the same
expression. When evaluating an expression containing multiple operators, the driver
evaluates operators with higher precedence before those with lower precedence. The
driver evaluates operators with equal precedence from left to right within an
expression.
The following table lists the levels of precedence among SQL operators from high to
low. Operators listed on the same line have the same precedence.
4. EQ GE GT LE LT NE Right to left
22
3.4 Data Types
Numerical Values
A larger value is considered greater than a smaller one. All negative numbers are less
than all positive numbers. Thus,-1 is less than 100; -100 is less than -1.
Date Values
A later date is considered greater than an earlier one.
However, the Navision ODBC Driver supports closing dates.To support closing dates,
in the Navision ODBC Setup window, click Options and place a check mark in the
Closing Date field in the Options box that appears. When you have enabled closing
date support, you must enter data in a field with the DATE data type in the following
format: {ts '2001-01-01 23:59:59'}. The time part can hold one of two values:
23:59:59, which means a closing date, and 00:00:00, which means an ordinary
date. The default setting of the Closing Date option is disabled.
Note that even with the use of the SQL statement {ts '2001-01-01 23:59:59'},
fields with the DATE data type do not store time stamps. To store the actual time
stamp, use the DATETIME data type.
23
Chapter 3. Technical Documentation
24
3.5 Multilanguage Functionality
When you are running Navision ODBC and you open the ODBC Data Source
Administrator window from the operating system’s Control Panel, you can set up the
Navision ODBC Driver as described on page 5. Use the Language field properties to
set up the connection appropriate to the user.
C/SIDE uses the following hierarchy when showing the application data:
1 Global language
3 Application language
For more information about multilanguage functionality, see the manual Application
Designer’s Guide.
Specifications
The Navision ODBC Driver covers the following multilanguage features:
· Table name
· Field name
· OptionString value
When you link a table by selecting an application language other than the default
language and this language has a corresponding output from Navision, you will notice
that the value of the table name, all the field names, and the option fields within that
table are shown in the language you selected.
Limitations
You cannot use the Navision ODBC to create a table with multilanguage Caption
properties. This means that no matter what language has been chosen in the Options
box in the Navision ODBC Setup window, the table that is created for any Navision
ODBC application will use the Name property. No Caption property can be written to
the application database.
You will not be able to change the language choice in real-time mode. Navision ODBC
can only accept one setting at the time of loading. To switch the language when using
the Navision ODBC Driver, you must to close the Navision ODBC connection and
thereby release it from the memory, change to the preferred language in the Options
25
Chapter 3. Technical Documentation
box in the Navision ODBC Setup window, and start the Navision ODBC connection
again.
Scenarios
There are three different scenarios that are possible when running multilanguage for
the Navision ODBC Driver. In the following scenarios, the user has the following
settings:
Property Setting
Neutral
In the first scenario, the global language of the Navision application is English (United
Kingdom), and the Language field in the Navision ODBC Options box is set to
Neutral.
Navision ODBC The application data is retrieved and shown using the field and table names as they
Result are in their respective Name properties in Navision, and the multilanguage captions
are not used.
Navision ODBC The application data retrieved is shown in German (Austrian) if the selected objects
Result have multilanguage captions for the language code German (Austrian).
If the selected objects do not have multilanguage captions with the language code for
German (Austrian), the application data is shown in the code base language, English
(United States). If there is no caption in Navision for English (United States), the
Navision ODBC Driver uses the field and table names as they are defined in their
respective Name properties in Navision.
Specific Language
In this scenario, the global language of the Navision application is still English (United
Kingdom), but the Language field in the Navision ODBC Options box is set to
German (Austrian).
26
3.5 Multilanguage Functionality
Navision ODBC The application data retrieved is shown in German (Austrian) if the selected objects
Result have multilanguage captions for the language code for German (Austrian).
If the selected objects do not have multilanguage captions with the language code for
German (Austrian), the application data is shown using the field and table names as
they are defined in Navision.
27
Chapter 3. Technical Documentation
28
Appendix A
SQL Statement Reference Guide
Indicates that the statement syntax is continued from the previous line.
Denotes the repeat symbol. Terms enclosed within the repeat symbol may be
repeated any number of times with varying values.
A
B
C
Multiple choices for parameters are enclosed in boxes with horizontal lines. There will
be as many lines as there are choices.
A
B
Optional parameters are enclosed in lines descending from the main diagram line, as
shown in the diagram above. The statement is correct without the optional
parameters. If the parameter is not specified, an underscore indicates the default
value.
30
A.1 Introduction to the Reference Guide
Some complex diagrams have been broken up by grouping several parameters and
clauses by a specified name in the main diagram. This specified name is enclosed in
angle brackets (<>). Such complex statements are later represented using sub-unit
diagrams. A sub-unit diagram starts with
Uppercase letters denote keywords. Note that this convention is used only to make
the syntax diagrams easier to read: the SQL reserved words (keywords) are not case-
sensitive.
Notice that all the examples of SQL statements in this section are written assuming
that the driver has been set up with the a-z,A-Z,0-9,_ option in the Identifiers field (see
page 9).
Expressions
The following diagram illustrates how expressions are constructed in the Navision
ODBC Driver:
<expr>
_(_____<expr>_______)
<primary>
<expr> * <primary>
/
-
+
<primary>
<column name>
<number>
<date>
<time>
<string>
31
Appendix A. SQL Statement Reference Guide
Syntax
SELECT <select list> FROM <table list>
ALL <whereclause>
DISTINCT
<select list>
_,
_*
qualifier column name
expr
agg
General Rules
The SELECT statement retrieves data from one or more tables. It takes the tables
listed in the <tablelist> as input and produces an output table that includes only those
rows that satisfy the search condition specified in the <whereclause>.
By default, all rows that satisfy the search condition are included in the output table.
You can, however, prevent duplicate rows from being included by using the DISTINCT
keyword
Syntax Rules
qualifier: the name of a table or its alias, if one has been specified, in the FROM
clause. If only one table is specified, the qualifier is not needed.
expr: a field that contains an expression, with or without a column name. See page
23 for a diagram of expression syntax.
agg: an aggregate function. There are these aggregate functions: COUNT(* | expr),
AVG(expr), MAX(expr), MIN(expr), SUM(expr).
32
A.2 SELECT Statement
<tablelist> The <tablelist> lists the tables (and aliases) used in the SELECT
statement.
_,
table alias
table name
<search condition>
<predicate>
( - <search condition> - )
AND
<predicate>
<expr> BETWEEN lower limit AND upper limit
NOT
NOT
NOT
<expr> = <expr>
>=
<=
>
<
<>
Example
This example produces a list of customers whose balance is greater than or equal to
20000:
33
Appendix A. SQL Statement Reference Guide
Although this statement inserts a new item record, it is not a good solution for an item
entry application because the values to insert cannot be hard-coded in the application.
An alternative is to construct the SQL statement at run time using the values to be
inserted. This also is not a good solution because of the complexity of constructing
statements at run time.
The best solution, if the client application supports it, is to replace the elements of the
VALUES clause with question marks (?) or parameter markers:
The parameter markers are then bound to application variables. To add a new row,
the application has only to set the values of the variables and execute the statement.
The driver then retrieves the current values of the variables and sends them to the
data source.
· In a SELECT list
· As both expressions in a comparison-predicate
· As both operands of a binary operator
· As both the first and second operands of a BETWEEN operation
· As both the first and third operands of a BETWEEN operation
· As both the expression and the first value of an IN operation
· As the operand of a unary + or – operation
34
A.4 Predicates in WHERE Clauses
Syntax
<expr> BETWEEN lower limit AND upper limit
NOT
General Rules
The BETWEEN predicate checks a value against a range bounded by the lower and
upper limits. The condition is true if the value being checked is greater than or equal to
the lower limit and less than or equal to the upper limit. Each row for which this
condition is true is included in the result set. The value being compared should be
comparable with the lower and upper limits.
By using the logical operator NOT, you can test a value outside the specified range.
One important thing to remember about the BETWEEN predicate is the order of the
lower and upper limits. The lower limit must be less than or equal to the upper limit.
Syntax Rules
lower limit: the lower limit of the range that is being checked.
upper limit: the upper limit of the range that is being checked.
Example
This example retrieves all customers with a post code in the range of 1000 to 1234:
Syntax
<expr> IN ( <value list> )
NOT
General Rules
The IN predicate checks a value against a set of values for equality. The condition is
true if the value being compared matches any of the values in the value list. If you use
the logical operator NOT, the checking principle is reversed.
Syntax Rules
value list: a list of values against which a value is checked for equality.
35
Appendix A. SQL Statement Reference Guide
Example
This example retrieves all customers whose post code is 1000, 2000 or 3000:
Syntax
<expr> LIKE pattern
NOT
General Rules
The LIKE predicate compares a string type value with a pattern. The condition is true
if a match is found, false if it is not. Every row for which the condition is true is included
in the result set.
The pattern is any character pattern against which the value is compared, and it may
include some special characters. A percent sign (%) matches any number of
characters including zero characters in the same position.
If you want to include a percent sign in the search pattern, then enter a backslash (\)
before it to remove its special meaning. For example, \\ represents the backslash
itself.
Syntax Rules
pattern: the string against which a value is compared.
Example
This example retrieves all customers whose name contains Hansen:
36
A.5 GROUP BY Clause
Syntax
,
General Rules
The GROUP BY clause groups the selected rows of data according to values in the
group column referred to by the column name. This produces an output that contains
one row for each distinct value in the group column.
When you use the GROUP BY clause, the value expression list in the SELECT
statement can only contain group columns, expressions containing group columns
and aggregate functions. Otherwise, an error will occur.
If you specify multiple columns, the selected rows will be grouped first according to the
first group column and within that grouping according to the second group column.
See page 32 for a list of the aggregate functions that are available. In all of the
aggregate functions, the value expression can be quantified by a quantifier that can be
either DISTINCT or ALL. The default is ALL, which means that all values of the value
expression for all rows in the group should be considered. If the quantifier is
DISTINCT, only distinct values of the value expression in the rows of the group are
considered for computing the value of the function.
Syntax Rules
column name: the name of the column on which rows will be grouped.
Example
This example retrieves the number of customers per country. We join the Customer
and the Country tables in order to get the names of the countries instead of the
country codes:
37
Appendix A. SQL Statement Reference Guide
Syntax
General Rules
The HAVING clause makes it possible to specify conditions on grouped data so as to
eliminate some of them and include the rest in the output.
There is an important difference between the HAVING and the WHERE clauses. The
WHERE clause filters rows before they are passed on to the GROUP BY clause. The
HAVING clause filters the output of the GROUP BY clause, and you can use
aggregate functions in the HAVING clause.
Syntax Rules
search condition: refers to the search condition that you may specify on grouped
rows so as to include them selectively in the output. See page 33 for a description of
search conditions.
Example
This example retrieves the name and balance of all customers with a balance that is
greater than 5000 and sorts the list by balance. This statement could be rewritten
using WHERE.
This example retrieves information from the Sales Invoice Header table. It produces
a list of customers and the average, maximum and minimum amounts of their sales
invoices, but only if there is more than one invoice for the customer. This statement
could not be rewritten using WHERE.
38
A.7 ORDER BY Clause
Syntax
_,
DESC
General Rules
The ORDER BY clause sorts the output of a query in the desired order. By default,
rows are sorted in ascending order of values. To reverse the order of the sort, use the
keyword DESC.
You can sort the output of a query by sorting multiple columns. In this case, the output
is first sorted by the values in the first column. Within each distinct value in the first
column, the rows are sorted by the values in the second column, and so on. When
sorting rows based on multiple columns, each column can be assigned its own sorting
order with ASC or DESC.
Syntax Rules
column name: the column in which the data will be sorted.
Example
This example retrieves all customers sorted by post code and name:
39
Appendix A. SQL Statement Reference Guide
Syntax
INSERT tablename <insertvals>
INTO
<insertvals> ,
VALUES ( value )
columnlist
General Rules
The INSERT statement inserts data into a table. If you are inserting data in only some
of the columns in the table, you must explicitly mention these column names in the
INSERT statement. If you do not provide a column list explicitly, the INSERT
statement will try to insert values in all columns of the table.
There should be as many data values as there are columns in the table or the column
list and the corresponding data types should match. If they do not, an error will be
reported and no values will be inserted.
You can insert explicit data values one row at a time using the VALUES clause. Each
data value should be separated from the next by a comma.
You can only insert records in tables where your license gives you permission to
insert. You cannot insert into a virtual table.
You should be aware that triggers are not run when you insert records through the
Navision ODBC Driver.
Syntax Rules
tablename: name of the table into which you are inserting rows.
columnlist: a list of columns in the table into which you are inserting data values.
The column names must be separated by commas.
value: refers to a data value that is being inserted into a column. When specifying a
data value, follow these conventions:
40
A.8 INSERT Statement
Example
This example inserts a record in the Country table. The column list contains only two
of the columns of the table. The rest of the columns will be inserted as default values.
41
Appendix A. SQL Statement Reference Guide
Syntax
DELETE FROM tablename
WHERE <search condition>
General Rules
The DELETE statement deletes rows from a table. If no conditions are specified, all
rows in the table will be deleted.
You can optionally specify a WHERE clause to select the rows from the table for
deletion. The WHERE clause can specify any valid search condition that selects the
rows. You can select the WHERE clause in the same way as you do in a SELECT
statement.
You can only delete records in tables where your license gives you permission to
delete. You cannot delete from a virtual table.
You should be aware that triggers are not run when you delete records through the
Navision ODBC Driver.
Syntax Rules
tablename: name of the table from which you are deleting rows.
search condition: this refers to a condition for choosing rows for deletion from the
named table. You may specify any valid condition that you can use in the WHERE
clause of a select statement (see page 32).
Example
This example deletes all rows from the Customer table:
42
A.10 UPDATE Statement
Syntax
________,________
UPDATE tablename SET columnname = value
General Rules
The UPDATE statement updates data in a table. If no conditions are specified, all
rows in the table are updated.
Set values into the columns to be updated by using the SET clause. The left-hand side
of the SET clause must be a column in the table being updated. The right-hand side
must contain a data value that can be assigned to the column.
You can optionally specify a WHERE clause to select the rows from the table for
update. The WHERE clause can specify any valid search condition that selects the
rows.
You can only update records in tables where your license gives you permission to
update. You cannot update in a virtual table.
You should be aware that triggers are not run when you update records through the
Navision ODBC Driver.
Syntax Rules
tablename: name of the table in which you are updating rows.
columnname: this refers to the name of the column in the table whose data is being
updated.
search condition: this refers to a condition for choosing rows for updating from the
named table. You may specify any valid condition that you can use in the WHERE
clause of a select statement (see page 32).
Examples
This example updates the Unit Price field in all records of the Item table:
This example updates the Country Code field in selected records of the Customer
table:
43
Appendix A. SQL Statement Reference Guide
Syntax
,
CREATE TABLE tablename ( <column definition> )
<column definition>
General Rules
The CREATE TABLE statement creates a table in the database.
You can define the columns of the table by specifying a column name and its data
type. The data types that are supported are shown in the syntax rules below. Some of
the data types optionally take one numeric argument. In the case of character data
types, the length of the column can be specified. In its absence, a default value of one
(1) is assumed. The length specifies the maximum length of the string data that can be
stored in the column (the declared length in C/SIDE® ).
When a table is created, the Navision ODBC Driver generates a table number
automatically. You must have the necessary permissions to insert tables, and there
must be free table numbers in the database. The range 49,999 – 99,999 is used, with
allocation starting from the top.
Syntax Rules
tablename: name of the table you wish to create. A table name can be up to 30
characters long, and it must be unique within a database. A table number will be
generated automatically.
columnname: name of the column (field) being defined. A column name can be 30
characters long, and it must be unique within the table. A field number will be
generated automatically.
data type: the data type of the column (field) being defined. The following table
shows the relationship between the data types you can use in the Navision ODBC
Driver and the C/SIDE data types.
BCD Decimal
BLOB BLOB
BOOL Boolean
DATE Date
44
A.11 CREATE TABLE Statement
TIMESTAMP DateTime
S32 Integer
TIME Time
Example
This example creates a table with three fields: an Integer, a Decimal and a Text field:
45
Appendix A. SQL Statement Reference Guide
Syntax
DROP TABLE tablename
General Rules
The DROP TABLE statement drops the named table from the database. When a table
is dropped (deleted), all data in the table is lost.
You must have the necessary permissions in order to drop (delete) a table.
Syntax Rules
tablename: name of the table to drop.
Example
The following example drops (deletes) the table named "Sample" from the database:
46
A.13 Navision FlowFields
The data type of a FlowFilter is always SQL_VARCHAR (string). The syntax of the
FlowFilter is specific to Navision.
The section in brackets is called the extended predicate. The following example
shows how to set a FlowFilter on the Customer Filter field in the Currency table.
SetFlowFilter is the name of the extended predicate, Currency is the table containing
the filter, and Customer_Filter is the field being filtered. The expression ’10000..40000’
is the filter that will be set on the Customer Filter field in the Currency table.
This SELECT statement returns all the records in the table because the first condition
in the WHERE clause, {pred SetFlowFilter, 'Currency',
'Customer_Filter', '10000..40000'}, is always TRUE. The OR operator has
no effect.
This will return all records where the the customer number falls within the filter and
where Last Date Modified is greater than 01.01.04.
47
Appendix A. SQL Statement Reference Guide
48
INDEX
Symbols sample . . . . . . . . . . . . . . . . . . . . . . . . 4
% sign . . . . . . . . . . . . . . . . . . . . . . . . 9, 36 setting up . . . . . . . . . . . . . . . . . . . . . . 5
Data Source (field) . . . . . . . . . . . . . . . . . 6
A data type
ADD SUB (operator) . . . . . . . . . . . . . . . 22 BIGINT . . . . . . . . . . . . . . . . . . . . . . . 20
add-in . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 BINARY . . . . . . . . . . . . . . . . . . . . . . . 20
aggregate function . . . . . . . . . . . . . . . . 32 BOOLEAN . . . . . . . . . . . . . . . . . . . . . 20
All Characters (menu option) . . . . . . . . . 9 CODE . . . . . . . . . . . . . . . . . . . . . . . . 20
All Except Dot (menu option) . . . . . . . . . 9 DATE . . . . . . . . . . . . . . . . . . . . . . . . 20
All Except Space (menu option) . . . . . . . 9 DATEFORMULA . . . . . . . . . . . . . . . . 20
AND (operator) . . . . . . . . . . . . . . . . 22, 23 DATETIME . . . . . . . . . . . . . . . . . . . . 20
AS (keyword) . . . . . . . . . . . . . . . . . . . . 33 DECIMAL . . . . . . . . . . . . . . . . . . . . . 20
ASC (keyword) . . . . . . . . . . . . . . . . . . . 39 DURATION . . . . . . . . . . . . . . . . . . . . 20
Auto (Windows Language) . . . . . . . . 8, 26 GUID . . . . . . . . . . . . . . . . . . . . . . . . . 20
available data sources . . . . . . . . . . . . . . 5 INTEGER . . . . . . . . . . . . . . . . . . . . . 20
a-z,A-Z,0-9,_ (menu option) . . . . . . . . . . 9 OPTION . . . . . . . . . . . . . . . . . . . . . . 20
SQL_BINARY . . . . . . . . . . . . . . . . . . 20
B
SQL_DATE . . . . . . . . . . . . . . . . . . . . 20
backslash . . . . . . . . . . . . . . . . . . . . . . . 36
SQL_INTEGER . . . . . . . . . . . . . . . . . 20
BETWEEN predicate . . . . . . . . . . . . . . 35
SQL_TIME . . . . . . . . . . . . . . . . . . . . 20
BLOB . . . . . . . . . . . . . . . . . . . . . . . . . . 20
SQL_TIMESTAMP . . . . . . . . . . . . . . 20
C SQL_VARCHAR . . . . . . . . . . . . . . . . 20
C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 TEXT . . . . . . . . . . . . . . . . . . . . . . . . . 20
C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 TIME . . . . . . . . . . . . . . . . . . . . . . . . . 20
character values . . . . . . . . . . . . . . . . . . 23 database
clause name . . . . . . . . . . . . . . . . . . . . . . . . . . 6
FROM . . . . . . . . . . . . . . . . . . . . . . . . 32 Database Name (field) . . . . . . . . . . . . . . 6
GROUP BY . . . . . . . . . . . . . . . . . . . . 37 DBMS Cache (KB) (field) . . . . . . . . . . . . 8
HAVING . . . . . . . . . . . . . . . . . . . . . . 38 decimals . . . . . . . . . . . . . . . . . . . . . . . . 22
ORDER BY . . . . . . . . . . . . . . . . . . . . 39 DELETE statement . . . . . . . . . . . . . . . . 42
SET . . . . . . . . . . . . . . . . . . . . . . . . . . 43 DESC (keyword) . . . . . . . . . . . . . . . . . . 39
WHERE . . . . . . . . . . . . . . . . . 35, 36, 47 Description (field) . . . . . . . . . . . . . . . . . . 6
client . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 drop down list . . . . . . . . . . . . . . . . . . . . . 8
client/server . . . . . . . . . . . . . . . . . . . 6, 14 DROP TABLE statement . . . . . . . . . . . 46
closing date support . . . . . . . . . . . . . 9, 23
E
Company Name (field) . . . . . . . . . . . . . . 7
environment . . . . . . . . . . . . . . . . . . . . . 14
comparison
EQ (operator) . . . . . . . . . . . . . . . . . . . . 22
operators . . . . . . . . . . . . . . . . . . . . . . 22
evaluate . . . . . . . . . . . . . . . . . . . . . . . . 22
rules . . . . . . . . . . . . . . . . . . . . . . . . . 23
expression . . . . . . . . . . . . . . . . . . . . . . 22
configuration . . . . . . . . . . . . . . . . . . . . . . 5
extended predicate . . . . . . . . . . . . . . . . 47
Connection (field) . . . . . . . . . . . . . . . . . . 6
Control Panel . . . . . . . . . . . . . . . . . . . . 11
F
CREATE TABLE statement . . . . . . . . . 44 filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 FlowField . . . . . . . . . . . . . . . . . . . . . . . 47
FlowFilter . . . . . . . . . . . . . . . . . . . . . . . 47
D
FROM clause . . . . . . . . . . . . . . . . . . . . 32
data source
adding . . . . . . . . . . . . . . . . . . . . . . . . 10
G
available . . . . . . . . . . . . . . . . . . . . . . . 5 GE (operator) . . . . . . . . . . . . . . . . . . . . 22
changing . . . . . . . . . . . . . . . . . . . . . . 10 GROUP BY clause . . . . . . . . . . . . . . . . 37
deleting . . . . . . . . . . . . . . . . . . . . . . . 11 GT (operator) . . . . . . . . . . . . . . . . . . . . 22
modifying . . . . . . . . . . . . . . . . . . . . . . . 5
name . . . . . . . . . . . . . . . . . . . . . . . . . . 5 H
new . . . . . . . . . . . . . . . . . . . . . . . . . . 10 HAVING clause . . . . . . . . . . . . . . . . . . 38
Index
I LE . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 LT . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
identifier MUL DIV . . . . . . . . . . . . . . . . . . . . . . 22
quoted . . . . . . . . . . . . . . . . . . . . . . . . 10 NE . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
space in . . . . . . . . . . . . . . . . . . . . . . . 10 OR . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
symbol in . . . . . . . . . . . . . . . . . . . . . . 10 operator precedence . . . . . . . . . . . . . . 22
transfer . . . . . . . . . . . . . . . . . . . . . . . . 9 Option (field) . . . . . . . . . . . . . . . . . . . . . . 8
Import License (button) . . . . . . . . . . . . . . 7 optional parameter . . . . . . . . . . . . . . . . 30
IN predicate . . . . . . . . . . . . . . . . . . . . . 35 OR (operator) . . . . . . . . . . . . . . . . . . . . 47
INSERT . . . . . . . . . . . . . . . . . . . . . . . . 40 ORDER BY clause . . . . . . . . . . . . . . . . 39
insert
triggers . . . . . . . . . . . . . . . . . 40, 42, 43 P
Installation of Navision ODBC . . . . . . . . 4 parentheses . . . . . . . . . . . . . . . . . . . . . 23
Integer (menu option) . . . . . . . . . . . . . . . 8 Password (field) . . . . . . . . . . . . . . . . . . . 7
interface . . . . . . . . . . . . . . . . . . . . . . . . 14 percent sign (%) . . . . . . . . . . . . . . . . . . 36
precision . . . . . . . . . . . . . . . . . . . . . . . . 22
K predicate
keyword BETWEEN . . . . . . . . . . . . . . . . . . . . 35
ASC . . . . . . . . . . . . . . . . . . . . . . . . . . 39 IN . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
DESC . . . . . . . . . . . . . . . . . . . . . . . . 39 LIKE . . . . . . . . . . . . . . . . . . . . . . . . . 36
DISTINCT . . . . . . . . . . . . . . . . . . . . . 32 predicate, extended . . . . . . . . . . . . . . . 47
L Q
language . . . . . . . . . . . . . . . . . . . . . . . . 26 quoted identifiers . . . . . . . . . . . . . . . . . 10
Language (field) . . . . . . . . . . . . . . . . . . . 8
LE (operator) . . . . . . . . . . . . . . . . . . . . 22 R
LIKE predicate . . . . . . . . . . . . . . . . . . . 36 RECORDID . . . . . . . . . . . . . . . . . . . . . 20
Local (setup) . . . . . . . . . . . . . . . . . . . . . . 6
logging in . . . . . . . . . . . . . . . . . . . . . . . . 7 S
LT (operator) . . . . . . . . . . . . . . . . . . . . . 22 sample data source . . . . . . . . . . . . . . . . 4
security . . . . . . . . . . . . . . . . . . . . . . . . . . 7
M SELECT statement . . . . . . . . . . . . . 32, 36
macro . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 server . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Microsoft Excel . . . . . . . . . . . . . . . . . . . . 2 Server (setup) . . . . . . . . . . . . . . . . . . . . . 6
Microsoft Query . . . . . . . . . . . . . . . . 2, 10 Server Name (field) . . . . . . . . . . . . . . . . 6
MUL DIV (operator) . . . . . . . . . . . . . . . 22 SET clause . . . . . . . . . . . . . . . . . . . . . . 43
multilanguage . . . . . . . . . . . . . . . . . . 8, 25 setup . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
multiuser . . . . . . . . . . . . . . . . . . . . . . . . . 6 sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
single-user . . . . . . . . . . . . . . . . . . . . . . . 6
N spreadsheet . . . . . . . . . . . . . . . . . . . . . . 2
name SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
company . . . . . . . . . . . . . . . . . . . . . . . 7 writing statements . . . . . . . . . . . . . . . 10
database . . . . . . . . . . . . . . . . . . . . . . . 6 SQL_DECIMAL . . . . . . . . . . . . . . . . . . 20
server . . . . . . . . . . . . . . . . . . . . . . . . . 6 SQL_VARCHAR . . . . . . . . . . . . . . . . . . 47
NE (operator) . . . . . . . . . . . . . . . . . . . . 22 statement
Net Type (field) . . . . . . . . . . . . . . . . . . . . 6 CREATE TABLE . . . . . . . . . . . . . . . . 44
network program . . . . . . . . . . . . . . . . . . . 6 DELETE . . . . . . . . . . . . . . . . . . . . . . 42
Neutral . . . . . . . . . . . . . . . . . . . . . . . . . . 8 DROP TABLE . . . . . . . . . . . . . . . . . . 46
non-padded . . . . . . . . . . . . . . . . . . . . . 23 INSERT . . . . . . . . . . . . . . . . . . . . . . . 40
SELECT . . . . . . . . . . . . . . . . . . . . . . 32
O UPDATE . . . . . . . . . . . . . . . . . . . . . . 43
Open DataBase Connectivity . . . . . . . . . 2
operator T
( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 TABLEFILTER . . . . . . . . . . . . . . . . . . . 20
ADD SUB . . . . . . . . . . . . . . . . . . . . . 22 Text (menu option) . . . . . . . . . . . . . . . . . 8
AND . . . . . . . . . . . . . . . . . . . . . . . . . 22 text string . . . . . . . . . . . . . . . . . . . . . . . . 8
EQ . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 triggers during insert . . . . . . . . . 40, 42, 43
GE . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
GT . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Index
U
UPDATE statement . . . . . . . . . . . . . . . 43
User ID . . . . . . . . . . . . . . . . . . . . . . . . . . 7
User ID (field) . . . . . . . . . . . . . . . . . . . . . 7
V
Visual Basic . . . . . . . . . . . . . . . . . . . . . . 2
Visual Basic .NET . . . . . . . . . . . . . . . . . 15
W
WHERE clause . . . . . . . . . . 35, 36, 39, 47
word processor . . . . . . . . . . . . . . . . . . . . 2
Index