Right now, I have this table:
id|name|status (varchar)|fk_id_test (int)
-----------------------------------------
1 |ABC | X |
2 | DX | Y |
3 | ZZ | X |
4 | TU | Y |
5 | EE | Z |
I have to insert in fk_id_test values coming from status column.
The algorithm would be something like:
switch(status)
case 'X': `fk_ik_test` = 1
case 'Y': `fk_ik_test` = 2
case 'Z': `fk_ik_test` = 3
etc.
The result should be this:
Right now, I have this table:
id|name|status (varchar)|fk_id_test (int)
-----------------------------------------
1 |ABC | X |1
2 | DX | Y |2
3 | ZZ | X |1
4 | TU | Y |2
5 | EE | Z |3
I have 5 status. This is because I will use another table (test) with the names of those status (varchar).
It's possible to do this in postgresql?