SQL Funtions and triggers

Posted on 2006-03-21
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.
Question by:idevil
    1 Comment
    LVL 3

    Accepted Solution

    CREATE OR REPLACE FUNCTION get_project_cost (
      p_proj_title  VARCHAR2)
      RETURN number

    cost NUMBER;

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


        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!

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
    Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now