ASA9_PG.pdf
(
2058 KB
)
Pobierz
351399802 UNPDF
Adaptive Server
®
Anywhere
Programming Guide
Part number: 38130-01-0900-01
Last modified: June 2003
Copyright © 1989–2003 Sybase, Inc. Portions copyright © 2001–2003 iAnywhere Solutions, Inc. All rights reserved.
No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual,
optical, or otherwise, without the prior written permission of iAnywhere Solutions, Inc. iAnywhere Solutions, Inc. is a subsiduary of
Sybase, Inc.
Sybase, SYBASE (logo), AccelaTrade, ADA Workbench, Adaptable Windowing Environment, Adaptive Component Architecture,
Adaptive Server, Adaptive Server Anywhere, Adaptive Server Enterprise, Adaptive Server Enterprise Monitor, Adaptive Server
Enterprise Replication, Adaptive Server Everywhere, Adaptive Server IQ, Adaptive Warehouse, AnswerBase, Anywhere Studio,
Application Manager, AppModeler, APT Workbench, APT-Build, APT-Edit, APT-Execute, APT-Library, APT-Translator, ASEP,
AvantGo, AvantGo Application Alerts, AvantGo Mobile Delivery, AvantGo Mobile Document Viewer, AvantGo Mobile Inspection,
AvantGo Mobile Marketing Channel, AvantGo Mobile Pharma, AvantGo Mobile Sales, AvantGo Pylon, AvantGo Pylon Application
Server, AvantGo Pylon Conduit, AvantGo Pylon PIM Server, AvantGo Pylon Pro, Backup Server, BayCam, Bit-Wise, BizTracker,
Certified PowerBuilder Developer, Certified SYBASE Professional, Certified SYBASE Professional (logo), ClearConnect, Client
Services, Client-Library, CodeBank, Column Design, ComponentPack, Connection Manager, Convoy/DM, Copernicus, CSP, Data
Pipeline, Data Workbench, DataArchitect, Database Analyzer, DataExpress, DataServer, DataWindow, DB-Library, dbQueue,
Developers Workbench, Direct Connect Anywhere, DirectConnect, Distribution Director, Dynamic Mobility Model, Dynamo, e-ADK,
E-Anywhere, e-Biz Integrator, E-Whatever, EC Gateway, ECMAP, ECRTP, eFulfillment Accelerator, Electronic Case Management,
Embedded SQL, EMS, Enterprise Application Studio, Enterprise Client/Server, Enterprise Connect, Enterprise Data Studio, Enterprise
Manager, Enterprise Portal (logo), Enterprise SQL Server Manager, Enterprise Work Architecture, Enterprise Work Designer,
Enterprise Work Modeler, eProcurement Accelerator, eremote, Everything Works Better When Everything Works Together, EWA,
Financial Fusion, Financial Fusion (and design), Financial Fusion Server, Formula One, Fusion Powered e-Finance, Fusion Powered
Financial Destinations, Fusion Powered STP, Gateway Manager, GeoPoint, GlobalFIX, iAnywhere, iAnywhere Solutions, ImpactNow,
Industry Warehouse Studio, InfoMaker, Information Anywhere, Information Everywhere, InformationConnect, InstaHelp,
InternetBuilder, iremote, iScript, Jaguar CTS, jConnect for JDBC, KnowledgeBase, Logical Memory Manager, M-Business Channel,
M-Business Network, M-Business Server, Mail Anywhere Studio, MainframeConnect, Maintenance Express, Manage Anywhere
Studio, MAP, MDI Access Server, MDI Database Gateway, media.splash, Message Anywhere Server, MetaWorks, MethodSet,
ML Query, MobiCATS, My AvantGo, My AvantGo Media Channel, My AvantGo Mobile Marketing, MySupport, Net-Gateway,
Net-Library, New Era of Networks, Next Generation Learning, Next Generation Learning Studio, O DEVICE, OASiS, OASiS (logo),
ObjectConnect, ObjectCycle, OmniConnect, OmniSQL Access Module, OmniSQL Toolkit, Open Biz, Open Business Interchange,
Open Client, Open Client/Server, Open Client/Server Interfaces, Open ClientConnect, Open Gateway, Open Server, Open
ServerConnect, Open Solutions, Optima++, Partnerships that Work, PB-Gen, PC APT Execute, PC DB-Net, PC Net Library,
PhysicalArchitect, Pocket PowerBuilder, PocketBuilder, Power Through Knowledge, Power++, power.stop, PowerAMC,
PowerBuilder, PowerBuilder Foundation Class Library, PowerDesigner, PowerDimensions, PowerDynamo, Powering the New
Economy, PowerJ, PowerScript, PowerSite, PowerSocket, Powersoft, Powersoft Portfolio, Powersoft Professional, PowerStage,
PowerStudio, PowerTips, PowerWare Desktop, PowerWare Enterprise, ProcessAnalyst, QAnywhere, Rapport, Relational Beans,
RepConnector, Replication Agent, Replication Driver, Replication Server, Replication Server Manager, Replication Toolkit, Report
Workbench, Report-Execute, Resource Manager, RW-DisplayLib, RW-Library, S.W.I.F.T. Message Format Libraries, SAFE,
SAFE/PRO, SDF, Secure SQL Server, Secure SQL Toolset, Security Guardian, SKILS, smart.partners, smart.parts, smart.script,
SQL Advantage, SQL Anywhere, SQL Anywhere Studio, SQL Code Checker, SQL Debug, SQL Edit, SQL Edit/TPU,
SQL Everywhere, SQL Modeler, SQL Remote, SQL Server, SQL Server Manager, SQL Server SNMP SubAgent, SQL Server/CFT,
SQL Server/DBM, SQL SMART, SQL Station, SQL Toolset, SQLJ, Stage III Engineering, Startup.Com, STEP, SupportNow, Sybase
Central, Sybase Client/Server Interfaces, Sybase Development Framework, Sybase Financial Server, Sybase Gateways, Sybase
Learning Connection, Sybase MPP, Sybase SQL Desktop, Sybase SQL Lifecycle, Sybase SQL Workgroup, Sybase Synergy Program,
Sybase User Workbench, Sybase Virtual Server Architecture, SybaseWare, Syber Financial, SyberAssist, SybMD, SyBooks,
System 10, System 11, System XI (logo), SystemTools, Tabular Data Stream, The Enterprise Client/Server Company, The Extensible
Software Platform, The Future Is Wide Open, The Learning Connection, The Model For Client/Server Solutions, The Online
Information Center, The Power of One, TradeForce, Transact-SQL, Translation Toolkit, Turning Imagination Into Reality, UltraLite,
UltraLite.NET, UNIBOM, Unilib, Uninull, Unisep, Unistring, URK Runtime Kit for UniCode, Versacore, Viewer, VisualWriter, VQL,
Warehouse Control Center, Warehouse Studio, Warehouse WORKS, WarehouseArchitect, Watcom, Watcom SQL, Watcom SQL
Server, Web Deployment Kit, Web.PB, Web.SQL, WebSights, WebViewer, WorkGroup SQL Server, XA-Library, XA-Server, and
XP Server are trademarks of Sybase, Inc. or its subsidiaries.
All other trademarks are property of their respective owners.
ii
Contents
About This Manual vii
SQL Anywhere Studio documentation . . . . . . . . . . . . . . . . .
viii
Documentation conventions . . . . . . . . . . . . . . . . . . . . . . .
xi
The Adaptive Server Anywhere sample database . . . . . . . . . . .
xiii
Finding out more and providing feedback . . . . . . . . . . . . . . . .
xiv
1 Programming Interface Overview
1
The ODBC programming interface . . . . . . . . . . . . . . . . . . .
2
The ADO.NET programming interface . . . . . . . . . . . . . . . . .
3
The OLE DB and ADO programming interface . . . . . . . . . . . . .
4
The Embedded SQL programming interface . . . . . . . . . . . . . .
5
The JDBC programming interface . . . . . . . . . . . . . . . . . . . .
6
The Open Client programming interface . . . . . . . . . . . . . . . .
7
Code samples and other programming interfaces . . . . . . . . . . .
9
2 Using SQL in Applications 11
Executing SQL statements in applications . . . . . . . . . . . . . . .
12
Preparing statements . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
Introduction to cursors . . . . . . . . . . . . . . . . . . . . . . . . . .
17
Working with cursors . . . . . . . . . . . . . . . . . . . . . . . . . . .
21
Choosing cursor types . . . . . . . . . . . . . . . . . . . . . . . . . .
26
Adaptive Server Anywhere cursors . . . . . . . . . . . . . . . . . . .
30
Describing result sets . . . . . . . . . . . . . . . . . . . . . . . . . . .
45
Controlling transactions in applications . . . . . . . . . . . . . . . . .
47
3 Introduction to Java in the Database 51
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
52
Java in the database Q & A . . . . . . . . . . . . . . . . . . . . . . .
54
A Java seminar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
The runtime environment for Java in the database . . . . . . . . . . .
68
Tutorial: A Java in the database exercise . . . . . . . . . . . . . . . .
75
4 Using Java in the Database 81
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
82
Java-enabling a database . . . . . . . . . . . . . . . . . . . . . . . .
84
Installing Java classes into a database . . . . . . . . . . . . . . . . .
89
Special features of Java classes in the database . . . . . . . . . . .
93
Configuring memory for Java . . . . . . . . . . . . . . . . . . . . . .
99
iii
Java classes reference . . . . . . . . . . . . . . . . . . . . . . . . . .
101
5 JDBC Programming 103
JDBC overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
104
Using the jConnect JDBC driver . . . . . . . . . . . . . . . . . . . . .
110
Using the iAnywhere JDBC driver . . . . . . . . . . . . . . . . . . . .
115
Establishing JDBC connections . . . . . . . . . . . . . . . . . . . . .
117
Using JDBC to access data . . . . . . . . . . . . . . . . . . . . . . .
124
Using JDBC escape syntax . . . . . . . . . . . . . . . . . . . . . . .
131
6 Embedded SQL Programming 135
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
136
Sample embedded SQL programs . . . . . . . . . . . . . . . . . . .
143
Embedded SQL data types . . . . . . . . . . . . . . . . . . . . . . .
149
Using host variables . . . . . . . . . . . . . . . . . . . . . . . . . . .
153
The SQL Communication Area (SQLCA) . . . . . . . . . . . . . . . .
161
Fetching data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
166
Static and dynamic SQL . . . . . . . . . . . . . . . . . . . . . . . . .
176
The SQL descriptor area (SQLDA) . . . . . . . . . . . . . . . . . . .
181
Sending and retrieving long values . . . . . . . . . . . . . . . . . . .
190
Using stored procedures . . . . . . . . . . . . . . . . . . . . . . . . .
196
Embedded SQL programming techniques . . . . . . . . . . . . . . .
201
The SQL preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . .
203
Library function reference . . . . . . . . . . . . . . . . . . . . . . . .
207
Embedded SQL command summary . . . . . . . . . . . . . . . . . .
224
7 ODBC Programming 227
Introduction to ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . .
228
Building ODBC applications . . . . . . . . . . . . . . . . . . . . . . .
230
ODBC samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
234
ODBC handles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
236
Connecting to a data source . . . . . . . . . . . . . . . . . . . . . . .
239
Executing SQL statements . . . . . . . . . . . . . . . . . . . . . . . .
243
Working with result sets . . . . . . . . . . . . . . . . . . . . . . . . .
247
Calling stored procedures . . . . . . . . . . . . . . . . . . . . . . . .
251
Handling errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
253
8 The Database Tools Interface 257
Introduction to the database tools interface . . . . . . . . . . . . . . .
258
Using the database tools interface . . . . . . . . . . . . . . . . . . .
259
DBTools functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
267
DBTools structures . . . . . . . . . . . . . . . . . . . . . . . . . . . .
278
DBTools enumeration types . . . . . . . . . . . . . . . . . . . . . . .
309
iv
9 The OLE DB and ADO Programming Interfaces 313
Introduction to OLE DB . . . . . . . . . . . . . . . . . . . . . . . . . .
314
ADO programming with Adaptive Server Anywhere . . . . . . . . . .
315
Supported OLE DB interfaces . . . . . . . . . . . . . . . . . . . . . .
322
10 Introduction to the Adaptive Server Anywhere .NET Data Provider 329
Adaptive Server Anywhere .NET data provider features . . . . . . . .
330
Running the sample projects . . . . . . . . . . . . . . . . . . . . . . .
331
11 Using the Adaptive Server Anywhere .NET Data Provider Sample Ap-
plications 333
Tutorial: Using the Simple code sample . . . . . . . . . . . . . . . . .
334
Tutorial: Using the Table Viewer code sample . . . . . . . . . . . . .
338
12 Developing Applications with the .NET Data Provider 343
Using the .NET provider in a Visual Studio .NET project . . . . . . .
344
Connecting to a database . . . . . . . . . . . . . . . . . . . . . . . .
346
Accessing and manipulating data . . . . . . . . . . . . . . . . . . . .
349
Using stored procedures . . . . . . . . . . . . . . . . . . . . . . . . .
370
Transaction processing . . . . . . . . . . . . . . . . . . . . . . . . . .
372
Error handling and the Adaptive Server Anywhere .NET data provider
374
Deploying the Adaptive Server Anywhere .NET data provider . . . .
375
13 Adaptive Server Anywhere .NET Data Provider API Reference 377
AsaCommand class . . . . . . . . . . . . . . . . . . . . . . . . . . .
379
AsaCommandBuilder class . . . . . . . . . . . . . . . . . . . . . . .
385
AsaConnection class . . . . . . . . . . . . . . . . . . . . . . . . . . .
389
AsaDataAdapter class . . . . . . . . . . . . . . . . . . . . . . . . . .
395
AsaDataReader class . . . . . . . . . . . . . . . . . . . . . . . . . .
404
AsaDbType enum . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
418
AsaError class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
419
AsaErrorCollection class . . . . . . . . . . . . . . . . . . . . . . . . .
421
AsaException class . . . . . . . . . . . . . . . . . . . . . . . . . . . .
423
AsaInfoMessageEventArgs class . . . . . . . . . . . . . . . . . . . .
425
AsaInfoMessageEventHandler delegate . . . . . . . . . . . . . . . .
426
AsaParameter class . . . . . . . . . . . . . . . . . . . . . . . . . . .
427
AsaParameterCollection class . . . . . . . . . . . . . . . . . . . . . .
433
AsaPermission class . . . . . . . . . . . . . . . . . . . . . . . . . . .
437
AsaPermissionAttribute class . . . . . . . . . . . . . . . . . . . . . .
438
AsaRowUpdatedEventArgs class . . . . . . . . . . . . . . . . . . . .
439
AsaRowUpdatingEventArgs class . . . . . . . . . . . . . . . . . . . .
441
AsaRowUpdatedEventHandler delegate . . . . . . . . . . . . . . . .
443
AsaRowUpdatingEventHandler delegate . . . . . . . . . . . . . . . .
444
AsaTransaction class . . . . . . . . . . . . . . . . . . . . . . . . . . .
445
v
Plik z chomika:
Koriolan_new
Inne pliki z tego folderu:
Sybase_ASA_programming_dbpgen10.pdf
(4333 KB)
ASA9_ReviewersGuide.pdf
(290 KB)
ASA9_Error_Messages9.pdf
(1466 KB)
UL9_embedded_UG.pdf
(589 KB)
dbs_remoter_UG_9.pdf
(1571 KB)
Inne foldery tego chomika:
Sybase 5 doc
Sybase 6 doc
Zgłoś jeśli
naruszono regulamin