vipin p
vipin p

Reputation: 111

looping and inserting values into a table in mysql

Hi I have two arrays as input. I want to insert into a table using loop. This is what I have tried.

simple_loop:LOOP

SET i = i + 1;
     simples_loop:LOOP
     SET j = j + 1;
     INSERT INTO ROLE_PRIVILEGE_BRIDGE (ROLE_ID,PRIVILEGE_ID,VALUE)
        VALUES(V_ROLE_FK,p_privilege_fk(i),p_values(j));
     END LOOP simples_loop;
END LOOP simple_loop;

This is just the portion of the procedure I have written. When executed the query an error showed up saying that ".p_privilege_fk() function does not exist.". Can anyone please help.

Upvotes: 0

Views: 107

Answers (1)

Sam
Sam

Reputation: 2761

Try something like this:

INSERT INTO ROLE_PRIVILEGE_BRIDGE (ROLE_ID,PRIVILEGE_ID,VALUE) 
    (SELECT V_ROLE_FK, p_privilege_fk, p_privilege_fk FROM firstTable) 

Upvotes: 3

Related Questions