Mega Code Archive

 
Categories / Delphi / Examples
 

Vets , animal planet and the firefighters on Discovery

Title: vets , animal planet and the firefighters on Discovery Question: if you want to learn more you have to dig more so if you realy sick of vcl or clx what you do ? go to the api (win322 or the unix api ) if you realy sick of all those components (IbObjects,FreeIb,FreeIb+,IBX...) what you do ? go to the ib api (*bird api) aka gds32.dll or libgds.so and start to dig first what the hack is with the title well look around everybody have an animal around on my linux box i have penguins in the perl box i have camels and some time lamers(lamas) pythons (My god is full of animals !!!) and now the interbase (hacka groton database Zystem) transformed in to a bird a fire one so from now i will call myself vet not hacker wats about fire i thik that borland had made big mistakes when they dumped employees.gdb out of them garden (i mean when they dumped people not the database) because what the hack is on sourceforge 2 projects and 2 rabits one is a bird and the other one is a ....(i dont know what is bu is tubointerbase faster than enterprise delphi) and there they write to feed only one rabit and leave the orther one the other one is certified (its'a good easter rabit egg) they dumped the turboib and then they took it back is still open but they are twin headed why they do it this way .......??? is bad for developers and is bad for market and for (h)open (in )source the same they should take back thouse people and build one project instead of one when i go on mysql.com i see one project and one download the same on the sourceforge and not to tell you that the 2 projects will NOT be compatible you take the gdb from one and move to the other and will not work Another issue is the comunity borland on the ib side is a little no move they should pay the ib handbook mainteiners first ... In the final i'm a little dissapointed about borland because they could make ib scream (i mean they could make it the best db on the planet ) if they push the improovements ahead look at the oracle oracle.com how the oracle push things ... any way i way to make the *bird screm is using the api here we go ....... Answer: after reading the doX at www.lovedata.com { here u'll find a copy of that document } wanted to try to code an little eXample with the use of ibApi like some AttachTo a db and then to play with transactions at the API level i took the funtions from that site and after tweeking a little bit i have done the following function AttachDatabase(DatabaseName, userName, password: string): isc_db_handle; var Buffer: array[0..1023] of char; BufPtr: integer; dbName: array[0..255] of char; status: status_vector; IBerrCode: isc_status; dbHandle: isc_db_handle; begin StrPCopy(dbName, DatabaseName); dbHandle := nil; {init the Database Param buffer} FillChar(Buffer, sizeof(Buffer), #0); BufPtr := 0; Buffer[0] := char(isc_dpb_version1); inc(BufPtr); Buffer[BufPtr] := char(isc_dpb_user_name); inc(BufPtr); Buffer[BufPtr] := char(length(username)); inc(BufPtr); StrPCopy(@Buffer[BufPtr], username); inc(BufPtr, length(username)); Buffer[BufPtr] := char(isc_dpb_password); inc(BufPtr); Buffer[BufPtr] := char(length(password)); inc(BufPtr); StrPCopy(@Buffer[BufPtr], password); inc(BufPtr, length(password)); {Attach Database Call } try IBerrCode := isc_attach_database(@status, 0, @DBName, @DBHandle, BufPtr, @Buffer); except if IBerrCode 0 then HandleIBErrors(@status); end; Result := dbHandle; end; once i made the function i needed to try it look out mam i can Attach: procedure TForm1.bAttachDbClick(Sender: TObject); begin LoadApi(); dbhandle:=AttachDatabase('C:\Program Files\InterBase Corp\InterBase\examples\database\employee.gdb','sysdba','masterkey'); end; first the gds32.dll must be loadeed somewhere in mem this is done in loadApi func in the ibProcs.pas unit after that lets see what version we have there procedure TForm1.Button1Click(Sender: TObject); begin memo1.clear; Memo1.lines.add('Version:'+GetVersion); memo1.Lines.add('Site:'+getDBSitename) end; here we get the info stuff (i took this from freeIB) function GetVersion: String; var local_buffer: array[0..1024 - 1] of Char; DBInfoCommand: Char; status: status_vector; begin DBInfoCommand := Char(isc_info_version); isc_database_info(@Status, @dbHandle, 1, @DBInfoCommand, 1024 , local_buffer); local_buffer[5 + ord(local_buffer[4])] := #0; result := String(PChar(@local_buffer[5])); end; function GetDBSiteName: String; var local_buffer: array[0..1024 - 1] of Char; p: PChar; DBInfoCommand: Char; status: status_vector; begin DBInfoCommand := Char(isc_info_db_id); isc_database_info(@Status, @dbHandle, 1, @DBInfoCommand, 1024, local_buffer); p := @local_buffer[5 + ord(local_buffer[4])]; // DBSiteName Length p := p + ord(p^) + 1; // End of DBSiteName p^ := #0; // Null it. result := String(PChar(@local_buffer[6 + ord(local_buffer[4])])); end; after playing with ataching we must see how the transactions should worK procedure TForm1.bStartTransactionClick(Sender: TObject); var errcode:integer; status: status_vector; begin teb.db_ptr:=@DBHandle; teb.tpb_len:=0; teb.tpb_ptr:=nil; Transaction:=StartTransaction(teb); end; function StartTransaction (const tebarray:array of isc_teb):isc_tr_handle; var status:status_vector; IBerrCode:isc_status; begin result:=0; IBerrCode:=isc_start_multiple(@status,@result,1,@tebarray); //IBerrCode:=isc_start_transaction(@status,@result,1,@dbhandle,1,@tebarray); if IBerrcode 0 then HandleIBErrors(@status);