Ask Your Question

Please give macro for For following update SQL: [closed]

asked 2016-08-13 09:19:35 +0200

koolninja gravatar image

update "Total" set "Total"."IssueTotal" = (SELECT SUM( "Issue"."Quantity" ) FROM "Issue" where "Issue"."ProductName"="Total"."ProductName"GROUP BY "Issue"."ProductName"); update "Total" set "Total"."RecieptTotal" = SELECT SUM( "Reciept"."Quantity") FROM "Reciept" WHERE "Total"."ProductName" = "Reciept"."ProductName" GROUP BY "Reciept"."ProductName"; update "Total" set "Total"."Balance" = SELECT SUM( "Total"."RecieptTotal" - "Total"."IssueTotal" ) FROM "Total" GROUP BY "Total"."ProductName"

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Ratslinger
close date 2016-08-15 19:29:40.226691

1 Answer

Sort by » oldest newest most voted

answered 2016-08-13 17:17:36 +0200

Ratslinger gravatar image

This is three different statements. You already have the basis for a macro to execute these (here). Just replace this line:

sSQL = "UPDATE ""Total"" SET ""Total"".""IssueTotal"" =" &_
     " (SELECT SUM( ""Issue"".""Quantity"") FROM ""Issue""" &_
     " WHERE ""Issue"".""ProductName""=""Total"".""ProductName""" &_
     " GROUP BY ""Issue"".""ProductName"")"

with each of your update statements surrounded by " (quote) marks and double " around table and field names. You must run each separately. Here is the first:

  sSQL =  "update ""Total"" set ""Total"".""IssueTotal"" = (SELECT SUM( ""Issue"".""Quantity"" ) FROM ""Issue"" where ""Issue"".""ProductName""=""Total"".""ProductName"" GROUP BY ""Issue"".""ProductName"")"

And execute each individually with:

oStatement.executeUpdate( sSQL )
edit flag offensive delete link more


Thanks to clear about macro formatting..

koolninja gravatar imagekoolninja ( 2016-08-15 07:47:00 +0200 )edit

Question Tools

1 follower


Asked: 2016-08-13 09:19:35 +0200

Seen: 54 times

Last updated: Aug 13 '16