Marcelo-
Eric's suggestion is valid, but you can use a stored procedure if you like. Sometimes it's appropriate. To do so, the database with the stored procedure must be the current one. You can do this with
SET DATABASE TO MyDBC
>I´m having problems with a function that resides in stored procedures section.