delphi oracle dataset getvariable,declareandset
function getComputerControl(pID: Integer;pComputerName:String): String; var dset: TOracleDataSet; begin dset:=TOracleDataSet.Create(nil); try dset.Session := Session; dset.SQL.Text := 'begin ' + ' :result := QD.ComputerControl(vid => :vid,vterminaladi => :vterminaladi); '+ 'end;'; dset.DeclareVariable('result',otString); dset.DeclareAndSet('vid',otInteger,pID); dset.DeclareAndSet('vterminaladi',otString,pComputerName); dset.Open; Result := dset.GetVariable('result'); finally dset.Close; dset.Free; end; end;
delphi runtime create oracle dataset
Hi,
Large and complex in the projects , i will give a simple and useful example of an oracle dataset for avoid confusion.
function getRowCount:Integer; var dset : TOracleDataSet; begin try dset := TOracleDataSet.Create(nil); dset.Session:= OracleSession1; dset.SQL.Text:= 'select count(1) from QD.FIXED_TABLE'; dset.Open; Result:= dset.Fields[0].AsInteger; finally dset.Close; dset.Free; end; end;
delphi oracle event
Hi everyone,
Today , we will examine the dbms_alert.signal procedure of oracle database.We use “TOracleEvent” object for catching oracle events in Delphi. Firstly , we should configure object names and object types. You can see at below picture.
procedure TForm1.FormActivate(Sender: TObject); begin Event.Start; end; procedure TForm1.FormClose(Sender: TObject); begin Event.Stop; end; procedure TForm1.EventEvent(Sender: TOracleEvent; const ObjectName: String; const Info: Variant); var I: Integer; begin if CompareStr(ObjectName,'CHANGE')=0 then begin if VarIsArray(Info) then begin for I:=0 to VarArrayHighBound(Info,1) do begin if (Info[I] = 'UPDATE') then ShowMessage('Update table'); if (Info[I] = 'INSERT') then ShowMessage('Insert table'); end; end; end end;
Below is an example use of dbms_alert.signal
CREATE OR REPLACE TRIGGER QD.FIXED_TABLE AFTER INSERT OR UPDATE ON QD.FIXED_TABLE FOR EACH ROW DECLARE msg VARCHAR2(128); BEGIN IF INSERTING THEN msg := 'INSERT'; dbms_alert.signal('CHANGE', msg); ELSIF UPDATING THEN msg := 'UPDATE'; dbms_alert.signal('CHANGE', msg); END IF; END;
delphi mutex
Programın birden fazla açılmasını engellemek veya kontrol altına almak için mutex komutu kullanılır.
program MutexApp; uses Forms, Windows, Unit1 in 'Unit1.pas' {Form1}; {$R *.res} var Mutex : THandle; begin Mutex := CreateMutex(nil, True, 'MutexApp.EXE'); if (Mutex = 0) OR (GetLastError = ERROR_ALREADY_EXISTS) then begin Application.MessageBox(' Program kullanımda !!! ','Hata',MB_OK+MB_ICONWARNING); end else begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; if Mutex <> 0 then CloseHandle(Mutex); end; end.
delphi exe information
procedure TForm1.VersionInfo; const InfoStr : array [1..11] of String = ( 'CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFilename', 'ProductName', 'ProductVersion', 'Comments', 'Author' ); var pLen, j , pHandle : Cardinal; VersionBuf, VersionValue : PChar; begin pHandle:=GetFileVersionInfoSize(PChar(Application.ExeName),pHandle); if pHandle > 0 then begin VersionBuf:=AllocMem(pHandle); GetFileVersionInfo(PChar(Application.ExeName),0,pHandle,VersionBuf); For J:=1 to 11 do begin If VerQueryValue(VersionBuf, PChar('StringFileInfo\041F04E6\'+InfoStr[j]), Pointer(VersionValue), pLen) Then ListBox.Items.Add(InfoStr[j] +' = '+VersionValue) ; end; FreeMem(VersionBuf,pHandle); end else ListBox.Items.Add('Versiyon bilgisi bulunamadı') ; end;
delphi lisans hatası
“Borland License information was found, but it is not valid for delphi
You can not run delphi without this information. “ hatasını verirse aşağıdaki işlemleri yaparak çözebilirsiniz.
1-) “C:\documents and settings\username\ .borland \registry.slm” dosyasını siliniz
2-) “C:\program files\borland\delphi7\bin\D7Reg.exe” çalıştırınız.
3-) D7Reg.exe kurulumu bitirdikten sonra Delphi7’yi çalıştırınız.
delphi uygulamayı başlangıca atma (Windows StartUp)
uses Registry; procedure writeStartUp; var fRegistry: TRegistry; begin fRegistry:=TRegistry.Create; try // Geçerli kullanıcı için HKEY_CURRENT_USER // Bilgisayar için HKEY_LOCAL_MACHINE fRegistry.RootKey := HKEY_CURRENT_USER; fRegistry.OpenKey('\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', True); fRegistry.WriteString('Uygulamam','C:\Project1.exe'); fRegistry.CloseKey; finally fRegistry.Free; end; end;
delphi procedure,function bildirimleri(overload,forward)
forward:
Bazı durumlarda bir procedür veya bir fonksiyonu çağırmadan önce o procedure/function varlığını derleyiciye bildirmemiz gerekir.Tanımlandığı yerden daha önce çağrılıyorsa Undeclared Identifier hatasını verir.Basit bir örnekle açıklarsak: iki procedürümüz olsun.(procedure d1, procedure d2)
procedure d1;
begin
…
end;
procedure d2;
begin
…
end;
Böyle bir tanımlamada d2 procedüründen d1 çağrılabilir ama d1 procedüründen d2 çağrılamaz.Bu sorunu çözmek için aşağıdaki şekilde tanımlama yaparak çözeriz.
procedure d2; forward;
procedure d1;
begin
d2;
end;
procedure d2;
begin
d1;
end;
overload : Overload olayına aynı procedure/funtion ‘da farklı parametreler girmemiz veya aynı olay için farklı sayıda parametre girmemiz gibi durumlar meydana geldiğinde ihtiyaç duyulur.
örnek tanımlama ise:
procedure appmessage(metin: string; adet: integer); overload
procedure appmessage(metin: string); overload
delphi convert bmptojpg
uses Jpeg,Graphics; procedure Convert(); var Bitmap : TBitmap; JpegImg : TJpegImage; begin Bitmap := TBitmap.Create; try Bitmap.LoadFromFile('c:\a.bmp'); JpegImg := TJpegImage.Create; try JpegImg.Assign(Bitmap); JpegImg.SaveToFile('c:\a.jpg'); finally JpegImg.Free; end; finally Bitmap.Free; end; end;
delphi inifile kullanımı
Örnek ini dosyamız aşağıdaki gibi olsun:
[FORMLISTE] GENEL_BASLIK=DENEMEE GENEL_LOGO=Logo1.png GENEL_ACILIS=1 FormCaption=Form1 [LISTE] Kisi1=AD-SOYAD1 Kisi2=AD-SOYAD2 Kisi3=AD-SOYAD3 Kisi4=AD-SOYAD4 [Transfer] Transfer_Onay=1 Transfer_Kisi_ID=2
Inifile işlemleri için basit bir örnek:
uses IniFiles; procedure IniIslemleri(); var IniF: TIniFile; begin IniF:=TIniFile.Create('c:\deneme.ini'); try // Yazma İşlemi IniF.WriteString('FORMLISTE','FormCaption',Self.Caption); // Okuma İşlemi ShowMessage(IniF.ReadString('FORMLISTE','FormCaption','Bos Geldi')); // "FORMLISTE" başlığı altındaki genel tanımlamaları getirir. // Dönecek Değerler : GENEL_BASLIK,GENEL_LOGO,GENEL_ACILIS,FormCaption IniF.ReadSection('FORMLISTE',Listbox2.Items); // "Deneme.ini" içindeki genel başlıkları getirir. // Dönecek Değerler : FORMLISTE,LISTE,Transfer IniF.ReadSections(ListBox1.Items); // "FORMLISTE" başlığı altındaki genel tanımlamaları ve değerlerini getirir // Dönecek Değerler : // -------------------- // GENEL_BASLIK=DENEMEE // GENEL_LOGO=Logo1.png // GENEL_ACILIS=1 // FormCaption=Form1 IniF.ReadSectionValues('FORMLISTE',ListBox3.Items); // "TRANSFER" başlığı altındaki Title1 değerini siler. IniF.DeleteKey('TRANSFER','Title1'); finally IniF.Free; end; end;