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

Positional and named notation, Positional and Named Notation You can wr...

Positional and Named Notation You can write the actual parameters when calling a subprogram, using either positional or named notation. That is, you can point to the relationsh

Introduction to oracle, Introduction Oracle 9i - it was made publ...

Introduction Oracle 9i - it was made public in the year 2001 with over 400 features, and graphics, it has merged the traditional business with modern internet application

%rowcount - implicit cursor attributes, %ROWCOUNT The %ROWCOUNT yields...

%ROWCOUNT The %ROWCOUNT yields the number of rows affected by the INSERT, UPDATE, or DELETE statement, or returned by a SELECT INTO statement. The %ROWCOUNT yields zero when a

Theory of spontaneous generation - origin of life, THEORY OF SPONTANEOUS GE...

THEORY OF SPONTANEOUS GENERATION - ABIOGENESIS OR AUTOGENESIS - According to this theory, the existing living communities have originated from non-living organic matter with

Parameter and keyword description - records, Parameter and Keyword Descript...

Parameter and Keyword Description: record_type_name: This identifies the user-defined type specifier that is used in the subsequent declarations of the records. NOT N

Between and not between operator in sql, BETWEEN and NOT BETWEEN Operator i...

BETWEEN and NOT BETWEEN Operator in SQL Example: Restricting exam marks to between 0 and 100 CREATE ASSERTION Marks_between_0_and_100 CHECK (NOT EXISTS (SELECT * FROM

Components of an object type in pl/sql, Components of an Object Type: A...

Components of an Object Type: An object type encapsulates the operations and data. Therefore, you can declare the methods and attributes in an object type specification, but no

Truth tables , Truth Tables: However in propositional logic - here we ...

Truth Tables: However in propositional logic - here we are restricted to expressing sentences and where the propositions are true or false - so we can check where a particular

Assignment 4, I need a query for PL/SQL, selecting names with cursor, goes ...

I need a query for PL/SQL, selecting names with cursor, goes down the list, assigns usernames (initials001) based on initials in the name. If two names have same initials the user

Parameter modes, Parameter Modes   To define the behavior of formal pa...

Parameter Modes   To define the behavior of formal parameters you use the parameter modes. The 3 parameter modes, IN, OUT, & IN OUT, can be used with any subprogram. Though, a

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