Senin, 30 November 2015

Drop Box Dinamis

...
type
  TString = class(TObject)
    private
      fStr: String;
    public
    constructor Create(const AStr: String) ;
    property Str: String read FStr write FStr;

...
constructor TString.Create(const AStr: String);
begin
  inherited Create;
  FStr := AStr;
end;


Proses ke combobox nya :
-------------------------------

cbDealer.Properties.Items.Clear;
  with DM.Q do
  begin
    Close;
    SQL.Text := 'select KD_DEALER,NAMA_DEALER from t_faktur'+
                ' where DATE_FORMAT(tgl_faktur, ''%Y%m%d'') between :tgl and :tgl2 group by KD_DEALER order by KD_DEALER';
    Params[0].AsString := FormatDateTime('yyyymmdd',dt.Date);
    Params[1].AsString := FormatDateTime('yyyymmdd',dt2.Date);
    Open;

    if DM.Q.RecordCount > 0 then
    begin
      while not eof do
      begin
        cbDealer.Properties.Items.AddObject(Fields[1].AsString,TString.Create(Fields[0].AsString));
      Next;
      end;
    end
    else
    begin
      cbDealer.Properties.Items.AddObject('SEMUA DEALER',TString.Create('ALL'));
    end;
  end;
 
  cbDealer.Text := '';

.......

Penggunaan pada saat combobox di pilih adalah sebagai berikut:

params() := TString(cbDealer.Properties.Items.Objects[cbDealer.ItemIndex]).Str;

Minggu, 10 Mei 2015

Oracle error 28001 - the password has expired

1. connect to database using sys users.
2. Sql > select * from dba_profiles; --> result PASSWORD_LIFE_TIME PASSWORD 180
3. Sql> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
4. Sql > select * from dba_profiles;
5. SQL> select 'alter user "'||d.username||'" identified by values '''||u.password||''';' c
from dba_users d, sys.user$ u
where d.username = upper('&&username')
and u.user# = d.user_id;

&&username = ganti dengan user nama user yg mau diaktifkan;

hasil querynya dipakai untuk proses update usernya: misalkan

SQL> alter user "SCOTT" identified by values 'F894844C34402B67';

terakhir cek query ini:

sql> select username,account_status from dba_users;

Selasa, 10 Maret 2015

ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

Below SQL will find your process

SELECT s.inst_id,
   'ALTER SYSTEM KILL SESSION '''||s.sid||','||s.serial#||''';' hasil,
   p.spid,
   s.username,
   s.program FROM   gv$session s
   JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id order by s.program;
Then kill it
ALTER SYSTEM KILL SESSION 'sid,serial#';
OR
some example I found online seems to need the instance id as well alter system kill session '130,620,@1';

Rabu, 04 Februari 2015

Oracle Split space delimited string with regexp SQL

SELECT regexp_substr('B 123 CC','[^ ]+', 1, 1) AS KodeWilayah,
                regexp_substr('B 123 CC','[^ ]+', 1, 2) AS Nomor,
                regexp_substr('B 123 CC','[^ ]+', 1, 3) AS KodeWilayahKab FROM DUAL;