---
title: "Calculation works while testing, but result cannot be written to database"
url: "https://openforis.support/questions/615/calculation-works-while-testing-but-result-cannot-be-written-to-database"
tags: ["calc"]
status: "closed"
score: 0
answer_count: 3
asked: "2016-07-28T11:12:45"
last_activity: "2016-08-02T12:19:32"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# Calculation works while testing, but result cannot be written to database

Asked by Fehrmann on 2016-07-28

Hi,
I have a general problem with calculations in Calc: Even if the calculation runs smoothly when I test it, I get an error in step 3 when running the calculation chain. Obviously the results are not written to the database. I also see that the plot area is not written to the tree view (even if correct).

My simple example calculation is:
tree$tree_basalarea <- pi/4*(tree$tree_dbh/100)^2
I am using a test case with only some trees.

The error I get is:

Error in 'tree basal area' 
 org.openforis.calc.r.RException: R error while evaluating tree basal area
	at org.openforis.calc.engine.CalcRTask.execute(CalcRTask.java:58)
	at org.openforis.calc.engine.Worker.run(Worker.java:75)
	at org.openforis.calc.engine.Job.execute(Job.java:103)
	at org.openforis.calc.engine.Worker.run(Worker.java:75)
	at org.openforis.calc.engine.Job.run(Job.java:89)
	at org.openforis.calc.engine.TaskManager$1.run(TaskManager.java:232)
	at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:230)
	at java.lang.Thread.run(Thread.java:745)
Error in `$<-.data.frame`(`*tmp*`, "tree_basalarea_per_ha", value = numeric(0)) : 
  Ersetzung hat 0 Zeilen, Daten haben 3
Error in checkError(result, connection) : 
  Error in `$<-.data.frame`(`*tmp*`, "tree_basalarea_per_ha", value = numeric(0)) : 
  Ersetzung hat 0 Zeilen, Daten haben 3


## Answer (score 0, by Fehrmann on 2016-07-28)

Link: https://openforis.support/questions/615/calculation-works-while-testing-but-result-cannot-be-written-to-database/616

Add on: In an older survey (where calculation works) the calculated fields in the database are "double precision", while with Calc 2.0 I have the problem that they are "numeric". Maybe the problem is somewhere here...


## Answer (score 0, by Fehrmann on 2016-07-28)

Link: https://openforis.support/questions/615/calculation-works-while-testing-but-result-cannot-be-written-to-database/617

While searching for the problem I found that my Calc installation was not correct. I installed Calc 2 without completely removing Calc 1 before. Therefore the question above is obsolete.

Thank you and sorry!


## Answer (score 0, by Mino Togna on 2016-08-02)

Link: https://openforis.support/questions/615/calculation-works-while-testing-but-result-cannot-be-written-to-database/621

Hi Fehrmann,

Thank you. please let us know if you face additional problems.

Mino
