If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Making a DB2 database Case-insensitive

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-21-03, 19:20
kangan kangan is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
Making a DB2 database Case-insensitive

Hi,
Is there anyway, I can make 'Adam' equal to 'ADAM' without using functions like UPPER, UCASE, TRANSLATE, LCASE etc. Is there anyway, when I create the database, I can specify if it is case sensitive or not. I am using DB2 V8.1 on windows XP.
-thanks
Kangan
Reply With Quote
  #2 (permalink)  
Old 11-21-03, 19:38
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Making a DB2 database Case-insensitive

There is a discussion in

http://www.dbforums.com/t906034.html
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 11-24-03, 19:19
kangan kangan is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
Hi,
I tried what was given in that thread, but it still did not work. Is there anything that I am missing.
__________________
kr
Reply With Quote
  #4 (permalink)  
Old 11-24-03, 19:34
kangan kangan is offline
Registered User
 
Join Date: Oct 2003
Posts: 17
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 */
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On