A Guide to SQL
A Guide to SQL
9th Edition
ISBN: 9781111527273
Author: Philip J. Pratt
Publisher: Course Technology Ptr
Expert Solution & Answer
Book Icon
Chapter 8, Problem 6CAT

Explanation of Solution

a.

Deleting query in the table “GUIDE”:

Public Function GuideDelete(I_GUIDE_NUM)

    Dim strSQL As String

    strSQL = "DELETE FROM GUIDE WHERE GUIDE_NUM = '"

    strSQL = strSQL & I_GUIDE_NUM

    strSQL = strSQL & "'"

    DoCmd.RunSQL strSQL

 End Function

 Explanation:

  • Create a function named as “GuideDelete” and pass an argument “I_GUIDE_NUM”.
  • Set the “strSQL” string variable to “DELETE FROM GUIDE WHERE GUIDE_NUM = '” and makes everything necessary in the command up to and including the single quotation mark preceding the order number.
  • The next command will concatenated previous value with the value in “I_GUIDE_NUM”.
  • The final command is used to set “strSQL” to the output of the value already created, concatenated with a single quotation mark...

Explanation of Solution

b.

Updating query:

Public Function GuideUpdate(I_GUIDE_NUM, I_LAST_NAME)

    Dim strSQL As String

    strSQL = "UPDATE GUIDE SET LAST_NAME = '"

    strSQL = strSQL + I_LAST_NAME

    strSQL = strSQL + "' WHERE GUIDE_NUM = '"

    strSQL = strSQL & I_GUIDE_NUM

    strSQL = strSQL & "'"

    DoCmd.RunSQL strSQL

End Function

 Explanation:

  • Create a function named as “GuideUpdate” and pass the arguments “I_GUIDE_NUM” and “I_ LAST_NAME”.
  • Set the “strSQL” string variable to “UPDATE GUIDE SET LAST_NAME = '” and makes everything necessary in the command up to and including the single quotation mark preceding the order number.
  • Here, the user pass two arguments, so there are two portions of the construction of the SQL command that involve variables...

Explanation of Solution

c.

Retrieving the list in the table “RESERVATION”:

Public Function FindReservations(I_CUSTOMER_NUM)

    Dim rs As New ADODB.Recordset

    Dim cnn As ADODB.Connection

    Dim strSQL As String

    Set cnn = CurrentProject.Connection

    strSQL = "SELECT RESERVATION_ID, TRIP_ID, NUM_PERSONS, TRIP_PRICE FROM RESERVATION WHERE CUSTOMER_NUM = '"

    strSQL = strSQL & I_CUSTOMER_NUM

    strSQL = strSQL & "'"

    rs.Open strSQL, cnn, adOpenStatic, , adCmdText

    Do Until rs.EOF

        Debug.Print (rs!RESERVATION_ID)

        Debug.Print (rs!TRIP_ID)

        Debug.Print (rs!NUM_PERSONS)

        Debug.Print (rs!TRIP_PRICE)

        rs.MoveNext

    Loop

End Function

 Explanation:

  • Create a function named as “Find_Reservations” and pass an argument “I_CUSTOMER_NUM”.
  • The “rs” and “cnn” is used to processing the “Recordset” and “ADODB.Connection”.
  • Set the “strSQL” string variable to “SELECT RESERVATION_ID, TRIP_ID, NUM_PERSONS, TRIP_PRICE FROM RESERVATION WHERE CUSTOMER_NUM = '” and makes everything necessary in the command up to and including the single quotation mark preceding the order number...

Blurred answer
Students have asked these similar questions
Write a stored procedure that accepts a department ID, uses BULK COLLECT to retrieve all employees in that department, and displays their first name and salary. Then write an anonymous block to run that procedure for department 100.
Below are some rows of the table INVOICE ​ COD PROV_COD DATE TYPE LOC TOTAL 2910 192 2022-03-11 90 TX 1928 9301 384 2022-05-03 90 NY 2800   Overdue invoices are those whose date plus TYPE days have passed. Which of the following shows all invoices with overdue dates?     a. SELECT * FROM INVOICE WHERE CURDATE() - DATE > TYPE   b. SELECT * FROM INVOICE WHERE CURDATE()-TYPE >DATE   c. SELECT * FROM INVOICE WHERE DATE+TYPE < CURDATE()   d. SELECT * FROM INVOICE WHERE DATE+TYPE > CURDATE()
Guideline: Pls create employees table and populate it with the scripts provided for you (if the employees table does not exist)   1. PL/SQL Cursor: Using Cursor, please write PL/SQL program to retrieve data from employees table and display employee first and last name.   2. PL/SQL Exceptions: Write PL/SQL program to data from employees table and handle the following exceptions   1) NO_DATA_FOUND   2) TOO_MANY_ROWS   3) WHEN OTHERS   4) VALUE_ERROR - This exception is raised, when the value which is returned does not match with the datatype variable.   5) DUP_VAL_ON_INDEX - This exception is raised when we try to insert a duplicate value on a primary key or unique key
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781285196145
Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:Cengage Learning
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Oracle 12c: SQL
Computer Science
ISBN:9781305251038
Author:Joan Casteel
Publisher:Cengage Learning
Text book image
CMPTR
Computer Science
ISBN:9781337681872
Author:PINARD
Publisher:Cengage