We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

SQL Update statement for delphi7 and paradox

QurbanDurrani
on
Medium Priority
1,227 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

Comment
Watch Question

Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
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

Commented:
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.
Commented:
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;
Geert GOracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
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

Author

Commented:
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

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.