Procedures Mysql

Asked

Viewed 39 times

-1

Hi, I’m new to procedures and I have a question I couldn’t find on the internet.

I need to create a procedure to include 2 tables: "User", "Supplier".

The provider has a user FK, that is, in this process, I need to insert a user, get the id of that user and insert a provider with the user Fk that was created.

How can I do that?

Thank you in advance...

  • Do you already know how to declare a trial? If so, it would be interesting to post what you have already done.

1 answer

0


After entering the user, use SELECT LAST_INSERT_ID(); to obtain the id user created, store the id into a variable and then enter the provider.

  • Ooh cool! This way should work yes! But then I came up with another question! This is the right way to do?

  • Whenever a user is registered, is it necessary that a related supplier is also registered? If so, maybe the best option is a Rigger on AFTER INSERT.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.