0
I have a database in Mysql with Stock, Sales and Ite_sales tables.
When making a sale record information in the Sales and Ite_sales tables, but I want to get information from the Stock table and register in Ite_venda.
Follows the structure of the bank:
Tabela Produto
CODPRODUTO int(11)
CODGRUPO int(11)
CODSUBGRUPO int(11)
CODTRIBUTACAO int(11)
COD_BARPRODUTO varchar(30)
CODFORNECEDOR int(11)
NOMPRODUTO varchar(80)
NOM_IDEPRODUTO varchar(80)
Tabela Ite_Venda
CODBALCAO_ITEVENDA int(10) unsigned
CODBALCAO_VENDA int(11)
CODPRODUTO int(11)
CODBAR_PRODUTO varchar(30)
NOMPRODUTO varchar(80)
QTDPRODUTO decimal(10,4)
VAL_TOTBALCAO_ITEVENDA decimal(10,4)
VAL_ITEBALCAO_ITEVENDA decimal(10,4)
VAL_ACRBALCAO_ITEVENDA decimal(10,4)
VAL_DESBALCAO_ITEVENDA decimal(10,4)
I need to create a Trigger that when recording in the Ite_venda table I can take the COD_BARPRODUTO field in the Product table and insert in the Ite_venda table in the CODBAR_PRODUTO field.
What you have tried so far and what problems you have encountered?
– Caffé
@Caffé I haven’t tried another alternative yet, I’m thinking of doing this way because I deal in the bank instead of dealing in the system and I don’t care a little to do everything, and with this function I can do other functions using the same process.
– DevAgil
when writing to the Ite_venda table you still don’t have COD_BARPRODUTO ? if you have then do not need to Trigger but improve your Internet, in case right now you do not have the COD_BARPRODUTO tell me how you will get it in the Product table if you do not know what the code is!
– SneepS NinjA
@Maisonsakamoto I did it through my system medium and not through the database.
– DevAgil
@Claytonquintiliano if made by means of system, then is known the COD_BARPRODUTO? then passes it on the Insert, does not need to Trigger
– SneepS NinjA
That’s what I did, I wasn’t bringing in the bank research but I changed the schedule and built in this field too.
– DevAgil