Question

Oracle PL/SQL Using Dynamic SQL to create a procedure named add_row_sp for inserting a row into...

Oracle PL/SQL

Using Dynamic SQL to create a procedure named add_row_sp for inserting a row into a table with three columns: add_rows (p_table_name VARCHAR2, p_column1 NUMBER, p_column2 VARCHAR2, p_column3 NUMBER). Testing the procedure by using the following block to add a record to the BB_TAX table:

BEGIN
add_row_sp ('BB_TAX', 4, 'SD', 0.02);
END;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

ORACLE Stored Procedure:

create or replace procedure "ADD_ROW_SP" (p_table_name VARCHAR2, p_column1 NUMBER, p_column2 VARCHAR2, p_column3 NUMBER)
is
begin
execute immediate
'insert into '||p_table_name ||' values(:1, :2, :3) ' using p_column1, p_column2, p_column3;
end;

________________________________________________________________________________________________

Add a comment
Know the answer?
Add Answer to:
Oracle PL/SQL Using Dynamic SQL to create a procedure named add_row_sp for inserting a row into...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • oracle 11g 2nd edition pl/sql Assignment 5-10: Returning a Record Create a procedure named DDPROJ_SP that...

    oracle 11g 2nd edition pl/sql Assignment 5-10: Returning a Record Create a procedure named DDPROJ_SP that retrieves project information for a specific project based on a project ID. The procedure should have two parameters: one to accept a project ID value and another to return all data for the specified project. Use a record variable to have the procedure return all database column values for the selected project. Test the procedure with an anonymous block.

  • PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create...

    PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....

  • Oracle 11g PL/SQL Programming Sometimes Brewbean’s customers mistakenly leave an item out of a basket that’s...

    Oracle 11g PL/SQL Programming Sometimes Brewbean’s customers mistakenly leave an item out of a basket that’s already been checked out, so they create a new basket containing the missing items. However, they request that the baskets be combined so that they aren’t charged extra shipping. An application page has been developed that enables employees to change the basket ID of items in the BB_BASKETITEM table to another existing basket’s ID to combine the baskets. A block has been constructed to...

  • Create a PL/SQL procedure that takes department ID as an input and prints the details of...

    Create a PL/SQL procedure that takes department ID as an input and prints the details of all the students including the Student ID (represented as StuID), name, and the description of the major that they are currently enrolled in. You may use the following procedure template: CREATE OR REPLACE PROCEDURE Student_Major (I_deptID IN Student.DeptID%type) AS CURSOR c1 is ... ... BEGIN ... END Student_Major;

  • In oracle sql, how do I add "not null constraint" at end of create table block...

    In oracle sql, how do I add "not null constraint" at end of create table block and give it a name without using the CHECK constraint? Is it e.g., CONSTRAINT constraintName NOT NULL If so, then how does the statement know which columnName I'm referring to to make NOT NULL? I know that I can do this after declaring the column, what I'm wondering about is how to do this after declaring all the columns.

  • I am supposed to create the code in SQL for the 3 Triggers using the information...

    I am supposed to create the code in SQL for the 3 Triggers using the information on the table below. 13.. Assume the Branch table contains a column called ?Total value that-represents the -total price. for all books.at -that branch. Following ?the style shown in-the text, write the code for the following-triggers. a.-When ?inserting a row in the Copy table, -add -the price -to the -total -value for the appropriate branch . b. When-updating -a -row in-the Copy table, .add-the-difference...

  • Please write SQL Query for following questions using Northwind Database: 1. Create a procedure to add...

    Please write SQL Query for following questions using Northwind Database: 1. Create a procedure to add a new record to Territories table. Call it NewTerr. Add the following records using the procedure. TerritoryID        TerritoryDescription     Region 88888 Brooklyn 1 99999 Waco 4 77777 Long Beach 2 2. Create an Update Procedure that will change the Region from 1 to 3 for record with TerritoryID 88888. Call it Update88. 3. Create a Delete Procedure that will delete the one record from...

  • Write PL/SQL Procedure that returns the names of people who spent over $100. Create table Resturauntorder...

    Write PL/SQL Procedure that returns the names of people who spent over $100. Create table Resturauntorder ( resturauntorder_id int, resturaunt_name varchar2(50), hotel_name varchar2(50), customer_name varchar2(50), order_date date, items_orderd varchar2(100), order_total decimal(5,2), payment_type varchar2(50), tip_amount decimal(5,2), primary key(resturauntorder_id) ); Insert into Resturauntorder values (123,'Terrace Restaurant', 'Hilton Palm Springs', 'John Smith', date '2019-01-10', 'Omelet Pan, Cinnamon French Toast, California eggs, Orange Juice', 60.49, 'cash', 10.33); Insert into Resturauntorder values (345,'Spiaggia', 'Hilton Chicago/Magnificent Mile Suite','Ashley Scott', date '2019-02-21', 'Polpo, Tonno Vitellato, Rabarbaro', 189.29,...

  • I am using oracle sql developer to create some queries to generated reports and it is...

    I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...

  • 1. Create a PL/SQL program block that determines the top students with respect to GPA. Assume...

    1. Create a PL/SQL program block that determines the top students with respect to GPA. Assume that the database has four tables. Student(SSN, SName, DOB, Major) , Grade(SSN, CNo, Grade(0,1,2,3,4)) and Course table(CNo,CName, Credit Hour), Prerequisite(CNo, PreCNo); Student and couse data ae given in the following SQL statements a. Accept a number n as user input with SQL*Plus telling top n%. b. In a loop get the SName and GPA of the top n% people with respect to GPA. c....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT