.: NeVeR GivE uP :.

4-Maret-2008

Record Status (Open Batch)

Diarsipkan di bawah: myDelphi's — cyberheck @ 1111:58
procedure TFEnPlgnAktif.aqGunaBrgCalcFields(DataSet: TDataSet);
begin
  inherited;
  with TADOQuery(Dataset) do begin
  if RecordStatus = [rsOK] then
    Dataset['clcStat'] := 'OK' else
  if RecordStatus = [rsNew] then
    Dataset['clcStat'] := 'New' else
  if RecordStatus = [rsModified] then
    Dataset['clcStat'] := 'Modified' else
  if RecordStatus = [rsDeleted] then
    Dataset['clcStat'] := 'Deleted' else
  if RecordStatus = [rsUnmodified] then
    Dataset['clcStat'] := 'Unmodified' else
  if RecordStatus = [rsInvalid] then
    Dataset['clcStat'] := 'Invalid' else
  if RecordStatus = [rsMultipleChanges] then
    Dataset['clcStat'] := 'MultipleChanges' else
  if RecordStatus = [rsPendingChanges] then
    Dataset['clcStat'] := 'PendingChanges' else
  if RecordStatus = [rsCanceled] then
    Dataset['clcStat'] := 'Canceled' else
  if RecordStatus = [rsCantRelease] then
    Dataset['clcStat'] := 'rsCantRelease' else
  if RecordStatus = [rsConcurrencyViolation] then
    Dataset['clcStat'] := 'ConcurrencyViolation' else
  if RecordStatus = [rsIntegrityViolation] then
    Dataset['clcStat'] := 'IntegrityViolation' else
  if RecordStatus = [rsMaxChangesExceeded] then
    Dataset['clcStat'] := 'MaxChangesExceeded' else
  if RecordStatus = [rsObjectOpen] then
    Dataset['clcStat'] := 'ObjectOpen' else
  if RecordStatus = [rsOutOfMemory] then
    Dataset['clcStat'] := 'OutOfMemory' else
  if RecordStatus = [rsPermissionDenied] then
    Dataset['clcStat'] := 'PermissionDenied' else
  if RecordStatus = [rsSchemaViolation] then
    Dataset['clcStat'] := 'SchemaViolation' else
  if RecordStatus = [rsDBDeleted] then
    Dataset['clcStat'] := 'DBDeleted';
  end;
end;

berfungsi untuk mengetahui status dari suatu record dengan menggunakan komponan ADOQuery jika query tersebut dibuka dengan Batch mode.

Angka Terbilang

Diarsipkan di bawah: myDelphi's — cyberheck @ 1010:14
function myGetTerbilang(sValue: string; const useRupiah: Boolean = true): string;

const

  Angka : array [1..20] of string =

          ('', 'Satu', 'Dua', 'Tiga', 'Empat',

           'Lima', 'Enam', 'Tujuh', 'Delapan',

           'Sembilan', 'Sepuluh', 'Sebelas',

           'Dua Belas', 'Tiga Belas', 'Empat Belas',

           'Lima Belas', 'Enam Belas', 'Tujuh Belas',

           'Delapan Belas', 'Sembilan Belas');

  sPattern: string = '000000000000000';var

  S : string;

  Satu, Dua, Tiga, Belas, Gabung: string;

  Sen, Sen1, Sen2: string;

  Hitung : integer;

  One, Two, Three: integer;

  Kata : string;

begin

  One    := 1;

  Two    := 2;

  Three  := 3;

  Hitung := 1;

  Kata   := '';

  S := copy(sPattern, 1, length(sPattern) - length(trim(sValue))) + sValue;

  Sen1 := Copy(S, 14, 1);

  Sen2 := Copy(S, 15, 1);

  Sen  := Sen1 + Sen2;

  while Hitung < 5 do

  begin

    Satu := Copy(S, One, 1);

    Dua  := Copy(S, Two, 1);

    Tiga := Copy(S, Three, 1);

    Gabung := Satu + Dua + Tiga;

if StrToInt(Satu) = 1 then

       Kata := Kata + 'Seratus '

    else

       if StrToInt(Satu) > 1 Then

          Kata := Kata + Angka[StrToInt(satu)+1] + ' Ratus ';

if StrToInt(Dua) = 1 then

       begin

         Belas := Dua + Tiga;

         Kata := Kata + Angka[StrToInt(Belas)+1];

       end

    else

       if StrToInt(Dua) > 1 Then

          Kata := Kata + Angka[StrToInt(Dua)+1] + ' Puluh ' +

                  Angka[StrToInt(Tiga)+1]

    else

       if (StrToInt(Dua) = 0) and (StrToInt(Tiga) > 0) Then

          begin

            if ((Hitung = 3) and (Gabung = '001')) or

               ((Hitung = 3) and (Gabung = '  1')) then

               Kata := Kata + 'Seribu '

            else

               Kata := Kata + Angka[StrToInt(Tiga)+1];

          end;

if (hitung = 1) and (StrToInt(Gabung) > 0) then

       Kata := Kata + ' Milyar '

    else

       if (Hitung = 2) and (StrToInt(Gabung) > 0) then

          Kata := Kata + ' Juta '

    else

       if (Hitung = 3) and (StrToInt(Gabung) > 0) then

          begin

            if (Gabung = '001') or (Gabung = '  1') then

               Kata := Kata + ''

            else

               Kata := Kata + ' Ribu ';

          end;

    Hitung := Hitung + 1;

    One    := One + 3;

    Two    := Two + 3;

    Three  := Three + 3;

  end;

(* hapus penggunaan rupiah *)

  if useRupiah then begin

    if length(Kata) > 1 then Kata := Kata + ' Rupiah ';

if (StrToInt(Sen) > 0) and (StrToInt(Sen) < 20) then

       begin

         if StrToInt(Sen) < 10 then Sen := Copy(Sen, 2, 1);

         Kata := Kata + Angka[StrToInt(Sen)+1] + ' Sen';

       end

    else

       if StrToInt(Sen) > 19 then

          Kata := Kata + Angka[StrToInt(Sen1)+1] + 'Puluh ' +

                  Angka[StrToInt(Sen2)+1] + ' Sen';

  end;

  Result := Kata;

end;

untuk mendapatkan angka terbilang.
sValue: string; -> isi dengan angka berupa string dgn 2 koma di belakang. format : 0.00
const useRupiah: Boolean = true -> menggunakan rupiah atau tidak, default ya.

call MDI Child

Diarsipkan di bawah: myDelphi's — cyberheck @ 1212:02

procedure TFMainMenu.actLsUserExecute(Sender: TObject);
var
FLsUser : TFLsUser;
begin
if FindComponent('FLsUser') = nil then
begin
FLsUser := TFLsUser.Create(Self);
FLsUser.FormStyle := fsMDIChild;
FLsUser.Visible := True;
FLsUser.Show;
end else begin
if ActiveMDIChild.Name <> 'FLsUser' then
(FindComponent('FLsUser') as TFLsUser).BringToFront;
end;
end;

berfungsi untuk memanggil form MDI Child, tapi jika MDI Child sudah ada, cukup dibawa ke hadapan kembali.

3-Maret-2008

Backup / Restore

Diarsipkan di bawah: IB FireBird — Tag:, , — cyberheck @ 1111:49

Backup Database
Berikut ini akan disajikan contoh normal dari suatu operasi backup database.

gbak -v -t -user SYSDBA -password “masterkey” dbserver:c:dbdata.fdb c:backupdatabak.fbk

Kita lihat pada perintah di atas ada parameter -v -t yang artinya kita menggunakan mode transportable backup dan akan dilakukan verifikasi pada setiap action yang dilakukan pada operasi backup ini.

Restore Database
Berikut ini akan disajikan contoh normal dari suatu operasi restore database.

gbak -c -v -user SYSDBA -password masterkey c:backupdatabak.fbk dbserver:c:dbdata.fdb

LIMIT in SELECT statements in Firebird

Diarsipkan di bawah: IB FireBird — Tag:, — cyberheck @ 1111:46

The question is, is there a MySQL/PostgreSQL equivalent of LIMIT clause in Firebird? It is very useful in situations where you don’t get to keep the database cursor over multiple requests, i.e. in some web applications. In my scenario, I just want to the database to return the most relevant n rows of result, over a potential huge result set.

You used to need to write store procedures in Firebird to simulate LIMIT clause, but due to popular demand it has been included in Firebird 1.0. But Google did not yield useful results on the first page, except an relevant but somehow inaccurate information on IBPhoenix. Trial and error, and here’s what I found that was working with Firebird 1.0.3.

  SELECT FIRST x [SKIP y] … [rest of query]

It will then return x rows of result from the query, and optionally skip first y rows. For example, returning row 21-30 from a query would be something like this in Firebird:

  SELECT FIRST 10 SKIP 20 column1, column2, column3 FROM foo

The same statement in MySQL would be:

  SELECT column1, column2, column3 FROM foo LIMIT 10, 20

Again in PostgreSQL:

  SELECT column1, column2, column3 FROM foo LIMIT 20, 10

And let’s not get into the differences between Oracle, MS SQL Server and other RDBSMS. What a wonderful world of SQL :)

By the way, while Firebird is such an excellent open source RDBMS for both the high-end transaction-safe applications and low end embedded database, its documentation is seriously lacking. I am still using the Interbase 6 Beta’s Language Reference PDF to consult SQL syntax, and there is no way I can know all the great things they have added to Firebird 1.0/1.5. All I want is the one-volume reference manual that provides everything a developer needs, in the same style of MySQL and PostgreSQL. Hopefully the documentation will pick up in speed, while the coders move towards releasing 1.5 and developing 2.0.

26-Desember-2007

maling di kompleks

Diarsipkan di bawah: myDelphi's — cyberheck @ 77:31

gara-gara lama gak main internet sampe lupa kalo banyak kejadian yg belum ku tulis. makanya hari ini aku ingin bercerita kejadian tanggal 14 dec 07.

hari itu hujan turun dengan deras, dan jam menunjukkan jam 6.00 sore. tiba-tiba di pos satpam depan kok ribut-ribut. ternyata ada maling yg ke tangkep. huahahaha… seru banget kalo ngeliat maling itu di hajar habis-habis an ama penghuni kompleks.

emang aslinya gak tega. tapi sapa suruh jadi maling. hari gini kok masih ada orang yang menekuni profesi jadi maling huahahah….

maling 1

nah.. berikut ini adalah kejadian waktu polis datang ke tpk. tapi malingnya udah di bawa pergi. gak sempet mo ku photo :)

maling 2

« Tulisan Lebih Baru

Blog pada WordPress.com.