question

Paúl Alejandro R avatar image
0 Likes"
Paúl Alejandro R asked Jacob Gillespie edited

How to register my product label into a database in phpmyAdmin ?

I am using the new features of database connection with SQL in Flexsim. I did the tutorial related to it, in which they use phpmyAdmin as an example (https://answers.flexsim.com/articles/19407/sql-tutorial-step-by-step-model-construction-29.html). I made some changes, as in my model I would want to register the time in which my products reach the sink and their label as well. I managed to register their time, however when I try to do the same for the labels, my table only gets filled up with nulls. I don´t know why, as the logic seems right, I´m using this line code: string Etiqueta = getlabel(item,"WIP");

I´m not using a primary key because I need my table to act as a view entries list, so the NULL should all be: 40405. In the future I´m hoping to be able to extend my number of labels, so it´s important for me to solve this.

FlexSim 18.1.2
sqlcustom codescriptdatabasedatabase connector
php.png (51.4 KiB)
php2.png (23.0 KiB)
php3.png (85.0 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jacob Gillespie avatar image
1 Like"
Jacob Gillespie answered Jacob Gillespie edited

Your altquery which is updating the time looks fine. The query inserting into the table doesn't have Etiqueta in it.

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Paúl Alejandro R avatar image Paúl Alejandro R commented ·

@Jacob Gillespie I´m new to this, so how should I correct this to keep it simple? Also, I would like my altquery to delete all the data everytime the model resets. How could I do this?

Thanks in advance!

0 Likes 0 ·
Jacob Gillespie avatar image Jacob Gillespie ♦ Paúl Alejandro R commented ·

I think line 8 should be something like this:

string query = concat("insert into  `flexsimdata`.`outtimes2` (`Etiqueta`,`Tiempo`)values ('", Etiqueta, "','", Tiempo, "');");

To delete all rows from a table you would execute a query like this:

"delete from `flexsimdata`.`outtimes2`;"
0 Likes 0 ·