Tco 2 and 5 what is the difference between a stored

Info icon This preview shows pages 2–4. Sign up to view the full content.

View Full Document Right Arrow Icon
(TCO 2 and 5) What is the difference between a stored procedure and a stored function? Where are they located? How can they be used? Explain. A stored procedure is invoked using a CALL statement and can only pass back values using output variables, such as performing an operation like modifying a table. For example, I wrote this for one of the labs: BEGIN UPDATE baseball.season SET HomeTeamScore = iHomeScore,
Image of page 2

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
AwayTeamScore = iAwayScore WHERE HomeTeam = vHomeTeam AND AwayTeam = vAwayTeam; END In my C# code I can call this stored procedure each time I want to update the "season" table, this saves time when writing the code because you can call the stored procedure and not have to write an update statement each time it's needed. A stored function will actually return a value, unlike a stored procedure that just performs an operation. You need to have a "return" clause in your statement, such as: CREATE FUNCTION example_function ([parameters]) RETURNS datatype Then you can write something like an IF/THEN statement to set your values You can use this stored function in your code by calling the function name (example_function). 6) What is an event? How do you use an event? Give an example. An event can be used in numerous ways to perform scheduled tasks to run on your database. A few examples are scheduling an event to create a backup, or even delete specified records in your database. I created this backup using an event: CREATE EVENT IF NOT EXISTS WeeklyBackup ON SCHEDULE EVERY 1 Week STARTS '2017-10-08 23:59:59.999999' -- Backs up database every Friday night DO SELECT * INTO OUTFILE 'C:\Devry\DBM405A\pastseasons.txt' FROM baseball.pastseasons;
Image of page 3
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern