?
Solved

SQL Update statement for delphi7 and paradox

Posted on 2009-02-12
6
Medium Priority
?
1,047 Views
Last Modified: 2012-05-06
Hi experts,
In the sql statement attached, I would also like to update another field called "Part_of_no_of_Derived" in the point table in the same statement. I would actually like to increment this field by '1'. "Part_of_no_of_Derived" is an integer field in the point table.
I have tried different ways, one of the error I get during compile is "left side cannot be assigned to".
Would appreciate a quick solution. Thanks
function TAddDerivedPointsForm.ChangeAidRpt(aid: string): boolean;
begin
  with DMForm.Q_blank do
  begin
    SQL.Clear;
    SQL.Add('UPDATE point set Report = 4 WHERE ( P$RTUID = :vRtu ) AND (AID = :vaid )');
    ParamByName('vRtu').AsInteger := DMForm.T_RTURTUID.AsInteger;
    ParamByName('vaid').AsString := aid;
    try
      ExecSQL;
      result := TRUE;
      SQL.Clear;
      Close;
    except
      result := FALSE;
    end;
  end;
 
end;

Open in new window

0
Comment
Question by:QurbanDurrani
6 Comments
 
LVL 13

Assisted Solution

by:rfwoolf
rfwoolf earned 600 total points
ID: 23628535
You should post this question in the sql zone as well. Also note that if you're using the BDE to access your Paradox tables then the BDE uses LocalSQL which has some limitations on normal SQL -- you can access the LocalSQL help files in the BDE directory, usually located at C:\program files\common files\bde\
.
..in any event the error you are getting is not an SQL error it seems - it seems to be a compile error, change the left side's ".asInteger" and ".asString" to just ".value" and that should compile
0
 

Author Comment

by:QurbanDurrani
ID: 23628604
rfwoolf,
I changed the satement as attached, still get the "left side cannot be assigned error". The sql I posted with the question works just fine. It errors out when I try to update the second field as shown.

function TAddDerivedPointsForm.ChangeAidRpt(aid: string): boolean;
begin
  with DMForm.Q_blank do
  begin
    SQL.Clear;
    SQL.Add('UPDATE point set Report = 4, Part_of_no_of_Derived = :vNodrv WHERE ( P$RTUID = :vRtu ) AND (AID = :vaid )');
    ParamByName('vNodrv').Value := Inc(DMForm.T_PointPart_of_no_of_Derived.AsInteger);
    ParamByName('vRtu').AsInteger := DMForm.T_RTURTUID.AsInteger;
    ParamByName('vaid').AsString := aid;
    try
      ExecSQL;
      result := TRUE;
      SQL.Clear;
      Close;
    except
      result := FALSE;
    end;
  end;
 
end;

Open in new window

0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 23628635
Try using .value instead of .asinteger or .asstring (for the left side). it seems to be telling you that asinteger and asstring are readonly properties for ParamByName.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Accepted Solution

by:
bokist earned 800 total points
ID: 23629923
try this way

function TAddDerivedPointsForm.ChangeAidRpt(aid: string): boolean;
begin
  with DMForm.Q_blank do
  begin
    SQL.Clear;
    SQL.Add('UPDATE point set Report = 4, Part_of_no_of_Derived =Part_of_no_of_Derived + 1');
    SQL.Add(' WHERE ( P$RTUID = :vRtu ) AND (AID = :vaid )');
    ParamByName('vRtu').AsInteger := DMForm.T_RTURTUID.AsInteger;
    ParamByName('vaid').AsString := aid;
    try
      ExecSQL;
      result := TRUE;
      SQL.Clear;
      Close;
    except
      result := FALSE;
    end;
  end;
 
end;
0
 
LVL 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 600 total points
ID: 23630046
on which line are you getting "left side cannot be assigned error"

try
  ExecSQL;
  result := TRUE;
except
  result := FALSE;
end;

you don't need to close and update statement,
it normally doesn't return any rows
and actually sql.clear would allready have closed the dataset
any manipulation to the sql.text closes the dataset automatically
0
 

Author Comment

by:QurbanDurrani
ID: 23630521
Thanks to all for your responses.
The error was on the line:
ParamByName('vNodrv').Value := Inc(DMForm.T_PointPart_of_no_of_Derived.AsInteger);
I changed the line as shown in the attached code and it worked.
Thanks to all, I split the points.

Changed from Line:
ParamByName('vNodrv').Value := Inc(DMForm.T_PointPart_of_no_of_Derived.AsInteger);
 
Changed to Line:
ParamByName('vNodrv').AsInteger := DMForm.T_PointPart_of_no_of_Derived.AsInteger + 1;

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses
Course of the Month16 days, 13 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question