Knowee
Questions
Features
Study Tools

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

Question

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

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is the PL/SQL procedure that you requested:

CREATE OR REPLACE PROCEDURE insertConnection(connection_name IN VARCHAR2) IS
  new_id NUMBER;
BEGIN
  SELECT COUNT(*) + 1 INTO new_id FROM electricity_connection_type;
  
  INSERT INTO electricity_connection_type(id, name) VALUES (new_id, connection_name);
  
  COMMIT;
EXCEPTION
  WHEN OTHERS THEN
    ROLLBACK;
    RAISE;
END insertConnection;

This procedure first counts the number of records in the electricity_connection_type table and adds 1 to it to generate a new id. Then it inserts a new record into the electricity_connection_type table with the new id and the connection_name passed as a parameter. If any error occurs during these operations, it rolls back the transaction and re-raises the exception.

This problem has been solved

Similar Questions

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

Create a procedure named 'insertRoute' which has route_name as an input parameter with varchar as its datatype. This procedure should take the count of the existing table records(route table) and add 1 with that to generate the new route id.The newly generated id along with the route_name should be inserted into the route table.Hints:Procedure name : insertRouteParameters : route_name is type of varchar

Write a query to display the entire contents of the 'electricity_connection_type'. Display the records in ascending order based on their connection name.

Create a procedure named 'findConnection' which which has contactNumber as an input parameter with varchar as its data type and and  connection as an output parameter with varchar as its datatype. This procedure should find the name of the connection for the contactNumber passed as parameter.Hints:Procedure name :findConnectionParameters : contactNumber(varchar),connection(varchar)SubmitSaveExecutePrevious Submission

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.

1/1

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.