1
I have a table of Chamados
. I have to add a whole column that will be called sequencia
and will be used to search in the order the user wants.
Just to illustrate: the call will have some arrows, when you click on the arrow pointing upwards, this call will increase the number of the column sequencia
, and alter all other records so that that call gets above what was above. Same thing if you click the down arrow, changing its order, remembering that the sequence column cannot have repeated numbers.
Can anyone help? I am developing in JAVA
and MySQL
.
EDIT:
Based on the comments, I decided to do so:
UPDATE chamado SET sequencia = sequencia + 1 WHERE cod = 1
UPDATE chamado SET sequencia = sequencia - 1 WHERE cod = 2
Thus it increases the value of the sequence where the user clicked, in case the code 1, and decreases the value of the above code so that the code 1 has a value more auto than the code 2, to do the opposite:
UPDATE chamado SET sequencia = sequencia - 1 WHERE cod = 1
UPDATE chamado SET sequencia = sequencia + 1 WHERE cod = 2
There’s nothing ready, or it’s homework?
– Gustavo Cinque
I have everything ready, asked to add this functionality in the Software, and I’m hitting myself how can I do it.
– AronKS
@Aronks your question is quite broad. I understood what has to be done, but exactly, what is your difficulty, or the problem?
– Erico Souza
Specify better, preferably what you have already tried. Asking for a 'zero' solution does not demonstrate any effort on your part to solve the problem..
– Franchesco
@Aron, you’re using some framework?
– Gustavo Cinque
I thought to take the record, and increment + 1 in it, and a FOR in the other records, to increment the top, and decrease the bottom, but our database is not very fast (it’s external), there would be an easier way to solve?
– AronKS
@Gustavocinque No, only using Netbeans.
– AronKS
Aron, I don’t have much experience in
swing
, but the idea would be, every time a record was qualified with "+1", the table would reload, and in the functions that model the table, there would be a separation by the fieldvoto
(for example). I also don’t know if it’s the best idea...Chamado
implemented? If so, it would just create a new field within it.– Gustavo Cinque
Sorry, I had understood "create another table" instead of "column" up there. I advise using the framework
Hibernate
to be able to map the models more calmly, and without burning the head withSQLs
, but I believe the project is already too advanced to do this.– Gustavo Cinque
[note to editor] @Earendul, check the guide How we should format questions and answers?, especially the part about the use of
\
``.– brasofilo
Aronks, click [Edit] and update the question, check [Ask] for more details. Like this: 1) Negative votes can be reversed. 2) You will receive answers instead of comments asking for clarification.
– brasofilo
This question seems to be out of context because it’s about a specific problem that won’t help anyone else. Moreover the question is very broad and has the answer in the question itself.
– Jorge B.