Developer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
InterBase 6 Developer’s Guide Borland/INPRISE 100 Enterprise Way, Scotts Valley, CA 95066 http://www.interbase.com Inprise/Borland may have patents and/or pending patent applications covering subject matter in this document. The furnishing of this document does not convey any license to these patents. Copyright 1999 Inprise/Borland. All rights reserved. All InterBase products are trademarks or registered trademarks of Inprise/Borland. All Borland products are trademarks or registered trademarks of Inprise/Borland. Other brand and product names are trademarks or registered trademarks of their respective holders. 1INT0050WW21003 6E1R0699 Table of Contents List of Tables.....................................xv List of Figures....................................xvii CHAPTER 1 Using the InterBase Developer’s Guide Who should use this book .....................19 Topics covered in this book .....................20 CHAPTER 2 Client/Server Concepts Definition of a client ........................23 The InterBase client library ....................24 Definition of a server ........................25 Application development ......................26 Borland client tools applications ............... 26 Embedded applications .................... 27 API applications ........................ 28 Multi-database applications .................. 29 CHAPTER 3 Programming Applications with Delphi or C++ Builder Optimizing the InterBase SQL Links driver ............32 Setting the driver flags .................... 32 Setting the SQL pass-through mode ............. 33 Setting the SQL query mode ................. 33 Working with TTable and TQuery .................33 Setting TQuery properties and methods........... 33 Using generators ...........................34 CHAPTER 4 Programming Applications with JBuilder Installing InterClient classes into JBuilder ............38 Database application basics.................. 38 Using JDBC URLs........................ 40 Installing and administering InterServer .............41 Starting InterServer on Windows NT and 95 ........ 41 DEVELOPER’S GUIDE iii Shutting down InterServer .................. 42 Viewing InterServer information and properties ...... 42 Programming with InterClient ...................43 InterClient architecture .................... 43 InterClient communication .................. 44 Developing InterClient programs .................45 Using the JDBC interfaces................... 45 About InterClient drivers ................... 47 Accessing InterClient extensions to the JDBC........ 50 Opening a database connection ............... 50 Executing SQL statements................... 53 Executing stored procedures ................. 59 Troubleshooting InterClient programs ..............61 Handling installation problems................ 61 Debugging your application ................. 61 Deploying InterClient programs ..................62 Deploying InterClient programs as applets ......... 62 Deploying InterClient programs as applications ...... 65 InterClient/JDBC compliance specifications ...........66 InterClient extensions to the JDBC API ........... 66 JDBC features not implemented in InterClient ....... 67 InterClient implementation of JDBC features ........ 68 InterBase features not available through InterClient or JDBC ................. 69 Java SQL datatype support .................. 70 SQL-to-Java type conversions ................. 70 Java-to-SQL type conversion ................. 71 InterClient class references .................. 72 CHAPTER 5 Programming Applications with ODBC Overview of ODBC ..........................73 Programming with the ODBC driver ...............74 Configuring and using ODBC data sources ............74 Configuring data sources ................... 74 iv INTERBASE 6 TABLE OF CONTENTS CHAPTER 6 Working with UDFs and Blob Filters About UDFs ..............................76 UDF overview ............................76 Writing a function module .....................76 Writing a UDF ......................... 77 Thread-safe UDFs ....................... 78 Compiling and linking a function module ............80 Creating a UDF library..................... 81 Modifying a UDF library.................... 81 Declaring a UDF to a database ...................81 Declaring UDFs with FREE_IT ................ 83 UDF library placement .................... 84 Calling a UDF .............................85 Calling a UDF with SELECT .................. 86 Calling a UDF with INSERT .................. 86 Calling a UDF with UPDATE .................. 86 Calling a UDF with DELETE .................. 86 Writing a Blob UDF .........................87 Creating a Blob control structure .............. 87 Declaring a Blob UDF ..................... 88 A Blob UDF example...................... 89 The InterBase UDF library .....................90 Declaring Blob filters ........................92 CHAPTER 7 Using the Install and Licensing APIs About the InterBase Install API ..................94 Files in the Install API ..................... 94 What the Install API does ................... 95 The install handle ....................... 96 Error handling ......................... 96 Callback functions ....................... 97 Datatypes defined for the Install API ............ 99 Writing an InterBase install ....................99 Overview of the process ................... 100 DEVELOPER’S GUIDE v A real-world example .................... 101 The Install API functions ..................... 102 isc_install_clear_options() ................. 103 isc_install_execute() ..................... 104 isc_install_get_info() .................... 106 isc_install_get_message() .................. 107 isc_install_load_external_text() .............. 108 isc_install_precheck() .................... 109 isc_install_set_option() ................... 111 isc_install_unset_option().................. 113 isc_uninstall_execute() ................... 114 isc_uninstall_precheck() .................. 115 Using the License API ....................... 116 Loading the License API................... 116 Preparing the ib_license.dat file .............. 116 Adding server functionality ................. 117 isc_license_add() ....................... 117 isc_license_check() ..................... 118 isc_license_remove()..................... 119 isc_license_display() ..................... 120 isc_license_get_msg() .................... 120 Pseudocode for a typical install ................. 121 CHAPTER 8 Introduction to IBX The InterBase tab ......................... 125 TIBTable ............................ 126 TIBQuery ........................... 126 TIBStoredProc ......................... 127 TIBDatabase .......................... 127 TIBTransaction ........................ 127 TIBUpdateSQL ......................... 127 TIBDataSet ........................... 128 TIBSQL ............................. 128 TIBDatabaseInfo........................ 128 vi INTERBASE 6 TABLE OF CONTENTS TIBSQLMonitor ........................ 128 TIBEvents ........................... 129 The InterBase Admin tab ..................... 129 TIBConfigService....................... 130 TIBBackupService ...................... 130 TIBRestoreService ...................... 130 TIBValidationService..................... 130 TIBStatisticalService ..................... 130 TIBLogService ........................ 131 TIBSecurityService ...................... 131 TIBLicensingService ..................... 131 TIBServerProperties ..................... 131 TIBInstall ........................... 132 TIBUnInstall ......................... 132 CHAPTER 9 Designing Database Applications Using databases .......................... 134 Local InterBase databases.................. 134 Remote InterBase database servers ............ 134 Database security ...................... 135 Transactions ......................... 135 The Data Dictionary ..................... 136 Referential integrity, stored procedures, and triggers . 137 Database architecture ....................... 138 Planning for scalability ................... 139 Single-tiered database applications ............ 140 Two-tiered database applications.............. 141 Multi-tiered database applications ............. 141 Designing the user interface ................... 143 Displaying a single record ................. 144 Displaying multiple records................. 144 Analyzing data ........................ 145 Selecting what data to show ................ 145 DEVELOPER’S GUIDE vii CHAPTER 10 Building One- and Two-tiered Applications Understanding databases and datasets ............. 150 Using transactions ...................... 150 Caching updates ....................... 152 Creating and restructuring database tables ........ 153 Using the briefcase model.................. 153 Scaling up to a three-tiered application ............. 154 Creating multi-tiered applications ................ 155 CHAPTER 11 Connecting to Databases Understanding persistent and temporary database components ................. 157 Using temporary database components .......... 158 Creating database components at design time ...... 158 Controlling connections ...................... 159 Controlling server login ................... 159 Connecting to a database server .............. 160 Working with network protocols .............. 160 Using ODBC ......................... 161 Disconnecting from a database server ........... 161 Iterating through a database component’s datasets ... 161 Requesting information about an attachment ......... 162 Database characteristics................... 162