Jump to content

TurboMagic

Members
  • Content Count

    235
  • Joined

  • Last visited

  • Days Won

    9

Posts posted by TurboMagic


  1. 1 hour ago, Uwe Raabe said:

    AFAIK, that won't work with Inserts via SQL (at least I never did it that way). The reason may be, that an INSERT query will never retrieve any fields like a SELECT query. There simply are no fields you can get the ID from.

     

    The usual way you have something like SELECT * FROM MYTABLE which retrieves all fields including the ID field. For adding a new record you just call Append or Insert, set the field values as needed and call Post. If everything is set up correctly, the new ID should then be available in the PERSON_ID field.

    I just tried this, but it does not work. It throws an EDatabaseError exception that the PERSON_ID must not be null.
    That field is the primary key and as soon as I delcare it as primary key the DB management tool adds a not null constraint.
    The exception occurs on the Post line.

     

    My code looks like this:

    FQuery.SQL.Text := 'select Person_ID, LastName, FirstName from persons';
    
    FQuery.Open;
    FQuery.Append;
    
    FQuery.FieldByName('LastName').AsString     := 'Doe';
    FQuery.FieldByName('FirstName').AsString     := 'John';
    
    FQuery.Post;
    Result := FQuery.FieldByName('Person_ID').AsInteger;

    The generator value us applied via some ACTIVE BEFORE  INSERT trigger by the way...


  2. 4 minutes ago, Uwe Raabe said:

    AFAIK, that won't work with Inserts via SQL (at least I never did it that way). The reason may be, that an INSERT query will never retrieve any fields like a SELECT query. There simply are no fields you can get the ID from.

     

    The usual way you have something like SELECT * FROM MYTABLE which retrieves all fields including the ID field. For adding a new record you just call Append or Insert, set the field values as needed and call Post. If everything is set up correctly, the new ID should then be available in the PERSON_ID field.

    Thanks! Sounds helpfull and I'll try this later!


  3. The developer of FireDAC somewhere recommended this one:

    FireDAC.Comp.Client.TFDCustomConnection.GetLastAutoGenValue

     

    But that also retrieves the last value of the generator and thus should better be avoided for most RDMS, at least in multi user scenarios.

    Somewhere else adding this to the insert statement is recommended: RETURNING ID INTO :ID
    This would return the value in a field named ID. But: FireDAC doesn't seem to support this. If I add this to the insert the Prepare
    call throws an error: Dynamic SQL error. Error code -104, Token unknown, Line 1 column 138.

    Where column 138 (at least when I copy out the SQL text in the debugger) is one of the parameters before...


  4. In my case I have used this one:

     

    FQuery.SQL.Text := 'insert into MYTABLE ' +
                       '(LASTNAME, FIRSTNAME) ' +
                       'VALUES (:NEW_LASTNAME, :NEW_FIRSTNAME);';
    
    FQuery.UpdateOptions.AutoIncFields := 'PERSON_ID';
    FQuery.CachedUpdates := false;
    FQuery.Prepare;

    Later on I fill in values like this, which works and created unique IDs:

      FQuery.ParamByName('NEW_LASTNAME').AsString  := 'Doe';  
      FQuery.ParamByName('NEW_FIRSTNAME').AsString := 'John';
      FQuery.ExecSQL;

    But how to retrieve the generated new PERSON_ID?


  5. On 4/12/2019 at 11:56 AM, Uwe Raabe said:

    There actually is some documentation about this: Auto-Incremental Fields (FireDAC)

    This is exactly the help topic I don't fully understand!
    I'm having the same issue right now, but with a Firebird database.
    The help topic doesn't show me (at least not in a form I can understand) hot to access the generated value after calling ExecSQL.
    And the sample linked I don't understand either.


  6. Your idea is of course how one might find it, if it shows in a reduced demo.
    My first question would be: what's different between those two forms that one shows this
    problem and the other works as expected.

     

    So which properties or behavior can influence that?

    Both forms have set:

    - BorderIcons := [biSystemMenu,biMinimize,biMaximize]

    - BorderStyle := bsSingle

    - DefaultMonitor := dmActiveForm

    - FormStyle := fsNormal

    - PopupMode := pmNone also pmAuto doesn't change this

    - PopupParent := nil, but also setting it to TCustomForm(AOwner) in the constructor didn't change anything

    - Position := poOwnerFormCenter

    - WindowState := wsNormal

     

    The form itsself only has an OnShowEvent, where one control gets set the focus.

     

    Any other properties known which might play a role here?


  7. I might try later on, but it might prove difficult. I already tried to do a minimal demo for something else I saw in that project and reported as QP 38385,
    but the minimal demo failed to show the effect. In the German DP somebody said something that all new forms seem to have some popupparent issue
    as if always the main form would be used as popup parent...

     

    I haven't done any investigation of that theory yet, as I just read it. Could that be related?


  8. Strange! I found this post because I have exactly the same issue, but the solution above doesn't fix my issue 😞

    Given:

     

    - D11.1

    - a datamodule containing a TTaskDialog

    - a main form

    - two other forms, each having a button for showing that TTaskDialog

    - both forms have the same popup mode, border style etc.

    - both are created at runtime and shown via ShowModal and when created both get the main form set as owner

    - in one form the TaskDialog shows in the foreground, in the other it stays in the background

    - calling execute with self.handle as param doesn't help

     

    Now I copied the Taskdialog from the datamodule directly on the form where it doesn't work and called that directly.

    Result: still doesn't work 😞

     

    Anybody any clue?


  9. Hello,

     

    this is to let you know that there was a open source collaboration project started to create a formal specification of
    the Delphi language in Backus-Naur format (https://en.wikipedia.org/wiki/Backus–Naur_form).

     

    It is hosted on GitHub here: https://github.com/MHumm/DelphiGrammar

    David Hoyle contributed his Delphi 10.3 version as a starting point.

    If you want to participate in this endeavor, which might help developers of language tools, just
    drop me a message with your GitHub account name and I'll give you commit permission.

    Either via this forum or as an issue on that GitHub project.

     

    Currently I picked Apache 2.0 as license, but if necessary we can discuss to use something else.

     

    Cheers

    TurboMagic

    • Like 1

  10. Good news: DEC V6.4.1 jsut got released.

    https://github.com/MHumm/DelphiEncryptionCompendium/releases/tag/V6.4.1

     

    What is this?

    DEC, also known as Delphi Encryption Compendium is a cryptography library for Delphi and FPC.

     

    What's new in V6.4.1?

    This is mainly a bugfix release with these topics:

    • fixed some regression which produced wrong output at least for the 2DES encryption algorithm when used with CBC block chaining kode
    • improved layout and handling of GCM block chaining mode in Cipher_FMX demo application
    • added a new Cipher_Console_KDF demo application
    • fixed and improved the documentation, especially about wrongly written GCM properties

     

    What's the plan for the future?

    1. Have a short rest 😉
    2. Require Delphi 10.1 Berlin instead of D2009 as minimum compatible version
    3. The rest of the plan (which exists) will not be disclosed yet.

     

    Cheers

    TurboMagic

    • Like 4

  11. On 9/17/2021 at 12:49 PM, Wagner Landgraf said:

    I think the "problem" with Package Manager is that is has to be widely adopted by the community to be very useful. Because the key is that relevant libraries and 3rd parties are available in the package manager. "Unfortunately" Embarcadero is pushing GetIt so it's unlikely we will have a different one being widely adopted, I guess.

    There are concrete (but not public yet) plans to improve GetIt. One of the items will make it easier to update contents which has already been published via GetIt so it might attrack more publishers.


  12. On 9/17/2021 at 9:58 AM, Jasja said:

    Hello Angus,

     

    Oke, thank you. I don't have a SVN client installed. I've tried it once but it created too many dependensies too my likeing.

    Maybe it's an idea too deposit ICS into github.com ? Then it's easy for users like me to download the latest snapshot as zip file, while also easy to maintain with git.

    Anyway, thanks so much. I will wait until the zip file is available on the site.

     

     

    Regards,

     

    I don't know which SVN client you used, but Tortoise SVN integrates nicely into Windows Explorer and works quite well...

    After installing that one create a new folder and right click on it, select "SVN Checkout" and enter the SVN Url of ICS and things should be on your computer a few seconds later...

×