You can check the database FAQ for answers to your DB2® and Structured Query Language (SQL) questions. Topics in the FAQ include finding informative database resources, data sharing and migration, and several query topics.
DB2 UDB for iSeries is the relational database manager that is fully integrated on your iSeries server. Because it is integrated, DB2 UDB for iSeries is easy to use and manage. DB2 UDB for iSeries also provides functions such as triggers, stored procedures, and dynamic bitmapped indexing that serve a wide variety of application types. These applications range from traditional host-based applications to client/server solutions to business intelligence applications.
The history of DB2 UDB for iSeries began in the late 1980s with the integration of a fully relational, though nameless, database on the first AS/400® systems. In 1995, this database joined the DB2 brand, adopting the name DB2/400. In 1999, the DB2 UDB branding was added.
As an interface to DB2 UDB for iSeries, the DB2 Query Manager and SQL Development Kit for iSeries adds an interactive query and report writing interface, as well as precompilers and tools to assist in writing SQL application programs in high-level programming languages. Conforming to the industry standard SQL, the SQL implementation for i5/OS allows you to define, manipulate, query, and control access to your iSeries data. It works equally well with i5/OS files and SQL tables.
Yes. DB2 UDB for iSeries is the newest member of the DB2 UDB product line, which also includes DB2 UDB and DB2 Universal Database™ for zSeries®. DB2 UDB, the founding member of the product line, is the single product available across all UNIX®, Windows NT®, and OS/2® operating systems.
Each member of the DB2 UDB product line has its own unique code-base, functions, and different SQL syntax. There is, however, technology sharing across the DB2 UDB brand members. To learn about the relationships between the DB2 UDB products, see the following information:
If you are using an iSeries server, you have DB2 UDB for iSeries. The level of DB2 UDB for iSeries is based on the i5/OS operating system, and is independent of the DB2 versioning scheme. Because DB2 UDB for iSeries is included with the i5/OS operating system, the version, release, and modification level of DB2 is the same as that of your operating system. This is typically expressed as VxRyMz, where x is the version, y is the release, and m is the modification. If you do not know what version, release, and modification of i5/OS you have, use the following steps:
Yes. You can find the sample tables and the system-provided stored procedure to create them in DB2 UDB for iSeries sample tables of the SQL programming topic.
You don't need to install DB2. It is shipped as a part of i5/OS at every release.
DB2 object access can be controlled using SQL GRANT and REVOKE statements along with i5/OS security interfaces. See Secure a database in the Database programming topic. iSeries Navigator can also be used to authorize users. For more information, see Authorize a user or group using iSeries Navigator.
You can administer DB2 UDB for iSeries using iSeries Navigator. Within iSeries Navigator there is a tool for working with databases. You can work either from a traditional tree view of you database, or from a visual representation of the database objects called Database Navigator. For details about using Database Navigator, see Map your database using Database Navigator maps.
Yes. See Co-existing with "long" SQL table and column names for instructions.
The Softcopy Library was integrated into the iSeries Information Center in V5R1. You can find database manuals by following the (PDFs) link in the information center navigation bar under the Database topic.
It is recommended that you save PDF files locally for ease in viewing and printing. To save the PDF, follow these steps:
See the Frequently asked questions about the information center topic. This FAQ contains tips that make using the information center easier. You can also find help by clicking the help button in the upper right of your screen.
You can use the Copy From Import File (CPYFRMIMPF) and Copy To Import File (CPYTOIMPF) commands to import (load) or export (unload) data from and to the iSeries server. See the Import and export data between systems topic for instructions.
IBM provides several guides to help you move data into DB2 UDB for iSeries from other databases, such as Oracle and SQL Server. See DB2 Porting Information for the guides.
Yes. See the XML Extender Administration and Programming manual for tutorials on how to set up a database using provided sample data, how to map SQL data to an XML document, how to store XML documents in the database, and how to search and extract data from the XML documents.
Yes. You can learn more in User FAQs of the Distributed database programming topic.
You can follow these steps to produce a report of all the queries containing the file name:
The graphical query interface software provided for iSeries includes DB2 Query Management Facility and DB2 Web Query Tool.
You can join two members of the same table by creating an alias for one of the members and joining them using the alias. To create an alias using SQL, see the Create and use ALIAS names or Create database objects topic.
You can run SQL statements from a text file using the Run SQL Statements (RUNSQLSTM) command. Or, you can use Run SQL Scripts from iSeries Navigator to run a text file on your PC or in the integrated file system. See Query your database using the Run SQL Scripts interface.
SELECT 'ITEM' AS ROWTYPE, PARTID, PRICE FROM PART UNION SELECT 'TOTAL' AS ROWTYPE, 0 AS PARTID, SUM( PRICE ) AS PRICE FROM PART ORDER BY ROWTYPE, PARTID
To make sure that the total row is at the end of the result set, you must include the Order By clause.
The SQL CurDate function returns a date value, which cannot be directly compared to a number or an unformatted character value. You must do some conversion before the comparison. Use SQL functions to get the year, month, and day of the date as integers, and then create a numeric date in the form YYYYMMDD. See the code in Example: Select records based on the current date.
There can be some query performance problems if you recently upgraded from V4R4 to a newer release or version. See IBM DB2 UDB Query Performance Behavior Changes Since R440 for a possible solution.
No. When you create an alias, make sure that the table, view, or physical file you create it for is on the current server. For more information, see CREATE ALIAS, with some syntax examples.
You can create an alias to point at the first member you want to access.
CREATE ALIAS SALES_JANUARY FOR SALES(JANUARY)For the complete example in the SQL reference, see CREATE ALIAS.
SQL messages are displayed when a DB2 UDB for iSeries returns an error or code to the application that uses it. The message text is displayed or logged at run time.
SQL0901: An SQL system error has occurred. This is the general message for all errors. For more information about SQL0901, see the SQL messages and codes topic.
You can find a complete list of SQL messages and codes in the SQL messages and codes topic. Or use SQL message finder.
An application can also send the SQL message corresponding to any SQLCODE to the job log by specifying the message ID and the replacement text on the CL commands Retrieve Message (RTVMSG), Send Program Message (SNDPGMMSG), and Send User Message (SNDUSRMSG).
SQL packages are permanent objects that are used to store information related to prepared SQL statements. They are used by open database connectivity (ODBC) support when the Extended Dynamic box is checked on a data source. They are also used by applications that use an API.
Because SQL packages are a shared resource, when a statement is prepared, the information is available to all the users of the package. This saves processing time, especially in an environment when many users are using the same or similar statements. Because SQL packages are permanent, this information is also saved across job initiation and end, and is also saved across system restarts. In fact, SQL packages can be saved and restored on other systems. By comparison, dynamic SQL requires that each user go through the preparatory processing for a particular statement, and this must be done every time the user starts the application.
SQL packages also allow the system to accumulate statistical information about the SQL statements that result in better decisions about how long to keep cursors open internally and how to best process the data needed for the query. This information is shared across users and retained for future use. In the case of dynamic SQL, this information must be gathered by every job and every user.
The SQL package contains all the necessary information to run the prepared statement. This includes registry of the statement name, the statement text, the internal parse tree for the statement, definitions of all the tables and fields involved in the statement, and the query access plan needed to access the tables at run time.
Use the Print SQL Information (PRTSQLINF) command to produce a formatted report that shows the SQL statement and information about the access plan used to access the data.
SELECT qqc103, qqc21, qq1000 from <db monitor file>
For ODBC, you can also look in the job log for the message Extended Dynamic has been disabled to determine if ODBC was unable to use an SQL package.
For more SQL package FAQs, see the DB2 Universal Database for iSeries Frequently Asked Questions: Improving Performance with SQL Packages.
Use Run SQL Scripts to run the procedure in iSeries Navigator. First, open the Run SQL Scripts window. Then, call the stored procedure using the CALL statement, pass the parameters to the statement, and then run the procedure. The parameters are returned to the Result Set tab, and the output parameters are returned to the Messages tab.
Yes. DB2 UDB for iSeries supports external stored procedures, which allows existing high-level programs to be called as stored procedures. The CREATE PROCEDURE statement is used to register these programs as stored procedures.
The SET PATH statement must be done before the CREATE PROCEDURE statement. The path for static statements in a precompiled program is determined when the program is created. In the case of CREATE PROCEDURE, we create an SQL C program. Dynamic statements in the procedure use the current path, but the static statements in the procedure use the path that was used at the time of creation. This is also true for the CREATE FUNCTION statement.
SELECT * from sysprocs where routine_name = 'MYPROC' and routine_schema = 'MYLIB'This checks to see if there is a stored procedure named myproc in mylib. If you do not know the library, do not include the routine_schema part of the search condition in the query. See iSeries catalog tables and views in the SQL reference topic for the definition of all the columns for the SYSPROCS catalog. You might also be interested in the SYSPARMS catalog, which contains the parameter definitions for a procedure.
A trigger is a set of actions that are run automatically when a specified change or read operation is performed on a specified table or on a specified physical database file. For more information, see Trigger automatic events in your database.
Beginning in V5R1, you can also use SQL triggers. The SQL CREATE TRIGGER statement provides a way for the database management system to actively control, monitor, and manage a group of tables whenever an insert, update, or delete operation is performed. The statements specified in the SQL trigger are run each time an SQL insert, update, or delete operation is performed. An SQL trigger can call stored procedures or user-defined functions to perform additional processing when the trigger is run. For more information, see SQL triggers.
The offset of your record might have changed. For several releases in the past, the offset did not change. It did, however, change for V5R1 and might change in subsequent releases. The easiest solution is to always code your trigger programs to use the offsets and lengths passed in the trigger buffer. For a summary of fields in the trigger buffer, see Trigger buffer field descriptions.