Create a package pkg_customer with specification and body. The package has a procedure named addCustomer to add new customer. The procedure will take customer id, name and address as parameter and inserts the customer to the t_customer table.PACKAGE pkg_customerPROCEDURE addCustomer(c_id t_customer.cust_id%type, c_name t_customer.cust_name%type, c_addr t_customer.cust_address%type)Package name : pkg_customerProcedure name : addCustomerParameter : c_id, c_name and c_addrNote:Do not change the package or procedure nameDo not change the argument count and orderDo not change the output text.You can query the table records using select statementDelimiter / is mandatory. If delimiter is missed, then while executing nothing will be displayedWhile executing, if you get WARNING: PROCEDURE CREATED WITH COMPILATION ERRORS, then use SHOW ERRORS to display the errors in the procedure.Instructions:1. Create the package successfully2. Once the package is created, check the functionality of the procedure using different anonymous block call.3. DO NOT submit the anonymous block. Submit only the CREATE PACKAGE query.Sample Input and Output:If the addCustomer procedure is called using 126, 'BNETON ELECTRONICS', '2215, Venus Avenue', then new records will be inserted into T_CUSTOMER table. You can query using SELECT and cross check it.SubmitSaveExecutePrevious Submission
Question
Create a package pkg_customer with specification and body. The package has a procedure named addCustomer to add new customer. The procedure will take customer id, name and address as parameter and inserts the customer to the t_customer table.PACKAGE pkg_customerPROCEDURE addCustomer(c_id t_customer.cust_id%type, c_name t_customer.cust_name%type, c_addr t_customer.cust_address%type)Package name : pkg_customerProcedure name : addCustomerParameter : c_id, c_name and c_addrNote:Do not change the package or procedure nameDo not change the argument count and orderDo not change the output text.You can query the table records using select statementDelimiter / is mandatory. If delimiter is missed, then while executing nothing will be displayedWhile executing, if you get WARNING: PROCEDURE CREATED WITH COMPILATION ERRORS, then use SHOW ERRORS to display the errors in the procedure.Instructions:1. Create the package successfully2. Once the package is created, check the functionality of the procedure using different anonymous block call.3. DO NOT submit the anonymous block. Submit only the CREATE PACKAGE query.Sample Input and Output:If the addCustomer procedure is called using 126, 'BNETON ELECTRONICS', '2215, Venus Avenue', then new records will be inserted into T_CUSTOMER table. You can query using SELECT and cross check it.SubmitSaveExecutePrevious Submission
Solution
To create the package and procedure in Oracle SQL, you can follow the steps below:
Step 1: Create the package specification. This is like a function prototype in C/C++. It declares the types, variables, constants, exceptions, cursors, and subprograms available for use.
CREATE OR REPLACE PACKAGE pkg_customer AS
PROCEDURE addCustomer(
c_id t_customer.cust_id%type,
c_name t_customer.cust_name%type,
c_addr t_customer.cust_address%type
);
END pkg_customer;
/
Step 2: Create the package body. This is where you define the procedures and functions that were declared in the package specification.
CREATE OR REPLACE PACKAGE BODY pkg_customer AS
PROCEDURE addCustomer(
c_id t_customer.cust_id%type,
c_name t_customer.cust_name%type,
c_addr t_customer.cust_address%type
) IS
BEGIN
INSERT INTO t_customer (cust_id, cust_name, cust_address)
VALUES (c_id, c_name, c_addr);
END addCustomer;
END pkg_customer;
/
Now, you can call the procedure from an anonymous block to test it:
BEGIN
pkg_customer.addCustomer(126, 'BNETON ELECTRONICS', '2215, Venus Avenue');
END;
/
Remember to commit the transaction to make the changes permanent:
COMMIT;
Finally, you can check the inserted data:
SELECT * FROM t_customer WHERE cust_id = 126;
This should return the newly inserted customer.
Similar Questions
Create Android Application for performing the following operation onthe table customer (id, name, address, phone)(Use SQL database)i) Insert new customerii) Display details on toast
Create a procedure named 'insertConnection' which has connection_name as an input parameter with varchar2 as its datatype. This procedure should take the count of the existing table records(electricity_connection_type) and add 1 with that to generate the new electricity_connection_type id.The newly generated id along with the connection_name should be inserted into the electricity_connection_type table
Multi File Programming QuestionWrite a query to insert any 7 records to the table 'Customers'The column names and data types are given below.Table Details:Table name: CustomersColumn Names:customer_id INT PRIMARY KEY,first_name VARCHAR (255) NOT NULL,last_name VARCHAR (255) NOT NULL,phone VARCHAR (25),email VARCHAR (255) NOT NULL,street VARCHAR (255),city VARCHAR (50),state VARCHAR (25),zip_code VARCHAR (5)Note:Table names are case-sensitive.Customers table is already created in the backend.Input format :No Console InputOutput format :The Output prints the number of rows inserted.Sample test cases :Input 1 :Output 1 :count(*)7Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Write PL/pgSQL using trigger for insertion of first_name, last_name, amount and payment_id into Customer_backup table whendeletion happens from Customer table considering below schema.Customer_backup (first_name, last_name, amount, payment_id)Customer (customer_id, payment_id, first_name, last_name, amount)Create tables with Primary Key, foreign key constraints in given schemas
Create a procedure named 'insertMeter' which takes 2 input parameters namely, meter_number is type of varchar2 and building_id is type of int. This procedure will take the count of the existing table records(meter) and add 1 with that to generate the new meter id.The newly generated id along with the meter_number and building_id should be inserted into the meter table.Hints:Procedure name : insertMeterParameters : meter_number(varchar2) ,building_id(int)SubmitSaveExecutePrevious Submission
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.