Multiples statement sql

Hi!
Is it possible to send more than one sql statement by the web component to mysql?

I ask this because I created 3 web components to send three sql statements, however, it only goes one at a time, that is, to send I must click the SEND button three times.
How can I do this so that the 3 web components are called in the same button click?

Sql statement web1:
INSERT INTO tb_cadastro(idtb_cadastro, apelido, email) VALUES (NULL, ‘John’, ‘[email protected]’)

Sql statement web2:
SELECT idtb_cadastro FROM tb_cadastro WHERE email=‘[email protected]

Sql statement web3:
INSERT INTO tb_login(idtb_login, senha, fk_id_usuario) VALUES (NULL, 1234, >>>FK FROM SELECT ABOVE <<<<)

I am recording the Fk of the tb_login table after recording the PK of the tb_cadastro table.

yes possbile just use index method

How can use it, please? Give me example, thanks.

just sample, pls test it

the above method is used for posting continuously… In every query you are looking for different approach, then you must use different approach

1 Like

Thank you very much!

1 Like

Did you test it ? Worked?..

Hi, unfortunately, doesnt worked. But, I think that yours example can be adjust for me… I will try.

See, i am using the same code for adding values from app to gsheet (upon certain condition)… But see your logic, your first query seems to be insert, (certainly this will work) but second query you are trying to select something it seems… and again in third query you are trying to insert …

so better you can use clock component for waiting couple of seconds… so it may work feasibly

Already i saidm the above code is to run altogather…

Are you looking to do different functions with same buttons click?

I understand. I will add clock, should be the time to record data. I will return the post.

if so try like this

i hope in second query only you need some time interval…

add your desired time interval at here, may be 2000/3000

image

Yes, I am.

What’s the purpose: I have two tables: the tb_cadastro table records the user’s information minus their access password in the app. The access password in the app I record in the tb_login table where I have a foreign key pointing to the PK of the registration table. So when a new user creates his login, the app records his password in tb_login and the other data in the tb_cadastro table.

1 Like

ok, make sure every query returns response code as 200 upon every attempts else app will not proceed furthere…

1 Like

Insert your web.POST 2 Inside the web.got1 … And web.post3…
It’s asynchronous…

1 Like

Yes!! Worked! it!
Perfect!
I was already disheartened by this! I thank everyone.

1 Like

to use a clock in this example is not the best advice…
let me suggest you to follow @Rogerio_Rios suggestion…

Taifun

1 Like

I hope the same thing only was suggested using single web block in earlier post but 2nd query was not returned the expected val it seems and his platform expected to be few sec interval so advised him to test with clock and it was worked…

User wants to execute it continuously it seems so…

the correct way is to do it aynnchronously…
i.e. send web request, response comes back in Web.GotText event, then send next request etc.
see also this completely different example how to do something asynchronously App Inventor Tutorials and Examples: Webprefetch File by File | Pura Vida Apps

Taifun

1 Like

Doesn’t??? Am i missed the asynchronous?

sorry, I just checked your screenshot more in detail… you are doing it almost correctly…
but a clock not really is necessary…

for more that 3 sql statements you might want to put the sql statements into a list and read them from there to avoid long if then elseif constructs…

Taifun

2 Likes

Yes i agree, but see to this suggestion Multiples statement sql - #4 by Still-learning also