[Solved] Put Formula in Column - Calculated Column

Creating tables and queries
Post Reply
peterwt
Posts: 35
Joined: Mon Apr 19, 2010 4:04 pm
Location: South Wales

[Solved] Put Formula in Column - Calculated Column

Post by peterwt »

I have a Table, Table1, with two Columns, a and b both integers. I want a third Column Total which is a + b. You can run a Query to give the Totals but this does not change the Table. I want to be able to enter values for a and b and have Total created when the Record is added. Similar to a spread sheet where the formula is in a cell.

I have seen in other applications you can use SQL

Code: Select all

ALTER TABLE "Table1" ADD COLUMN "Total" INTEGER AS ("a" + "b") PERSISTED
I get error "Unexpected token: AS in statement [AS]"

Code: Select all

ALTER TABLE "Table1" ADD COLUMN "Total" INTEGER
does work.
Last edited by peterwt on Thu Oct 22, 2015 12:34 pm, edited 1 time in total.
Peter
LibreOffice 4.4.1.2 on Windows 8
F3K Total
Volunteer
Posts: 1039
Joined: Fri Dec 16, 2011 8:20 pm

Re: Put Formula in Column - Calculated Column

Post by F3K Total »

Hello,
it's not possible with the shipped embedded database HSQLDB 1.8.10. If you split your DB (see Base Tutorials) you can e.g. use HSQL 2.3.3 currently, which can generate calculated columns as well as triggers.

R
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
peterwt
Posts: 35
Joined: Mon Apr 19, 2010 4:04 pm
Location: South Wales

Re: Put Formula in Column - Calculated Column

Post by peterwt »

Thanks F3K Total
Peter
LibreOffice 4.4.1.2 on Windows 8
Post Reply