We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

SQL Funtions and triggers

idevil
idevil asked
on
Medium Priority
473 Views
Last Modified: 2013-12-01
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.
Comment
Watch Question

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!

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.