Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Manipulating Individual ElementsFaraway you have manipulated an entire collection. Within the SQL, to manipulate the individual elements of the collection, and then use the operator TABLE. The operand of TABLE is a subquery which returns a single column value for you to manipulate. That the value is the nested table or the varray.In the illustration below, you add a row to the History Department nested table stored in the column courses:BEGININSERT INTOTABLE(SELECT courses FROM department WHERE name = ’History’)VALUES(3340, ’Modern China’, 4);END;In the next illustration, you revise the number of credits for two courses offered by the Psychology Department:DECLAREadjustment INTEGER DEFAULT 1;BEGINUPDATE TABLE(SELECT courses FROM departmentWHERE name = ’Psychology’)SET credits = credits + adjustmentWHERE course_no IN (2200, 3540);END;In the following illustration, you retrieve the number and the title of a specific course offered by the History Department:DECLAREmy_course_no NUMBER(4);my_title VARCHAR2(35);BEGINSELECT course_no, title INTO my_course_no, my_titleFROM TABLE(SELECT courses FROM departmentWHERE name = ’History’)WHERE course_no = 3105;...END;In the next illustration, you delete all 5-credit courses offered by the English Department:BEGINDELETE TABLE(SELECT courses FROM departmentWHERE name = ’English’)WHERE credits = 5;END;In the following illustration, you recover the title and cost of the Maintenance Department’s fourth project from the varray column projects:DECLAREmy_cost NUMBER(7,2);my_title VARCHAR2(35);BEGINSELECT cost, title INTO my_cost, my_titleFROM TABLE(SELECT projects FROM departmentWHERE dept_id = 50)WHERE project_no = 4;...END;Presently, you cannot reference the individual elements of a varray in an UPDATE, INSERT, or DELETE statement. And hence, you should use the PL/SQL procedural statements. In the illustration below, the stored procedure add_project inserts a new project into the department’s project list at a given position a shown:CREATE PROCEDURE add_project (dept_no IN NUMBER,new_project IN Project,position IN NUMBER) ASmy_projects ProjectList;BEGINSELECT projects INTO my_projects FROM departmentWHERE dept_no = dept_id FOR UPDATE OF projects;my_projects.EXTEND; -- make room for new project/* Move varray elements forward. */FOR i IN REVERSE position..my_projects.LAST - 1 LOOPmy_projects(i + 1) := my_projects(i);END LOOP;my_projects(position) := new_project; -- add new projectUPDATE department SET projects = my_projectsWHERE dept_no = dept_id;END add_project;The stored procedure updates below for a given project is:CREATE PROCEDURE update_project (dept_no IN NUMBER,proj_no IN NUMBER,new_title IN VARCHAR2 DEFAULT NULL,new_cost IN NUMBER DEFAULT NULL) ASmy_projects ProjectList;BEGINSELECT projects INTO my_projects FROM departmentWHERE dept_no = dept_id FOR UPDATE OF projects;/* Find project, update it, then exit loop immediately. */FOR i IN my_projects.FIRST..my_projects.LAST LOOPIF my_projects(i).project_no = proj_no THENIF new_title IS NOT NULL THENmy_projects(i).title := new_title;END IF;IF new_cost IS NOT NULL THENmy_projects(i).cost := new_cost;END IF;EXIT;END IF;END LOOP;UPDATE department SET projects = my_projectsWHERE dept_no = dept_id;END update_project;
Develop Data Business Intelligence Project Project Description: We are linking our Microsoft SQL Database to GoodData Business Intelligence. We are seeking somebody who has e
Blocks: The fundamental program unit in the PL/SQL is the block. The PL/SQL block is defined by the keywords BEGIN, DECLARE, EXCEPTION, and END. These keywords partition the b
Data Abstraction The Data abstraction extracts the important properties of data while ignoring the not necessary details. Once you design a data structure, you can fail to reme
Declarations in SQL Your program stores values in the variables and constants. As the program executes, the value of the variables can change, but the values constants cannot.
EXIT The EXIT statement forces a loop to done unconditionally. Whenever an EXIT statement is encountered, the loop is done immediately and controls the passes to the next statem
SQL Functions The PL/SQL uses all the SQL functions involving the following aggregate functions that summarize the whole columns of the Oracle data: GROUPING, AVG, COUNT, STDDE
Definition of FROM - SQL Recall that the operand of FROM is denoted by a commalist, each element of that commalist being a table expression optionally accompanied by a range v
What are the rates for help in writing PL/SQL procedures and functions?
Opening a Cursor Opening the cursor executes the query & identifies the result set that consists of all rows that meet the query search criteria. For the cursors declared usin
Product-specific Packages The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illus
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd