🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.pascal
1 messages
1 total messages Started by MrDudek Fri, 18 Feb 2011 08:42
[FPC] PostgreSQL i TSQLQuery.Open
#93154
Author: MrDudek
Date: Fri, 18 Feb 2011 08:42
70 lines
2607 bytes
Witam

Już nie mam pojęcia gdzie szukać. Poniższy kod kompilowany fpc na
linuxie

<code>
{$mode objfpc}{$H+}

program test;

uses Classes, SysUtils, postgres, DB, SQLdb, PQConnection;

var
  C: TPQConnection;
  T: TSQLTransaction;
  Q: TSQLQuery;
begin
  C := TPQConnection.Create(nil);
  T := TSQLTransaction.Create(nil);
  Q := TSQLQuery.Create(nil);
  try
    try
      C.Hostname := 'localhost';
      C.DatabaseName := 'dbname';
      C.UserName := 'uname';
      C.Password := 'password';
      C.Transaction := T;

      T.Database := C;
      C.Open;
      writeln('C.Open');

      Q.Database := C;
      Q.Transaction := T;
      Q.SQL.Text := 'SELECT id FROM tbrand';

      Q.Open;
      writeln('Q.Open');
    except
      on E: Exception do writeln(E.Message);
    end;
  finally
    writeln('Finally 1');
    Q.Free;
    writeln('Finally 2');
    T.Free;
    C.Close;
  end;
end.
</code>

generuje następujące wyniki.

C.Open
Access violation
Finally 1
Finally 2
An unhandled exception occurred at $00147BF0 :
EAccessViolation : Access violation
  $00147BF0
  $080AC986
  $080A7E66
  $0016C917

Dla ciekawości, Q.ExecSQL działa poprawnie.
Będę wdzięczy jeśli ktoś podsunie mi jakieś sensowne pomysły.

--
Pozdrawiam
Andrzej Kosmala
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads