I have a matrix in excel where in the first column I have user names and in the second and subsequent columns I have role names and a 'Y' if a user is a member of the role:
User Role1 Role2 Role3
Jon Y Y
Mary Y Y
I need to load this into an Oracle database. In the database I already have a table for users:
UserId Username
1 Jon
2 Mary
I need to take the roles i.e. Role1, Role2, Role3 and load it into a roles table:
roleId role
1 Role1
2 Role2
3 Role3
And then I need to load the role memberships into a role mapping table:
UserId RoleId
1 1
1 2
2 2
2 3
So far I created a table with Column1,Column2,Column3 attributes and loaded the Excel sheet in there with SQL developer without using the HEADER!
Column1 Column2 Column3 Column4
User Role1 Role2 Role3
Jon Y Y
Mary Y Y
From here I'm trying to use a stored procedure to loop through the table with a cursor and where I find the value 'User' in Column1, loop through the attributes in that row and add those to the roles table, etc.
However I'm having trouble looping through the attributes within the CURSOR in each %ROWTYPE.
Is this a good approach? How can I loop through each attribute in a %ROWTYPE?