Trim String String Trim String Leading String Trailing: 'A' 'Anaconda'
Trim String String Trim String Leading String Trailing: 'A' 'Anaconda'
---- The Oracle TRIM function allows you to remove characters from the left, right, or both sides of a string. By
default, it trims from both sides of a string, but you can specify which side. The TRIM function looks like this:
TRIM (trim_string FROM source_string)
You can trim the characters from the left of the string (LEADING) or the right of the string (TRAILING) using extra
keywords:
TRIM (LEADING trim_string FROM source_string)
An example of the TRIM function is:
SELECT TRIM('a' FROM 'anaconda') FROM dual;
Q what is % type and %rowtype what is advantages over using this data types?
--%TYPE can be used with the column name preceded with table name to decide the datatype and length of the
variable at runtime. In this case there is no dependency on changes made to the data structure.
%ROWTYPE can be used to declare the variable having the same no. of variables inside it (ROWTYPE) as no. of
columns there in the table. In this case columns selected with SELECT statement must match with variables
inside the rowtype variable. If not then induvidually refer these variables inside the ROWTYPE variables
No need to know about data type of variable, if database definition of column of table are changes then type of
variables changed accordingly .
Q- what is difference between rowtype and type??
%rowtype is used whenever query returns a entire row of table or view
Type rec record is to be used whenever query returns column of different table or views and variables.
Q- what Is pl/sql table??
Object of type table are called plsql tables. Which are modeled as database tables. Plsql tables use a primary
plsql tables can have one column and a primary key
PL/SQL tables help you move bulk data. They can store columns or rows of Oracledata, and they can be passed
as parameters. So, PL/SQL tables make it easy to move collections of data into and out of database tables or
between client-side applications and stored subprograms
Q- what is cursor??
Cursor is a named private area in SQL from which information can be accessed. They are required to process
each row individually for queries which return multiple rows.
Plsql require a special capability to reterive and process more than one row and that resource is known as
cursors. A cursor is pointer to cotext area whichis an area of memory containing sql statements and information
for processing the statement.
Pl sql cursor is mechanism under which multiple rows of the datat form the database are selected and then each
row is individually processed inside plsql program.
There are two types of cursor-
Explicit cursor- For query that return more than one row an explicit cursor is declared and named by a
programmer in order to use explicit cursor in plsql .
A cursor is implicit by default. The user cannot control or process the information in this cursor.
If a query returns multiple rows of data, the program defines an explicit cursor. This allows the application to
process each row sequentially as the cursor returns it.
Q- what are the plsql statements used in cursor processing??
Declare cursor <cursor name> , open <cursor name>, fetch <cursor name> into <variable list> or record types,
close cursor name.
Q- what are the cursor attribute used in pl sql??
Anw- %isopen- to check whether cursor is open or not
%rowcount- number of rows fetched/updated/ deleted
%found- to check whether cursor fetch any row, true rows are fetched
%notfound- to check whether cursor fetched any rows, trues if rows fetched any row.
These attributes are processed with sql for implicit cursors with cursor name for explicit cursor.