[fpc-pascal] Boring problem when I try to create a database using SQLdb (again)

silvioprog silvioprog at gmail.com
Sat May 16 19:19:52 CEST 2015


On Sat, May 16, 2015 at 1:51 PM, Michael Van Canneyt <michael at freepascal.org
> wrote:
>
> On Sat, 16 May 2015, silvioprog wrote:
>
>> [...]
>>
> Set the stoUseImplicit option on the transaction:
>
> VCon.Transaction.options:=[stoUseImplicit]


Thanks for the fast reply buddy.

I have another problem: my FPC version is 2.6.4, and this option is not
available in this version. =/

But just to test, I did it using FPC from trunk, and the following code
returned another error:

[code]
var
  VCon: TPQConnection;
begin
  VCon := TPQConnection.Create(nil);
  VCon.Transaction := TSQLTransaction.Create(VCon);
  try
    VCon.Transaction.Options := VCon.Transaction.Options + [stoUseImplicit];
    VCon.HostName := '127.0.0.1';
    VCon.DatabaseName := 'postgres';
    VCon.UserName := 'postgres';
    VCon.Password := 'postgres';
    VCon.ExecuteDirect(
      'CREATE DATABASE "09_0025" WITH ENCODING=''UTF8'' ' +
      '  OWNER="postgres" TEMPLATE="template1" ' +
      '  LC_COLLATE=''English_United States.1252'' ' +
      '  LC_CTYPE=''English_United States.1252'' '+
      '  CONNECTION LIMIT=-1 TABLESPACE="pg_default"');
  finally
    VCon.Free;
  end;
end;
[/code]

Error:

#0 PQCONNECTION$_$TPQTRANS_$__$$_REGISTERCURSOR$TPQCURSOR at :0
#1
PQCONNECTION$_$TPQCONNECTION_$__$$_EXECUTE$TSQLCURSOR$TSQLTRANSACTION$TPARAMS
at :0
#2 SQLDB$_$TSQLCONNECTION_$__$$_EXECUTEDIRECT$ANSISTRING$TSQLTRANSACTION at
:0
#3 SQLDB$_$TSQLCONNECTION_$__$$_EXECUTEDIRECT$ANSISTRING at :0
#4 TFORM1__BUTTON1CLICK(0x1dc248, <error reading variable>) at Unit1.pas:45
...


> Why methods like "ExecuteDirectPG", "CheckConnectionStatus",
>> "CheckResultError", "TranslateFldType" and "GetExtendedFieldInfo" are not
>> declared as protected methods?
>>
>
> No particular reason. That can be changed.
>
> Michael.


Very nice. I can create a patch to move this methods to the protected area.
=)

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150516/bfcceb9f/attachment.html>


More information about the fpc-pascal mailing list