Using %type-declarations in sql, PL-SQL Programming

Assignment Help:

Using %TYPE

The %TYPE attribute gives the datatype of a variable or the database column. In the example below, the %TYPE gives the datatype of a variable:

credit REAL(7,2);
debit credit%TYPE;

The Variables declared using %TYPE is treated such as those declared using a datatype specifier. For example, given the earlier declarations, the PL/SQL treats debit such as REAL (7, 2) variable. The later example shows that a %TYPE declaration can involve an initialization clause:

balance NUMBER(7,2);
minimum_balance balance%TYPE := 10.00;
The %TYPE attribute is mainly useful when declaring a variable which refer to a database columns. You can reference a table & column, or you can reference an owner, column, table, and as in

my_dname scott.dept.dname%TYPE;

Using the %TYPE to declare my_dname has two merits. Firstly, you do not require knowing the exact datatype of dname. Secondly, when the database definition of the dname changes, the datatype of my_dname change accordingly at the run time.


Related Discussions:- Using %type-declarations in sql

Enrolment was split - sql, Enrolment was split - SQL Example shows ho...

Enrolment was split - SQL Example shows how relvars IS_CALLED and IS_ENROLLED_ON can be derived from the original ENROLMENT relvar, using projection in the initial assignment

Fetching from a cursor variable, Fetching from a Cursor Variable The F...

Fetching from a Cursor Variable The FETCH statement retrieve rows one at a time from the product set of a multi-row query. The syntax for the same is as shown: FETCH {curso

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

First step at defining type sid in sql, First Step at defining type SID in ...

First Step at defining type SID in SQL CREATE TYPE SID AS ( C VARCHAR(5) ) ; Explanation: TYPE SID announces that a type named SID is being defined to the syst

Prepare a slq project, Project Description: I want to write some SQL st...

Project Description: I want to write some SQL statements. The things I need are between pages 5-7. The only problem is that i want it till tomorrow. Skills required is SQL

Triggers, At times, customers make mistakes in submitting their orders and ...

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

Ssrs report writing, SSRS Report Writing Project Description: This re...

SSRS Report Writing Project Description: This report is part of a larger project to make a SQL Server Reporting Service (SSRS) based reporting solution. There can be more rep

Currval and nextval - sql pseudocolumns, CURRVAL and NEXTVAL The serie...

CURRVAL and NEXTVAL The series is a schema object which generates the sequential numbers. Whenever you form a sequence, you can specify its primary value and an increment. T

Develop data business intelligence project, Develop Data Business Intellige...

Develop Data Business Intelligence Project Project Description: We are linking our Microsoft SQL Database to GoodData Business Intelligence. We are seeking somebody who has e

Keyword and parameter description - goto statement, Keyword and Parameter D...

Keyword and Parameter Description: label_name: This is an undeclared identifier which labels an executable statement or the PL/SQL block. You can use a GOTO statement to

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