[Lazarus-es] Concectividad a bases de Datos

Claudio Romero clauslack en gmail.com
Jue Nov 4 20:49:39 CET 2010


Funciona, pero no del modo correcto

Aqui hay un ejemplo
http://bugs.freepascal.org/view.php?id=12956

**--
procedure TForm1.Button1Click(Sender: TObject);
begin
    //without try .. finally ..
    //for this example uses table p_ucm_a with blob field in linux firebird
    //I Use a BLOB field, because before this issue caused 'Invalid BLOB ID'
    if not opendialog1.Execute then exit;
    IBConnection1.open;
    //--
    if SQLTransaction1.Active then showmessage('SQLTransaction1.active=true')
    else showmessage('SQLTransaction1.active=false');
    if SQLTransaction2.Active then showmessage('SQLTransaction2.Active=true')
    else showmessage('SQLTransaction2.Active=false');
    SQLQuery2.close;
    SQLQuery2.sql.clear;
    SQLQuery2.sql.add('select * from p_ucm_a');
    SQLQuery2.Transaction:= SQLTransaction2;
    if not SQLTransaction2.active then SQLTransaction2.StartTransaction;
    SQLQuery2.open;
    //--
    if SQLTransaction1.Active then showmessage('After SELECT
(SqlQuery2) SQLTransaction1.Active=true')
    else showmessage('After SELECT (SqlQuery2) SQLTransaction1.Active=false');
    if SQLTransaction2.Active then showmessage('After SELECT
(SqlQuery2) SQLTransaction2.Active=true')
    else showmessage('After SELECT (SqlQuery2) SQLTransaction2.Active=false');
    SQLQuery1.close;
    SQLQuery1.sql.clear;
    SQLQuery1.sql.add('update p_ucm_a set memo=:memo where clave_adhe=4');
    SQLQuery1.Transaction:=SQLTransaction1;
    SQLQuery1.params.paramByName('memo').LoadFromFile(opendialog1.filename,ftBlob);
    if not SQLTransaction1.active then SQLTransaction1.StartTransaction;
    SQLQuery1.ExecSQL;
    SQLTransaction1.Commit;
    SQLTransaction2.Commit;
    //
end;

*--

La segunda consulta usa la primera transacción, en vez de la segunda
transacción. Lo que da unos lios terribles en algunos casos, yo tenia
errores cuando maneja BLOBs.




More information about the Lazarus-es mailing list