That error suggests that the user who owns the serviceinvoice
procedure either doesn't have any privileges to the s8.servwork
table, or it only has privileges granted by a role.
If you have a definers right program (which is the default), the program's owner needs to have specific privileges on tables, etc that it needs to use.
So, you need to run something like the following as the S8
user for your procedure to work:
grant select on servwork to <owner of your serviceinvoice procedure>;
If your procedure(s) will also be inserting, updating, etc on that table, you will need to grant those privileges too. (e.g. grant insert, select, ... to ...;
)
Secondly, your select needs to return values into a variable, which it does not currently do. Depending on whether you're expecting at most 1 row or multiple rows affects the kind of variable you need to return into. E.g. if you're getting multiple rows back, you need to bulk collect into an array of the necessary rowtype, or maybe it's a record, or individual variables.
Finally, it's bad practice to use select * ...
inside code - you should explicitly specify the columns you want to use. This avoids errors with your code if someone adds a column to the table.
SET Role none
– Hasan Patel