Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: D10, FireDAC, MySQL


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Aug 19, 2017 8:42 AM Last Post By: Jim Sawyer Threads: [ Previous | Next ]
Jim Sawyer

Posts: 214
Registered: 1/3/10
D10, FireDAC, MySQL  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 19, 2017 7:56 AM
The routine below simplifies what I was trying to accomplish in the previous post by stripping away all
of the conditions which complicate understanding what I was trying to communicate.

I am trying to do a routine that will allow me to set all Minder.Picked values to true based on
the Patient.Species value being 'CAN' where the two tables are joined by the fields
Minder.Patno and Patient.Patno which is the Patient file unique identifier.

{Code}
mQuery := TFDQuery.Create( AConnection );
with mQuery do
begin
Connection := AConnection;
SQL.Add( 'Update Minder ' );
SQL.Add( 'join Patient ' );
SQL.Add( 'on Minder.Patno = Minder.Patno ' );
SQL.Add( 'set Minder.Picked = true ' );
SQL.Add( 'where Patient.Species = ''CAN'' ' );
ExecSQL;
Free;
end;
Jim Sawyer

Posts: 214
Registered: 1/3/10
Re: D10, FireDAC, MySQL  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 19, 2017 8:42 AM   in response to: Jim Sawyer in response to: Jim Sawyer
I figured it out. The following routine works as hoped.

   mQuery := TFDQuery.Create( AConnection );
   with mQuery do
   begin
     Connection := AConnection;
     SQL.Add( 'Update Minder ' );
     SQL.Add( 'join Patient ' );
     SQL.Add( 'on Minder.Patno = Patient.Patno ' );
     SQL.Add( 'set Minder.Picked = true ' );
     SQL.Add( 'where Minder.Minded < :M and Minder.Period < 7 and Minder.Due between :S and :ES or Minder.Period >= 7 and Minder.Due between :St and :EL ' );
     SQL.Add( 'and Patient.Species = ''CAN'' ' );
     ParamByName('M').AsInteger := nMind;
     ParamByName('S').AsDate := dStart;
     ParamByName('ES').AsDate := dShortEnd;
     ParamByName('St').AsDate := dStart;
     ParamByName('EL').AsDate := dLongEnd;
     ExecSQL;
     Free;
   end;


Thanks.

Jim Sawyer wrote:

The routine below simplifies what I was trying to accomplish in the previous post by stripping away all
of the conditions which complicate understanding what I was trying to communicate.

I am trying to do a routine that will allow me to set all Minder.Picked values to true based on
the Patient.Species value being 'CAN' where the two tables are joined by the fields
Minder.Patno and Patient.Patno which is the Patient file unique identifier.

{Code}
mQuery := TFDQuery.Create( AConnection );
with mQuery do
begin
Connection := AConnection;
SQL.Add( 'Update Minder ' );
SQL.Add( 'join Patient ' );
SQL.Add( 'on Minder.Patno = Minder.Patno ' );
SQL.Add( 'set Minder.Picked = true ' );
SQL.Add( 'where Patient.Species = ''CAN'' ' );
ExecSQL;
Free;
end;
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02