วันพฤหัสบดีที่ 1 พฤษภาคม พ.ศ. 2551

Change oracle database character set

I had problem with AL32UTF8 character from Oracle ... so I want to change character set to THTISASCII by follow as step

sqlplus "/as sysdba"
startup;
select * from nls_database_parameters;
shutdown immediate;

STARTUP MOUNT;

ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE CHARACTER SET TH8TISASCII;

SHUTDOWN;
STARTUP;

After follow this step as my friend suggest I found error with command

ALTER DATABASE CHARACTER SET TH8TISASCII;
ORA-12712: new character set must be a superset of old character set

Because old character set is Superset of new character set so Oracle does not allow to change character set.

Anyway you can avoid this problem if you really want to change it by using command
ALTER DATABASE CHARACTER SET INTERNAL_USE TH8TISASCII;

Oracle will allow you to change character set although old character set is a superset of new character set but you must make sure that this change will not impact your database.

:)

วันจันทร์ที่ 7 เมษายน พ.ศ. 2551

How to convert FAT32 to NTFS

Today I have problem about copying image-file 11 GB to FAT32 hdd.
Even free space have enough but when I copy image-file to hdd WindowXP will alert "Disk full".

So my friend advises me to change FAT32 to NTFS format because FAT32 is not support filesize more tan 4 GB (Other different between FAT32 and NTFS can see http://www.ntfs.com/ntfs_vs_fat.htm)


The simple way to convert my drive d: from FAT32 to NTFS is shown below.

Start > Run > "convert d: /fs:ntfs"

:)

วันศุกร์ที่ 21 มีนาคม พ.ศ. 2551

How to create folder yy/mm/dd by using shell script

If you don't have time to create a lof of directory for keep log file by yy/mm/dd.
you can use a simple shell script for create it automatically as follow.


#!/bin/bash

numdays=( 0 31 29 31 30 31 30 31 31 30 31 30 31 )
year=${1:-2008}
month_begin=${2:-1}

month_end=${2:-12}
seq $month_begin $month_end while read month ; do

seq 1 ${numdays[$month]} while read day ; do

mkdir -p $( printf "%04d%02d%02d" $year $month $day )

done
done

Make it simple :)

วันพฤหัสบดีที่ 20 มีนาคม พ.ศ. 2551

How to write data to device with non cache (DIRECT I/O).

Last year (2007) when I worked at my 1st comapany. I was assigned to write interface program for read/write to ATA device with non cache memory.

On Linux u can use basic function as read/write for do it. Not like window that u must use writeasync/sync.

But a little tricky is a first step to open device with direct IO mode. you just add flag O_DIRECT and it will work correctly with non cache access.

example;
fd = open(devName, O_RDWR |O_DIRECT|O_RSYNC | O_SYNC );

:)
Cheers.

็How to create linux shared library (.so)

Hi guys... this is my first topic.
I would like to talk about the way to create shared library on Linux.

Last week I was assigned to create dll version on Linux . That is shared library.
Don't talk anymore ... let see the way :) .

This work will build new library that use a OCCI library internal.

1.Declare nessecary macro.
CC = g++

OBJ = Th_lexer_lib2_linux.o Worddict.o
OCCI_SHARELIBS = /home/nat/oracle/product/10.2.0/db_1/lib/
OCCI_HEADER = /home/nat/oracle/product/10.2.0/db_1/rdbms/public/

all:Th_lexer_lib2_linux.so
@echo "Build TestBox_linux module complete!!"
clean:
rm -fr *.o Th_lexer_lib2_linux.so
@echo "Remove all TestBox_linux modules!!!"


2.Build nessacary object files that use in library. flag "-fpic" is need.

Worddict.o:Worddict.cpp Thaifunc.h Thaihead.h TypeLinux.h
$(CC) -fpic -c Worddict.cpp

Th_lexer_lib2_linux.o:Th_lexer_lib2_linux.cpp TypeLinux.h
$(CC) -I $(OCCI_HEADER) -fpic -c Th_lexer_lib2_linux.cpp


3.After we get all object files we will collect them to new library by using -shared.
Th_lexer_lib2_linux.so: Th_lexer_lib2_linux.o Worddict.o
$(CC) -shared -o Th_lexer_lib2_linux.so Worddict.o Th_lexer_lib2_linux.o -L. -locci -lclntsh

That's all .... now you can get new library that all function can access by not using _declspec(dllexport) in c code like as window dll.

If you want to limited scope for access you must include mapfile for define local and global part of library.

In g++ complier you must use extern keywords for defined function name correctly for protect undefined symbol problem when you call that function.

extern "C"{
void function_a();
}

And you can check all modules in library by using
nm "library_name"

Goodluck ,