/******************************************************************************* ** ** Source File Name = db_udcs.c ** ** Licensed Materials - Property of IBM ** ** (C) COPYRIGHT International Business Machines Corp. 1996, 2000 ** All Rights Reserved. ** ** US Government Users Restricted Rights - Use, duplication or ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp. ** ** ** PURPOSE : ** This program is an example of how APIs are implemented in order to ** CREATE a DATABASE with a user-defined collating sequence, then ** DROP the DATABASE. ** ** A user-defined collating sequence allows the user to specify the ** collating behavieour of the database. This can be used by ** applications that require compatibility to the collating ** behaviour of host database products. For example, simulating ** the collating behaviour of DB2/MVS CCSID 500 (EBCDIC International) ** can be achived by specifying a colating sequence that maps ** codepage 819 characters to CCSID 500 characters when the ** database is created. ** ** APIs USED : ** INSTANCE ATTACH sqleatin() ** CREATE DATABASE sqlecrea() ** DROP DATABASE sqledrpd() ** ** STRUCTURES USED : ** sqledbdesc ** sqledbcountryinfo ** sqlca ** ** OTHER FUNCTIONS USED : ** 'C' COMPILER LIBRARY : ** stdio.h - printf ** ** external : ** check_error : Checks for SQLCODE error, and prints out any ** [in UTIL.C] related information available. ** This procedure is located in the UTIL.C file. ** ** ** EXTERNAL DEPENDENCIES : ** - Compiling and linking with the IBM Cset++ compiler (AIX and OS/2) ** or the Microsoft Visual C++ compiler (Windows) ** or the compiler supported on your platform. ** - a database by the name of "DBUDCS" does not exist. ** ** For more information about these samples see the README file. ** ** For more information on programming in C, see the: ** - "Programming in C and C++" section of the Application Development Guide ** For more information on Building C Applications, see the: ** - "Building C Applications" section of the Application Building Guide. ** ** For more information on the SQL language see the SQL Reference. ** *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sqle819a.h> /* collating sequence mapping 819 to 500 */ #include <sqlutil.h> #include <sqlenv.h> #include "utilapi.h" int main (int argc, char* argv[]) { struct sqlca sqlca; struct sqledbdesc db_desc; struct sqledbcountryinfo dbCountry; char userid[9]; char passwd[19]; char nodename[9]; if (argc == 4) { strcpy (userid, argv[1]); strcpy (passwd, argv[2]); strcpy (nodename, argv[3]); /*************************/ /* ATTACH API called */ /*************************/ sqleatin (nodename, userid, passwd, &sqlca); } else if (argc != 1) { printf("\nUSAGE: db_udcs [userid password remote_nodename]\n"); return 1; } strcpy(db_desc.sqldbdid, SQLE_DBDESC_2); db_desc.sqldbccp = 0; db_desc.sqldbcss = -1; memcpy(db_desc.sqldbudc, sqle_819_500, SQL_CS_SZ); db_desc.sqldbcmt[0] = 0x00; db_desc.sqldbsgp = 0; db_desc.sqldbnsg = 10; db_desc.sqltsext = -1; db_desc.sqlcatts = NULL; db_desc.sqlusrts = NULL; db_desc.sqltmpts = NULL; strcpy(dbCountry.sqldbcodeset, "ISO8859-1"); strcpy(dbCountry.sqldblocale, "En_US"); printf ("CREATing the temporary database DBUDCS...\n"); printf ("please wait... this will take a while...\n"); /****************************\ * CREATE DATABASE API called * \****************************/ sqlecrea( "DBUDCS", "DBUDCS", "", &db_desc, &dbCountry, '\0', NULL, &sqlca ) ; API_SQL_CHECK("creating the database"); printf ("database DBUDCS with a user-defined collating\n"); printf ("sequence created successfully.\n"); printf ("DROPping the database DBUDCS\n"); /**************************\ * DROP DATABASE API called * \**************************/ sqledrpd ("DBUDCS", &sqlca); API_SQL_CHECK("dropping the database"); return 0; }