insert values in postgres

1
0
-1

Hi.
I'm trying to insert values into a table in postgreSQL, I need to save the values of the variables that the user enters into the application.
I test with static values in this case the test is correct but when I put the variables the script does not work.
The script is the following:

`import groovy.sql.Sql;

import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;

long idDoc;
idDoc = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, "alfrescoAtCliJeAgPo").getId();
Document doc=apiAccessor.getProcessAPI().getDocument(idDoc);
DocumentValue docValue=new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName());
int redAux=1, departamentoAux;
if(red.equalsIgnoreCase("Sector Rurral")){
redAux = 2;
}

switch(departamento){
case "Red-1":
departamentoAux=1;
break;
case "Red-2":
departamentoAux=2;
break;
case "Red-3":
departamentoAux=3;
break;
case "Red-4":
departamentoAux=4;
break;
case "Red-5":
departamentoAux=5;
break;
case "Red-6":
departamentoAux=6;
break;
case "Red-7":
departamentoAux=7;
break;
case "Red-8":
departamentoAux=8;
break;
case "Red-9":
departamentoAux=9;
break;
default:
departamentoAux = 1;
break;
}
byte[] aux = docValue.getContent();
double ordenAuxi = double.parseDouble(orden);

Sql sql = BonitaSql.newInstance("jdbc:postgresql://localhost:5432/repracionesepemapar","postgres","bpm",new org.postgresql.Driver());
sql.execute("INSERT INTO atencioncliente( id_red, id_deparatamento, orden, cuenta, nombrecliente, telefonocliente, sectorcliente, fechainicio, tiporeparacion, archivoadjunto ,tipoimportancia)"+
"VALUES('"+ redAux +"', '"+ departamentoAux +"','"+ ordenAuxi +"','"+ cuenta +"','"+ nombreCliente +"','"+ telefonoCliente +"','"+ sectorcliente +"','"+ (fechaInicioProceso.toString()) +"','"+ tipoReparacion +"','"+ aux +"','"+ tipoimportancia +"')");
sql.close();`

Thanks.

Comments

Submitted by romualdo.s.rs on Tue, 01/31/2017 - 17:48

I know it does not answer your question, but how did you save the information to try to save in the database afterwards? And another thing, can you display the bank information in UI Designer?

Submitted by Sean McP on Wed, 02/01/2017 - 06:41

What do the logs say?

Submitted by romualdo.s.rs on Wed, 02/01/2017 - 12:10

As well? The information I select from the bank in the case?

No answers yet.
Notifications