[Lazarus] Postgres database again...

Damien Gerard milipili at shikami.org
Tue May 27 13:45:42 CEST 2008


Le May 27, 2008 à 1:05 PM, Dave Coventry a écrit :

> Graeme,
>
> If I do as Damien suggests and use:
>
> PQConnection1.ExecuteDirect(''INSERT INTO Foo (Caption) VALUES (''A
> caption'') RETURNING uID;')
>
> and, assuming it returns the field uID, how do I place the uID field
> into an edit box(read only of-course!).
>

As Graeme said through his links. I think they are very good.
With the keyword RETURNING, Your INSERT/UPDATE will have the same  
behavior than a SELECT statement.

I forgot to mention that you should prefer full column names (SELECT  
Col1,Col2... FROM...) instead of `*` (SELECT * FROM...)


> On Tue, May 27, 2008 at 12:43 PM, Graeme Geldenhuys
> <graemeg.lists at gmail.com> wrote:
>> Dave Coventry wrote:
>>> Okay, just supposing that I have the SQL Queries working ok, how  
>>> do I
>>> access the fields from inside Lazarus?
>>>
>>> If I query using "SELECT * FROM registration", where do the  
>>> resultant
>>> fields end up?
>>>
>>> Or perhaps I was on the right track and they ARE accessible from
>>> SQLQuery1.Fields[i].AsString?
>>
>>
>> Here are step-by-step instructions in using Databases with Lazarus
>> (normal Delphi style).
>>
>> http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=fcldbnotes
>> http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi? 
>> file=index&unit=sqldb
>>
>>
>> A quick search on the Lazarus wiki found the following. I think they
>> might be handy as well.
>>
>> http://wiki.lazarus.freepascal.org/Contacts_Database
>> http://wiki.lazarus.freepascal.org/Databases
>> http://wiki.lazarus.freepascal.org/Databases_in_Lazarus
>>
>>
>> Here is a post I found in the lazarus mailing list. There are many  
>> more.
>>
>>
>> ------------[ copy ]----------------
>> On Mon, 4 Feb 2008, el stamatakos wrote:
>>
>>>>
>>>> Hi,
>>>> I am working with a database and I am doing the following
>>>>
>>>> tFile:string;
>>>>
>>>> tFileName:=mainForm.SQLQuery1.FieldValues['tFileName'];
>>
>> You should never use FieldValues, this is a horrible construct  
>> which Delphi
>> introduced for Visual Basic  "compatibility".
>>
>> You should use
>>  tFileName:=mainForm.SQLQuery1.FieldByName('TFileName').AsString;
>> instead.
>>
>> Michael.
>> ------------[ end ]----------------
>>
>>
>> Regards,
>>  - Graeme -
>>
>>
>> _______________________________________________________
>> fpGUI - a cross-platform GUI toolkit using Free Pascal
>> http://opensoft.homeip.net/fpgui/
>>
>>
>> _______________________________________________
>> Lazarus mailing list
>> Lazarus at lazarus.freepascal.org
>> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus



--
Damien Gerard
milipili at shikami.org

"Intelligence is 10 million rules."
    -- Douglas Lenat









More information about the Lazarus mailing list