Show detailed of table properties

Untuk mengetahui object2 yang ada di dalam database SQL Server ternyata bisa menggunakan scripting query yang disediakan sendiri oleh sql server. Untuk diketahui ini sangat berguna sekali buat developer pada level database maupun pada lever bahasa pemrograman.

1. Table sysobjects
Table ini mempunyai struktur sebagai berikut :

Column_Name Type Computed Length Prec Scale Nullable
name sysname no 256 no
id int no 4 10 0 no
xtype char no 2 no
uid smallint no 2 5 0 yes
info smallint no 2 5 0 yes
status int no 4 10 0 yes
base_schema_ver int no 4 10 0 yes
replinfo int no 4 10 0 yes
parent_obj int no 4 10 0 no
crdate datetime no 8 no
ftcatid smallint no 2 5 0 yes
schema_ver int no 4 10 0 yes
stats_schema_ver int no 4 10 0 yes
type char no 2 yes
userstat smallint no 2 5 0 yes
sysstat smallint no 2 5 0 yes
indexdel smallint no 2 5 0 yes
refdate datetime no 8 no
version int no 4 10 0 yes
deltrig int no 4 10 0 yes
instrig int no 4 10 0 yes
updtrig int no 4 10 0 yes
seltrig int no 4 10 0 yes
category int no 4 10 0 yes
cache smallint no 2 5 0 yes

2. Table syscolumns

Table ini mempunyai struktur sebagai berikut :

Column_Name Type Computed Length Prec Scale Nullable
name sysname no 256             yes
id int no 4 10 0 no
xtype tinyint no 1 3 0 no
typestat tinyint no 1 3 0 yes
xusertype smallint no 2 5 0 yes
length smallint no 2 5 0 no
xprec tinyint no 1 3 0 no
xscale tinyint no 1 3 0 no
colid smallint no 2 5 0 yes
xoffset smallint no 2 5 0 yes
bitpos tinyint no 1 3 0 yes
reserved tinyint no 1 3 0 yes
colstat smallint no 2 5 0 yes
cdefault int no 4 10 0 no
domain int no 4 10 0 no
number smallint no 2 5 0 yes
colorder smallint no 2 5 0 yes
autoval varbinary no 8000             yes
offset smallint no 2 5 0 yes
collationid int no 4 10 0 no
language int no 4 10 0 yes
status tinyint no 1 3 0 yes
type tinyint no 1 3 0 no
usertype smallint no 2 5 0 yes
printfmt varchar no 255             yes
prec smallint no 2 5 0 yes
scale int no 4 10 0 yes
iscomputed int no 4 10 0 yes
isoutparam int no 4 10 0 yes
isnullable int no 4 10 0 yes
collation sysname no 256             yes
tdscollation binary no 5             yes

3. Table systypes 

Table ini mempunyai struktur sebagai berikut :

Column_Name Type Computed Length Prec Scale Nullable
name sysname no 256             no
xtype tinyint no 1 3 0 no
status tinyint no 1 3 0 yes
xusertype smallint no 2 5 0 yes
length smallint no 2 5 0 no
xprec tinyint no 1 3 0 no
xscale tinyint no 1 3 0 no
tdefault int no 4 10 0 no
domain int no 4 10 0 no
uid smallint no 2 5 0 yes
reserved smallint no 2 5 0 yes
collationid int no 4 10 0 yes
usertype smallint no 2 5 0 yes
variable bit no 1             no
allownulls bit no 1             yes
type tinyint no 1 3 0 no
printfmt varchar no 255             yes
prec smallint no 2 5 0 yes
scale tinyint no 1 3 0 yes
collation sysname no 256             yes

Sebagai contoh anda bisa menjalankan query di bawah ini untuk menampilkan seluruh table dan colum setiap table beserta type data kolomnya.

SELECT sysobjects.name as table_name,
syscolumns.name as column_name,
systypes.name as datatype,
syscolumns.length as length
FROM sysobjects
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON syscolumns.xtype=systypes.xtype
WHERE sysobjects.xtype=’U
ORDER BY sysobjects.name,syscolumns.colid

SAP - PHP Connection

We know SAP, the great enterprise resource planning in the world. But very expensive budget to create and implement this software. But based on real case in some company, we have limitation in SAP, such as :

  1. SAP always charge based on user name license, whereas we know employee of company always grow and increase.
  2. If SAP implement in company that have some branches, it can be spent more budget. Because communication cost must be spent every month.
  3. Develop new business and new reports and others.

So we can analyst about cost :

  1. user license, we can reduce in this case, user license only for key processing but entry data or reporting we can user the simple application. Approximately we can reduce between 50 - 60%.
  2. Cost of communications data transfer, we must subscribe private connection (VSAT/Frame Relay/MPLS) and spent budget to create connection to communicate between head office and branch. We can user GRPS or internet monthly.
  3. Consultant service is very expensive to develop new business process/reporting, We must analyst about current and future business process, so we can plan how many spent time and cost to develop it, and if we need from outsourcing, we can analyst about our requirement.
  4. SAP complete package not always suitable with our requirement, We must understand about some feature and package, so we can choose the correct features.

Actually SAP have provided some component and library to create connection to other programming. Such as SAP dot NET (SAP NET Connector) , SAP and Java (SAP Java Connector).

But currently, Eduard Koucky created SAP Remote Function Call (SAPRFC) to call SAP function from PHP command.This library have been published in http://saprfc.sourceforge.net, you can develop SAP tools using PHP.

Installationon Windows :

- PHP running well on Apache or IIS.

- Install SAP GUI / SAP Client software (SAP GUI 6.20)
- Download API & class from http://saprfc.sourceforge.net . Extract with new directory saprfc, example : http://localhost/saprfc.

- Take file php_saprfc.dll as modul extension ( C:\\php\ext ) and add on php.ini (extension=php_saprfc.dll).

- Copy file librfc32.dll from CD installer SAP GUI to system C:\\Windows\system32.

- Restart Web Server and cek your phpinfo.

Installation on Linux

- Install Apache and PHP

- Install php_devel

- Install GNU Tools (autoconf, automake, flex, libtool, gcc, m4, make)

- Install compat-libgcc , compat-libstdc++……

- We need SAPSDK taken from CD SAP on directory Linux/Unix and found file RFC.SAR dan SAPCAR. SAPCAR is decompress file from RFC.SAR. To extract please type ./SAPCAR -xvf RFC.CAR.

- Take extract result to directory /usr/sap/rfcsdk or other alternatif on /usr/local/rfcsdk or /opt/rfcsdk based on your want to.

- Download saprfc-..tar.gz, and extract it

$ gunzip -c saprfc-$VERSION$.tar.gz | tax xf -
$ cd saprfc-$VERSION$
$ phpize
$ ./configure
$ make
$ make install

- Restart Apache and check phpinfo

(phpug.or.id)

SAP - NET Connection, Integrated Database

PT. Astra International Tbk, a large company in Indonesia, Until now, they have implemented SAP connection between head office and branch. Astra International have some brand of car, Daihatsu, Toyota, Isuzu, BMW and Peugeot. Each brand have a head office business operational. And all of brand is handled by Head Office PT AI.

After some year running with SAP, they seem have to create a product to decrease budget of license. Because grow of this company is very quickly. So they have idea to create a software as bridge to SAP, but no decrease business process in SAP.

In Astra International company have standard of programming technology. They make Microsoft Dot Net to create solution. Hire a vendor from India and be assisted by IT employee department.

The basic of this idea is SAP as a large data store. And NET application as a data entry program.

They use Decentralization application method. Each branch have web application as server application special for a branch. To data synchronize to head office, that is synch method. There are schedule to data synchronize branch to head office and head office to branch. This method is called semi-online.

This solution can be implemented in all of business, cheaper and safer.

Membuat program Database dengan PHP dan mySQL

Membuat program Database dengan PHP dan mySQL
Sekarang ini perkembangan pemrograman internet sudah semakin menjamur di dunia, jenis bahasa dan database semakin banyak. Namun kebanyakan bahasa pemrograman yang dipakai adalah PHP dan databasenya mySQL, mereka adalah produk dari opensource jadi gratis dan mudah diterapkan.
Setelah anda download paket program dari xampp di http://www.apachefriends.org/en/xampp-windows.html, install ke dalan PC anda dan running service Apache dan mySQL, komputer anda sudah siap digunakan sebagai web server.
Secara default database mySQL sudah tersetup sendiri,jika anda mau memodifikasinya coba anda buka di folter php/php.ini.
Berikut logika pemikiran dari program database dan pengenalan fungsi mySQL di PHP:
a. membuat koneksi ke database
mysql_connect($strserver,$strusername,$strpassword); fungsi ini membuat koneksi dengan database, membuat sebuah link jembatan program dengan database.membutuhkan parameter user id, password dan alamat server database.
mysql_select_db($strdbname); fungsi ini berguna untuk memilih nama database yang akan dieksekusi.
b. Mengeksekusi query
$result = mysql_query($strquery), fungsi ini mengirimkan perintah query ke dalam database dan akan mengirim nilai kembali berupa recordset atau jumlah record yang dieksekusi.
c. Menampilkan Baris Data
$arr = mysql_fetch_array($result);, fungsi ini menghasilkan array yang berisi record data dari database.
d. Menutup koneksi
mysql_free_result($result);fungsi ini untuk menghapus di memory hasil query,mysql_close(); Fungsi ini untuk menutup dan menghapus session koneksi yang dihasilkan fungsi mysql_connect. 2 fungsi ini berguna untuk mengurangi zombi proses yang ada di web server.

Berikut contoh script php dengan mysql.
<?
$link = mysql_connect(”localhost”,”root”,”"); //default password root adalah kosong
mysql_select_db(”dbbelajarphp”) ;                   // nama database dbbelajarphp
$result = mysql_query(”SELECT nim, nama FROM tbl_mahasiswa”); //query menampilkan tabel mahasiswa
while ($row = mysql_fetch_array($result)) {                                             //memasukkan data ke array row
           echo “NIM : ” . $row["nim"] . ” NAMA : “. $row["nama"] .”<BR/>”;        // menampikan di browser IE
mysql_free_result($result); 
mysql_close($link); 
?>

Web, WAP, SMS and Fax Integrated System

Para pembaca blog yang setia, kali ini saya ketengahkan tema tentang Tugas Akhir saya yang mengantarkan Younan Setya menjadi wisudawan Teknik Informatika ITS Tahun 2006. Tema yang saya ambil adalah Integrasi aplikasi dengan beberapa media teknologi : Web, WAP, SMS dan Faksimile dengan studi kasus implementasi Perhitungan dan Rekapitulasi Hasil suara pada Pemilihan Kepala Daerah Kabupaten Mojokerto.

Berikut spesifikasi yang saya pergunakan :

  • Web : PHP, programnya dulu saya download dari http://www.apachefriends.org/en/xampp-windows.html, Saya install seperti biasa, tidak ada setting apapun.
  • WAP : Microsoft Visual Studio .NET 2003, pakek bahasa pemrograman ASP VB.NET untuk mobile application.
  • SMS : SMS Gateway, Microsoft Visual Studio .NET 2003 ,pakek bahasa pemrograman VB.NET untuk dekstop application. GSM yang saya pakai HP Nokia 5110 (HP murah 200an ribu) dengan koneksi kabel serial, Komponen SMSnya lupa donwload dari mana (dah gak pernah lagi develop SMS App lagi, tapi masih pengen).
  • Faksimile : Pakek Microsoft Visual Studio .NET 2003, bahasa programmnya C# untuk desktop app. FaxModem bermerek (lupa mereknya).

Bisnis prosesnya adalah sebagai berikut :

  • Semua media bisa menjadi sistem entri ke dalam sistem rekapitulasi, Web saya sediakan form entri, begitu juga WAP sedangkan SMS saya sediakan SMS Gateway untuk mengambil nilai. Dan untuk Fax saya sediakan Fax Server untuk bisa mengambil Fax yang dikirimkan.
  • Input, Parsing dan save, mungkin itu bisnis dan proses yang terbanyak di sistem saya, Parsing apakah sesuai dengan format yang ditentukan, jika OK data akan disimpan di dalam database.
  • Media Informasi, semua media juga bisa melayani informasi jika ada request (kecuali media Fax, server applikasi ini tidak ada menu request informasi).

Kapan-kapan kalau CDnya ketemu saya akan share programnya.