my problem is as follows: i have a database, each row represents a delivery that my agent has to make. The first column contains the specific name of the delivery, the others the names of the nodes to be reached ('pad_1','pad_2,'pad_3'.......).
In the main I have a string vector that contains the name of all the columns in the database.
I also have an event that at the specific delivery time calls a function with which I would like to scroll through the columns of the database of the row related to the delivery, so as to fill a vector of nodes with the contents of columns other than 0.
The query to the database, I wanted to automate it by scrolling the vector of strings with this code: ''' int [] Pad = new int[n_pc]; for (int i=0;i< n_pc;i++){ Pad[i]=selectFrom(farmacia_clinica).where(farmacia_clinica.fascia.eq(FASCIA_A).uniqueResult(farmacia_clinica.PAD_FarmaciaClinica[i]));}
the error is in the last command "uniqueResult(farmacia_clinica.PAD_FarmaciaClinica[i])"
How can I resolve this?
Thank u.
This doesn't work for QueryDSL as you need to have a StringPath and not String type as arguments for referencing the DB column. Instead, you can build an SQL query using your String array for your code.
The code will then be:
int [] Pad = new int[n_pc];
for (int i=0; i< n_pc; i++) {
Pad[i] = selectUniqueValue(int.class,
"SELECT " + PAD_FarmaciaClinica[i] +
" FROM farmacia_clinica WHERE fascia = ?;",
"FASCIA_A");
}