C# samples

Directory: sqllib\samples\.NET\cs.

Table 1. Samples that deal with database Level database objects in Db2.
Sample program name Program description
DbAuth.cs How to grant/display/revoke authorities at the database level.
DbDatAdp.cs How to use a DB2DataAdapter.
DbDatMap.cs How to set up DataTable and DataColumn mappings.
DbDsetCn.cs How to add existing constraints to a DataSet.
DbEvent.cs How to handle DB2DataAdapter events.
DbUse.cs How to use database objects.
DbValue.cs How to obtain a single value from a database.
Table 2. Samples that deal with table level database objects in Db2®.
Sample program name Program description
TbConstr.cs How to work with table constraints.
TbInfo.cs How to get and set information at a table level.
TbPriv.cs How to grant/display/revoke table level privileges.
TbSel.cs How to select from each of: insert, update, delete.
TbTrig.cs How to use a trigger on a table.
TbUse.cs How to manipulate table data and connect to/disconnect from a database.
Table 3. Samples that deal with data type level database objects in Db2.
Sample program name Program description
DtLob.cs How to use the LOB data type.
Table 4. Samples that demonstrate stored procedures in Db2.
Sample program name Program description
SpCat.db2 Drops and creates the procedures implemented in SpServer.cs.
SpClient.cs Client program used to call the stored procedures in SpServer.cs.
SpCreate.db2 Creates the external procedures implemented in SpServer.cs.
SpDrop.db2 Drops the external procedures created in SpCreate.db2 for C#.
SpReturn.cs Client application that calls the stored procedure EMP_DETAILS and obtains its return value.
SpServer.cs C# external code implementation of procedures created in SpCat.db2.
EmpDetails.db2 CLP script that creates a stored procedure named EMP_DETAILS.
Table 5. Samples that demonstrate user-defined functions in Db2.
Sample program name Program description
UdfCat.db2 Drops and creates the external UDFs implemented in UdfSrv.cs.
UdfCli.cs Client application that calls the user-defined functions in UdfSrv.cs.
UdfCreate.db2 Creates the external UDFs implemented in UdfSrv.cs.
UdfDrop.db2 Drops the external UDFs created in udfcreate.db2 for C#.
UdfSrv.cs User-defined scalar functions called by UdfCli.cs.
Table 6. Samples that demonstrate Db2 XML usage with .NET
Sample program name Program description
XmlIndex.cs Create an index and use it in an XQuery.
XmlUniqueIndexes.cs Create an index with UNIQUE and VARCHAR length constraints.
XmlInsert.cs Insert an XML document into a column of XML data type.
XmlUpAndDel.cs Update and delete XML documents in the tables.
XmlRead.cs Read XML data stored in tables.
XmlRelToXmlDoc.cs Create an XML document directly from data stored in relational tables using SQL/XML publishing functions.
XmlRelToXmlType.cs Create an XML document from relational and XML data using SQL/XML publishing functions.
XmltoTable.cs Insert the data from an XML document into relational tables using SQL/XML.
XmlDecomposition.cs Decompose data stored in an XML file and insert the data into tables.
XmlSchema.cs Register the XML schema to the database and use the registered schema to validate and insert and XML document.
XmlFlwor.cs Use the XQuery FLWOR expression.
XmlSQLXQuery.cs Use SQL/XML queries
XmlXPath.cs Run simple XPath queries.
XmlXQuery.cs Execute nested XQuery FLWOR expressions.
XmlSimpleProcClient.cs Client application that calls the stored procedure.
XmlSimpleProc.cs Stored procedure functions built and run on the server.
XmlSimpleProcCreate.db2 CLP script to issue CREATE PROCEDURE statement.
XmlSimpleProcDrop.db2 CLP script to drop stored procedure from the catalog.
XmlXQueryProcClient.cs Client application that calls the stored procedure.
XmlXQueryProc.cs Stored procedure functions built and run on the server.
XmlSpCatXQuery.bat Batch file that first calls XmlXQueryProcDrop.db2 and then calls XmlXQueryProcCreate.db2. This file will be found only on windows platforms.
XmlXQueryProcCreate.db2 CLP script to issue CREATE PROCEDURE statement.
XmlXQueryProcDrop.db2 CLP script to drop stored procedure from the catalog.
Table 7. Samples that demonstrate loosely coupled transactions in Db2
Sample program name Program description
empcat.bat Catalogs the stored procedure EMP_DETAILS for the C# client program, SpReturn.
LCTrans.cs Demonstrates loosely coupled transactions.
regCOM.bat Registers COM+ objects for the C# LCTrans program.
RootCOM.cs This file is used to create a library assembly RootCOM.dll. LCTrans.cs refers to the classes and methods that are defined in this file.
SubCOM.cs This file is used to create a library assembly SubCOM.dll. LCTrans.cs refers to the classes and methods that are defined in this file.