Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

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.
0
idevil
Asked:
idevil
1 Solution
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now