How can I assign a "select [value] from [db_table]" value to a single variable?

1
0
-1

I'm trying the new database connector, and I'm using an Oracle DataBase, and I want to assign a single value into a Bonita's defined value (int, bool) and when I do it, the process stops to work. When I retrieve a list of values and I assign it to an Array List, I don't have any problem, but when I want to work with single values, I can't do that, please help me.

PD: Sorry for my English

Comments

Submitted by rafael.vianna on Thu, 01/02/2014 - 16:52

Hi dpperalta,

So you want to retrieve a single value from your table into a Bonita's variable? Not sure if this is what you wanna do. If it is what you are intending to do and you're not getting that, can you paste your engine log? Someone can help you better if we see the error that's happening.

5 answers

1
0
-1

Hello again rafale.vianna

Of course, it's easier, sometimes we are searching for hard answers when there is a better way to do it, Thank you for your time, I'll try to do my query with your groovy code, and I'm sure that it will work, once again thank you very much for your help.

1
0
-1

Hey, it worked, nice. =)

About your question I never tried to get it that way, I prefer to use the groovy itself like this:

def retorno = ""

if (MyResultVariableFromOracle == 1)

retorno = "Some stuff like: "+ BonitaVariable1 + " " + BonitaVariable2 + " " + BonitaVariable3

else

retorno = "Someotherstuff"

retorno

Also you can set a verification if it returns true, null, blank... I believe it's easier than try to convert everything that comes from the DB. But it's just my opinion. ;)

Best regards.

1
0
-1

Thank You very much rafael.vianna

The goovy code works perfectly in the Oracle Connector, and consecuently my process work again, Thank you for your answer, and I have another question, I guess that I can use this (or some similar) code to "extract" values in Boolean Mode (from Oracle DB) to a Bonita Boolean values, I question it, because Oracle stores its boolean values like a kind of number (please correct me if I'm wrong).

1
0
-1

This is your problem: java.math.BigDecimal cannot be cast to java.lang.Integer

Your Oracle DB is sending you a BigDecimal and you are trying to simple put it to an integer variable.

I guess you'll need some groovy to solve that. Like this, for instance:

import groovy.sql.Sql

def result = 0

Sql sql = BonitaSql.newInstance("jdbc:oracle:thin:@IP:PORT:INSTANCE", "OWNER", "PASSWORD",new oracle.jdbc.OracleDriver())

sql.eachRow "SELECT MAX(ID_HIS) AS CODIGO FROM HISTORIA", {result += it.CODIGO.intValueExact() }

sql.close()

return result

With groovy stuff I can get my value from the DB and extract the intValueExact() (which returns an INTEGER value).

I know that work with groovy is a pain sometimes but it might be useful this time for you.

Hope it helps.

1
0
-1

Yes, I want to retrieve a single value from my table (I'm using: Select max(id_his) from historia) and I have tested this query and I retrieve a single Integer value (for example: 1, 5, 30, etc), I will attach the engine log, Thank You for your help.

Error Log:

ene 02, 2014 11:04:29 AM org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log WARNING: A work failed, The failure will be handled, work is: ExecuteConnectorOfActivity: flowNodeInstanceId = 29, connectorDefinitionName = seleccionarHistoria ene 02, 2014 11:04:29 AM org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log WARNING: Exception was:org.bonitasoft.engine.data.instance.exception.SUpdateDataInstanceException: Impossible to update data instance 'num_id_historia': org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.data.instance.exception.SUpdateDataInstanceException: Impossible to update data instance 'num_id_historia': org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.updateDataInstance(UpdateOperationExecutorStrategy.java:74) at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.update(UpdateOperationExecutorStrategy.java:57) at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.execute(OperationServiceImpl.java:141) at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeOutputOperation(ConnectorServiceImpl.java:206) at org.bonitasoft.engine.connector.ConnectorServiceDecorator.executeOutputOperation(ConnectorServiceDecorator.java:115) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.evaluateOutput(ExecuteConnectorWork.java:103) at org.bonitasoft.engine.execution.work.ExecuteConnectorOfActivity.evaluateOutput(ExecuteConnectorOfActivity.java:77) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork$EvaluateConnectorOutputsTxContent.call(ExecuteConnectorWork.java:273) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork$EvaluateConnectorOutputsTxContent.call(ExecuteConnectorWork.java:256) at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:223) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.work(ExecuteConnectorWork.java:127) at org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork.work(FailureHandlingBonitaWork.java:72) at org.bonitasoft.engine.work.BonitaWork.run(BonitaWork.java:56) at org.bonitasoft.engine.work.SequenceRunnableExecutor.innerRun(SequenceRunnableExecutor.java:45) at org.bonitasoft.engine.work.BonitaRunnable.run(BonitaRunnable.java:35) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Caused by: org.bonitasoft.engine.data.instance.exception.SUpdateDataInstanceException: Impossible to update data instance 'num_id_historia': org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.data.instance.DataInstanceDataSourceImpl.updateDataInstance(DataInstanceDataSourceImpl.java:99) at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bonitasoft.engine.data.DataSourceImplementationProxy.invoke(DataSourceImplementationProxy.java:39) at com.sun.proxy.$Proxy18.updateDataInstance(Unknown Source) at org.bonitasoft.engine.data.instance.api.impl.DataInstanceServiceImpl.updateDataInstance(DataInstanceServiceImpl.java:147) at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.update(UpdateOperationExecutorStrategy.java:45) at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.updateDataInstance(UpdateOperationExecutorStrategy.java:72) ... 20 more Caused by: org.bonitasoft.engine.recorder.SRecorderException: org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.recorder.impl.RecorderImpl.recordUpdate(RecorderImpl.java:136) at org.bonitasoft.engine.data.instance.DataInstanceDataSourceImpl.updateDataInstance(DataInstanceDataSourceImpl.java:97) ... 28 more Caused by: org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.persistence.AbstractHibernatePersistenceService.setField(AbstractHibernatePersistenceService.java:300) at org.bonitasoft.engine.persistence.AbstractHibernatePersistenceService.update(AbstractHibernatePersistenceService.java:289) at org.bonitasoft.engine.recorder.impl.RecorderImpl.recordUpdate(RecorderImpl.java:128) ... 29 more Caused by: org.bonitasoft.engine.commons.ReflectException: java.lang.reflect.InvocationTargetException at org.bonitasoft.engine.commons.ClassReflector.invokeMethodByName(ClassReflector.java:157) at org.bonitasoft.engine.persistence.AbstractHibernatePersistenceService.setField(AbstractHibernatePersistenceService.java:298) ... 31 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bonitasoft.engine.commons.ClassReflector.invokeMethodByName(ClassReflector.java:155) ... 32 more Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Integer at org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl.setValue(SIntegerDataInstanceImpl.java:45) ... 37 more ene 02, 2014 11:04:29 AM org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log WARNING: Error while executing connector with id 57 org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.data.instance.exception.SUpdateDataInstanceException: Impossible to update data instance 'num_id_historia': org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.updateDataInstance(UpdateOperationExecutorStrategy.java:74) at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.update(UpdateOperationExecutorStrategy.java:57) at org.bonitasoft.engine.core.operation.impl.OperationServiceImpl.execute(OperationServiceImpl.java:141) at org.bonitasoft.engine.core.connector.impl.ConnectorServiceImpl.executeOutputOperation(ConnectorServiceImpl.java:206) at org.bonitasoft.engine.connector.ConnectorServiceDecorator.executeOutputOperation(ConnectorServiceDecorator.java:115) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.evaluateOutput(ExecuteConnectorWork.java:103) at org.bonitasoft.engine.execution.work.ExecuteConnectorOfActivity.evaluateOutput(ExecuteConnectorOfActivity.java:77) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork$EvaluateConnectorOutputsTxContent.call(ExecuteConnectorWork.java:273) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork$EvaluateConnectorOutputsTxContent.call(ExecuteConnectorWork.java:256) at org.bonitasoft.engine.transaction.JTATransactionServiceImpl.executeInTransaction(JTATransactionServiceImpl.java:223) at org.bonitasoft.engine.execution.work.ExecuteConnectorWork.work(ExecuteConnectorWork.java:127) at org.bonitasoft.engine.execution.work.FailureHandlingBonitaWork.work(FailureHandlingBonitaWork.java:72) at org.bonitasoft.engine.work.BonitaWork.run(BonitaWork.java:56) at org.bonitasoft.engine.work.SequenceRunnableExecutor.innerRun(SequenceRunnableExecutor.java:45) at org.bonitasoft.engine.work.BonitaRunnable.run(BonitaRunnable.java:35) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) Caused by: org.bonitasoft.engine.data.instance.exception.SUpdateDataInstanceException: Impossible to update data instance 'num_id_historia': org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.data.instance.DataInstanceDataSourceImpl.updateDataInstance(DataInstanceDataSourceImpl.java:99) at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bonitasoft.engine.data.DataSourceImplementationProxy.invoke(DataSourceImplementationProxy.java:39) at com.sun.proxy.$Proxy18.updateDataInstance(Unknown Source) at org.bonitasoft.engine.data.instance.api.impl.DataInstanceServiceImpl.updateDataInstance(DataInstanceServiceImpl.java:147) at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.update(UpdateOperationExecutorStrategy.java:45) at org.bonitasoft.engine.core.operation.impl.UpdateOperationExecutorStrategy.updateDataInstance(UpdateOperationExecutorStrategy.java:72) ... 20 more Caused by: org.bonitasoft.engine.recorder.SRecorderException: org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.recorder.impl.RecorderImpl.recordUpdate(RecorderImpl.java:136) at org.bonitasoft.engine.data.instance.DataInstanceDataSourceImpl.updateDataInstance(DataInstanceDataSourceImpl.java:97) ... 28 more Caused by: org.bonitasoft.engine.services.SPersistenceException: Problem while updating entity: org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl@adf5ac50 with id: 6544 at org.bonitasoft.engine.persistence.AbstractHibernatePersistenceService.setField(AbstractHibernatePersistenceService.java:300) at org.bonitasoft.engine.persistence.AbstractHibernatePersistenceService.update(AbstractHibernatePersistenceService.java:289) at org.bonitasoft.engine.recorder.impl.RecorderImpl.recordUpdate(RecorderImpl.java:128) ... 29 more Caused by: org.bonitasoft.engine.commons.ReflectException: java.lang.reflect.InvocationTargetException at org.bonitasoft.engine.commons.ClassReflector.invokeMethodByName(ClassReflector.java:157) at org.bonitasoft.engine.persistence.AbstractHibernatePersistenceService.setField(AbstractHibernatePersistenceService.java:298) ... 31 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.bonitasoft.engine.commons.ClassReflector.invokeMethodByName(ClassReflector.java:155) ... 32 more Caused by: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Integer at org.bonitasoft.engine.data.instance.model.impl.SIntegerDataInstanceImpl.setValue(SIntegerDataInstanceImpl.java:45) ... 37 more

Comments

Submitted by s.e. on Sun, 01/19/2014 - 00:18

Hey,

I have the same problem with the SugarCRM-Connector:

Warnung: A work failed, The failure will be handled, work is: ExecuteConnectorOfActivity: flowNodeInstanceId = 20037, connectorDefinitionName = SugarCRM-1Object
Jan 19, 2014 12:14:36 AM org.bonitasoft.engine.log.technical.TechnicalLoggerSLF4JImpl log
Warnung: Exception was:org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: No value found for mandatory expression 'jsonObject' of type Input Expression
org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: No value found for mandatory expression 'jsonObject' of type Input Expression

Any help?

Thanks!
Sebastian

Notifications