I tried this with the DbCreate C file given in the samples directory.
and I converted the stt
dbDescriptor.sqldbcss = SQL_CS_NONE to
dbDescriptor.sqldbcss = SQL_CS_USER;
//
{
int i;
for(i=0;i<256;i++)
{
if (isalpha(i))
dbDescriptor.sqldbudc[i]=toupper(i);
else
dbDescriptor.sqldbudc[i]=i;
}
}
as given in the thread.
I am able to create a database but not really a case insensitive database. The full code is attached below, if anyone can say where I am going wrong, It will be of great help to me. I had commented out the DBDROP and INSTANCEDETACH function call.
-thanks
Kangan
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "C:\Program Files\IBM\SQLLIB\include\sqle819a.h"
#include "C:\Program Files\IBM\SQLLIB\include\sqlutil.h"
#include "C:\Program Files\IBM\SQLLIB\include\sqlenv.h"
#include "utilapi.h"
int DbCreate(void);
int DbDrop(void);
int main(int argc, char *argv[])
{
int rc = 0;
char nodeName[SQL_INSTNAME_SZ + 1]="DB2";
char user[USERID_SZ + 1]="USER";
char pswd[PSWD_SZ + 1]="PWD";
/* check the command line arguments */
/* rc = CmdLineArgsCheck2(argc, argv, nodeName, user, pswd);
if (rc != 0)
{
return rc;
}*/
printf("\nTHIS SAMPLE SHOWS HOW TO CREATE/DROP A DATABASE.\n");
/* attach to a local or remote instance */
rc = InstanceAttach(nodeName, user, pswd);
if (rc != 0)
{
return rc;
}
rc = DbCreate();
// rc = DbDrop();
/* detach from the local or remote instance */
//rc = InstanceDetach(nodeName);
if (rc != 0)
{
return rc;
}
return 0;
} /* main */
int DbCreate(void)
{
struct sqlca sqlca;
char dbName[SQL_DBNAME_SZ + 1];
char dbLocalAlias[SQL_ALIAS_SZ + 1];
char dbPath[SQL_PATH_SZ + 1];
struct sqledbdesc dbDescriptor;
SQLEDBTERRITORYINFO territoryInfo;
printf("\n-----------------------------------------------------------");
printf("\nUSE THE DB2 API:\n");
printf(" sqlecrea -- CREATE DATABASE\n");
printf("TO CREATE A NEW DATABASE:\n");
/* create a new database */
strcpy(dbName, "dbcrea2");
strcpy(dbLocalAlias, "dbcrea2");
strcpy(dbPath, "");
strcpy(dbDescriptor.sqldbdid, SQLE_DBDESC_2);
dbDescriptor.sqldbccp = 0;
dbDescriptor.sqldbcss = SQL_CS_USER;
{
int i;
for(i=0;i<256;i++)
{
if (isalpha(i))
dbDescriptor.sqldbudc[i]=toupper(i);
else
dbDescriptor.sqldbudc[i]=i;
}
}
memcpy(dbDescriptor.sqldbudc, sqle_819_500, SQL_CS_SZ);
strcpy(dbDescriptor.sqldbcmt, "comment for database");
dbDescriptor.sqldbsgp = 0;
dbDescriptor.sqldbnsg = 10;
dbDescriptor.sqltsext = -1;
dbDescriptor.sqlcatts = NULL;
dbDescriptor.sqlusrts = NULL;
dbDescriptor.sqltmpts = NULL;
// strcpy(territoryInfo.sqldbcodeset, "ISO8859-1");
strcpy(territoryInfo.sqldbcodeset, "IBM-1252");
strcpy(territoryInfo.sqldblocale, "US");
printf("\n Create a [remote] database and catalog it locally:\n");
printf(" database name : %s\n", dbName);
printf(" local database alias: %s\n", dbLocalAlias);
/* create database */
sqlecrea(dbName,
dbLocalAlias,
dbPath,
&dbDescriptor,
&territoryInfo,
'\0',
NULL,
&sqlca);
DB2_API_CHECK("Database -- Create");
return 0;
} /* DbCreate */
int DbDrop(void)
{
struct sqlca sqlca;
char dbLocalAlias[SQL_ALIAS_SZ + 1];
printf("\n-----------------------------------------------------------");
printf("\nUSE THE DB2 API:\n");
printf(" sqledrpd -- DROP DATABASE\n");
printf("TO DROP A DATABASE:\n");
/* drop a database */
strcpy(dbLocalAlias, "dbcreate1");
printf("\n Drop a [remote] database and uncatalog it locally.\n");
printf(" local database alias: %s\n", dbLocalAlias);
/* drop database */
sqledrpd(dbLocalAlias, &sqlca);
DB2_API_CHECK("Database -- Drop");
return 0;
} /* DbDrop */