Using trim - collection method, PL-SQL Programming

Assignment Help:

Using TRIM

This process has two forms. The TRIM removes an element from the end of the collection. The TRIM(n) removes the n elements from the end of the collection. For e.g. this statement removes all the last three elements from the nested table courses:

courses.TRIM(3);

If n is bigger than COUNT, then TRIM(n) raises SUBSCRIPT_BEYOND_COUNT.

TRIM operates on the internal size of the collection. Therefore, if TRIM encounters deleted elements, then it includes them in its tally. Consider the example shown below:

DECLARE

TYPE CourseList IS TABLE OF VARCHAR2(10);

courses CourseList;

BEGIN

courses := CourseList('Biol 4412', 'Psyc 3112', 'Anth 3001');

courses.DELETE(courses.LAST); -- delete element 3

/* At this point, COUNT equals 2, the number of valid

elements remaining. So, you might expect the next

statement to blank the nested table by trimming

elements 1 and 2. Instead, it trims valid element 2

and the deleted element 3 as TRIM includes deleted

elements in its tally. */

courses.TRIM(courses.COUNT);

DBMS_OUTPUT.PUT_LINE(courses(1)); -- prints 'Biol 4412'

In normal, do not depend on the interaction between the TRIM and DELETE. It is better to treat nested tables such as fixed-size arrays and use only DELETE, or to treat them like the stacks and use only TRIM and EXTEND.

The PL/SQL does not keep placeholders for the trimmed elements. As a result, you cannot replace a trimmed element just by assigning it a new value.


Related Discussions:- Using trim - collection method

Creating Views, Create a view named CustomerAddresses that shows the shippi...

Create a view named CustomerAddresses that shows the shipping and billing addresses for each customer in the MyGuitarShop database. This view should return these columns from the

Defining and declaring collections, Defining and Declaring Collections T...

Defining and Declaring Collections To create the collections, you must define a collection type, and then declare the collections of that type. You can define the VARRAY types a

Max and min operator in sql, MAX and MIN operator in SQL Example: ...

MAX and MIN operator in SQL Example: (SELECT MAX (Mark) FROM EXAM_MARK WHERE StudentId = 'S1') (SELECT MIN (Mark) FROM EXAM_MARK WHERE StudentId = 'S1') Example

Example of not exists in sql, Example of NOT EXISTS in SQL Example: Us...

Example of NOT EXISTS in SQL Example: Use of NOT EXISTS CREATE ASSERTION Must_be_enrolled_to_take_exam_alternative1 CHECK ( NOT EXISTS (SELECT StudentId, CourseId

Relational algebra, Define basic operators of relational algebra with an ex...

Define basic operators of relational algebra with an example each

Dbms, DBMS: The answer to this question is of course given in of the t...

DBMS: The answer to this question is of course given in of the theory book. This book is concerned with SQL DBMSs and SQL databases in particular. Soon we will be looking a

Create GUIs in PL/SQL, i NEED TO CREATE 3 guiS IN pl/sql sERVER PAGE FORM

i NEED TO CREATE 3 guiS IN pl/sql sERVER PAGE FORM

Transactions in sql, Transactions in SQL BEGIN TRANSACTION, COMMIT, an...

Transactions in SQL BEGIN TRANSACTION, COMMIT, and ROLLBACK, SQL has the same syntax except for START in place of BEGIN. However, START TRANSACTION is used only for outermost

Example of alternative formulation as a table constraint, Example of Altern...

Example of Alternative formulation as a table constraint Example: Alternative formulation as a table constraint ALTER TABLE EXAM_MARK ADD CONSTRAINT Must_be_enrolled_to_

I want customer management program, This is a Customer Management project. ...

This is a Customer Management project. Customer data is presented in a text file. The program will load this text data into its DB columns. The data mapping is user definable. User

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

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!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd