SQL Funtions and triggers

Here we go,
 
I have a write a stored function called get_project_cost. This function takes as input a project title and returns teh cost to date for that project. NOte that the type for cost is 'number'.Call the function from within an SQL statement to give the project title,customer name and cost to date for project.

I am struck.

Moreover, I have to write a trigger as well.
LVL 1
idevilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jazzylineCommented:
CREATE OR REPLACE FUNCTION get_project_cost (
  p_proj_title  VARCHAR2)
  RETURN number
IS

cost NUMBER;

BEGIN
  cost := (SELECT field_name FROM table_name t WHERE t.project_title = p_proj_title);

  RETURN(cost);

EXCEPTION
  WHEN OTHERS THEN
    RETURN 0;

END get_project_cost;

-> Substitute your query inside the function.
-> Compile the program.
-> Excute your query like.. SELECT project title,cust_name,cost(get_project_cost) FROM your_table

Good Luck!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.