Tried this but just got an error.
CASE WHEN "Account Transactions"."Income/Expense" is"Income" THEN "Account Transactions"."Transaction Amount" IS - "Account Transactions"."Transaction Amount";
Would appreciate any help on this one.

Code: Select all
UPDATE "Account Transactions" SET "Account Transactions"."Transaction Amount" = - "Account Transactions"."Transaction Amount"
WHERE "Account Transactions"."Income/Expense" = 'Income'
Code: Select all
UPDATE account_transactions SET amount = - amount WHERE income_or_expense = 'Income'
Code: Select all
UPDATE "Account Transactions" SET "Transaction Amount" = CASE
WHEN "Income/Expense" = 'Expense' AND "Transaction Amount" > 0 THEN "Transaction Amount"*(-1)
ELSE "Transaction Amount"
END;
Code: Select all
Sub Change_To_Negative (oEvent As Object) 'Button > Execute > event
oForm = oEvent.Source.Model.Parent 'MainForm from Button
oStatement = oForm.ActiveConnection.createStatement() 'Create an SQL statement object
sSQL = "UPDATE ""Account Transactions"" SET ""Transaction Amount"" = CASE "
sSQL = sSQL & "WHEN ""Income/Expense"" = 'Expense' AND ""Transaction Amount"" > 0 "
sSQL = sSQL & "THEN ""Transaction Amount""*(-1) "
sSQL = sSQL & "ELSE ""Transaction Amount"" "
sSQL = sSQL & "END"
oStatement.executeUpdate( sSQL ) 'Execute the SQL command
oForm.reload
oForm.last
End Sub
True.rudolfo wrote:...the enclosing of column/table names with double quotes is optional (if you have chosen well behaved names).
All of this to say that captkirk apparently created case-sensitive names (delimited identifiers) using the Base GUI so double-quotes are necessary. The slashes, spaces, case-sensitivity, and any other Unicode character are fair-game within double-quotes. Unfortunately, delimited identifiers require double-double-quotes within macros, as demonstrated above. This creates some debugging and readability challenges just as rudolfo highlights.rudolfo wrote:Of course a slash which would be interpreted as the division operator and a space in the name, [so the entire name] must be escaped with...double quotes.
rudolfo wrote:...the options to work with [Base+HSQLDB] without the need for quotes.
rudolfo wrote:...I only wanted to make the point that SQL is close to the human language if you are lucky to learn it with a decent dialect like Oracle or MySQL or other engines that don't force you into a long search for the SELECT, UPDATE or WHERE.