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;
At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean’s wants to create a trigger that automatically updates the stock level of all pr
Indeterminacy in SQL Some SQL expressions are actually not function invocations at all in the mathematical sense, being indeterminate-invocations operating on identical input
I would like to have a custom MS Access database designed and coded that would help me schedule my customer's orders and that would help me track my employees production output and
Project Description: This is stage 1 of a larger conversion project. We are converting a traditional Server/Client application written in Access 2007 into a web interface with S
Understanding Nested Tables Within the database, the nested tables can be considered as one-column database tables. The Oracle stores the rows of a nested table in no specific o
UNNEST operator in SQL The inverse operator of GROUP is UNGROUP. SQL has an operator, UNNEST, that can be used for similar purposes, but its method of invocation is somewhat p
Explicit Cursors The set of rows returned by the query can include zero, one, or multiple rows, depending on how many rows meet your search criteria. Whenever a query returns
Using EXCEPTION_INIT To handle unnamed internal exceptions, you should use the OTHERS handler or the pragma EXCEPTION_INIT. The pragma is a compiler directive that can be th
Disjunction (OR, ∨) Again we have nine rows instead of just four and again, when unknown is not involved, the rows are as for 2VL. Also, when anything is paired with true, t
Parameter Default Values As the illustration below shows, you can initialize the IN parameters to the default values. In that way, you can pass various numbers of actual par
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