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;
Left and Right Joins LEFT OUTER JOIN can be used when you want to retrieve the data from the main table (table1) even if there is no match in other tables (table_2, table_3...
Tautology - Equivalences Rules: If there Tautologies are not all the time as much easy to note as the one above so than we can use these truth tables to be definite that a sta
Semidifference via EXCEPT and JOIN - SQL SELECT * FROM (SELECT StudentId FROM IS_CALLED WHERE Name = 'Devinder' EXCEPT DISTINCT CORRESPONDING SELECT StudentId
Tautologies: Above given table allows us to read the truth of the connectives in the next manner. Just expect we are looking at row three. It means this says that, if there P
Using the BULK COLLECT Clause The keywords BULK COLLECT specify the SQL engine to bulk-bind output collections before returning them to the PL/SQL engine. You can use these ke
What Is a Package? The package is a schema object that group logically related PL/SQL items, types, and subprograms. The Packages usually have 2 parts, a specification & a bo
We are seeking a freelance consultant that is familiar with Appgen applications. We require exporting all our data into a format appropriate for importing into SAP Business One. Pl
what are ER diagrams
What Are Subprograms? The Subprograms are named PL/SQL blocks which can take parameters and be invoked. The PL/SQL has 2 types of subprograms known as the procedure s and func
What are the rates for help in writing PL/SQL procedures and functions?
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