SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Anchored data type
An anchored data type is a data type that is defined to be the same as that of
another object. If the underlying object data type changes, the anchored data type
also changes.

    An anchored type defines a data type based on another SQL object such as a
         Column
         Global variable,
         SQL variable,
         SQL parameter
         Row of a table or view.

Features of the anchored data type
An anchored type defines a data type based on another SQL object such as a
column, global variable, SQL variable, SQL parameter, or the row of a table or view.

A data type defined using an anchored type definition maintains a dependency on
the object to which it is anchored. Any change in the data type of the anchor object
will impact the anchored data type. If anchored to the row of a table or view, the
anchored data type is ROW with the fields defined by the columns of the anchor
table or anchor view.

This data type is useful when declaring variables in cases where you require that the
variable have the same data type as another object, for example a column in a table,
but you do not know exactly what is the data type.

An anchored data type can be of the same type as one of:
      a row in a table
      a row in a view
      a cursor variable row definition
      a column in a table
      a column in a view
      a local variable, including a local cursor variable or row variable
      a global variable

Anchored data types can only be specified when declaring or creating one of the
following:
       a local variable in an SQL procedure, including a row variable
       a local variable in a compiled SQL function, including a row variable
       a routine parameter
       a user-defined cursor data type using the CREATE TYPE statement.
       It cannot be referenced in a DECLARE CURSOR statement.
       a function return data type
       a global variable
To define an anchored data type specify the ANCHOR DATA TYPE TO clause (or
the shorter form ANCHOR clause) to specify what the data type will be. If the
anchored data type is a row data type, the ANCHOR ROW OF clause, or one of its
synonyms, must be specified. These clauses are supported within the following
statements:
      DECLARE
      CREATE TYPE
      CREATE VARIABLE
      In this version, global variables can only be anchored to other global
      variables, a column in a table, or a column in a view.
Restrictions on the anchored data type
Review the restrictions on the use of the anchored data type before declaring
variables of this type or when troubleshooting problems related to their use.

The following restrictions apply to the use of anchored data types, including types
specified using the PL/SQL %TYPE attribute:
       Anchored data types are not supported in inline SQL functions.
       Anchored data types cannot reference nicknames or columns in nicknames.
       Anchored data types cannot reference typed tables, columns of typed tables,
       typed views, or columns of typed views.
       Anchored data types cannot reference declared temporary tables, or columns
       of declared temporary tables.
       Anchored data types cannot reference row definitions associated with a
       weakly typed cursor.
       Anchored data types cannot reference objects with a code page or collation
       that is different from the database code page or database collation.
Anchored data type variables
An anchored variable is a local variable or parameter with a data type that is an
anchored data type.

Anchored variables are supported in the following contexts:
     SQL procedures
         o In SQL procedures, parameters and local variables can be specified to
            be of an anchored data type.
     Compiled SQL functions
         o SQL functions created using the CREATE FUNCTION statement that
            specify the BEGIN clause instead of the BEGIN ATOMIC clause can
            include parameter or local variable specification that are of the
            anchored data type.
     Module variables
         o Anchored variables can be specified as published or unpublished
            variables defined within a module.
     Global variables
         o Global variables can be created of the anchored data type.
Declaring local variables of the anchored data type
Declaring local variables or parameters of the anchored data type is a task that you would
perform whenever it is necessary that the data type of the variable or parameter remain
consistent with the data type of the object to which it is anchored.
Before you begin

The object of the data type that the variable will be anchored to must be defined.

About this task

Procedure

   1. Formulate a DECLARE statement

           a. Specify the name of the variable.
           b. Specify the ANCHOR DATA TYPE TO clause.
           c. Specify the name of the object that is of the data type that the variable is to be
              anchored.

   2. Execute the DECLARE statement from a supported DB2Âź interface.

Results

If the DECLARE statement executes successfully, the variable is defined in the database
with the specified anchor data type.

Example
The following is an example of an anchored data type declaration in which a variable
named v1 is anchored to the data type of a column named c1 in a table named emp:

DECLARE v1 ANCHOR DATA TYPE TO emp.c1;

What to do next

Once the variable is defined it can be assigned a value, be referenced, or passed as a
parameter to routines.

Example: Variable declarations of anchored data types
Examples of anchored data type declarations can be useful references when declaring
variables.

The following is an example of a declaration of a variable named v1 that has the same data
type as the column name in table staff:
DECLARE v1 ANCHOR DATA TYPE TO staff.name;
The following is an example of a CREATE TYPE statement that defines a type
named empRow1 that is anchored to a row defined in a table namedemployee:
CREATE TYPE empRow1 AS ROW ANCHOR DATA TYPE TO ROW OF employee;
For variables declared of type empRow1, the field names are the same as the table column
names.

If the data type of the column name is VARCHAR(128), then the variable v1 will also be of
data type VARCHAR(128).

Examples: Anchored data type use in SQL routines
Examples of anchored data type use in SQL routines are useful to reference when creating
your own SQL routines.

The set of examples below demonstrate various features and uses of anchored data types in
SQL routines. The anchored data type features are demonstrated more so than the features
of the SQL routines that contain them.

The following is an example that demonstrates a declared variable that is anchored to the
data type of a column in a table:
CREATE TABLE tab1(col1 INT, col2 CHAR)@

INSERT INTO tab1 VALUES (1,2)@

INSERT INTO tab1 VALUES (3,4)@

CREATE TABLE tab2 (col1a INT, col2a CHAR)@

CREATE PROCEDURE p1()
BEGIN
  DECLARE var1 ANCHOR tab1.col1;
  SELECT col1 INTO var1 FROM tab1 WHERE col2 = 2;
  INSERT INTO tab2 VALUES (var1, 'a');
END@

Weitere Àhnliche Inhalte

Was ist angesagt?

Dbms and rdbms ppt
Dbms and rdbms pptDbms and rdbms ppt
Dbms and rdbms pptrahul kapoliya
 
Multithreading
MultithreadingMultithreading
MultithreadingA B Shinde
 
Adbms 17 object query language
Adbms 17 object query languageAdbms 17 object query language
Adbms 17 object query languageVaibhav Khanna
 
Database Presentation
Database PresentationDatabase Presentation
Database Presentationa9oolq8
 
DBMS _Relational model
DBMS _Relational modelDBMS _Relational model
DBMS _Relational modelAzizul Mamun
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQLrehaniltifat
 
Advance database system(part 4)
Advance database system(part 4)Advance database system(part 4)
Advance database system(part 4)Abdullah Khosa
 
Database concepts
Database conceptsDatabase concepts
Database conceptsHarry Potter
 
4. plsql
4. plsql4. plsql
4. plsqlAmrit Kaur
 
Oracle Architecture
Oracle ArchitectureOracle Architecture
Oracle ArchitectureNeeraj Singh
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJDharita Chokshi
 
3 process management
3 process management3 process management
3 process managementDr. Loganathan R
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modelingoudesign
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)Sharad Dubey
 
Database Security
Database SecurityDatabase Security
Database SecurityShingalaKrupa
 
Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation LanguageJas Singh Bhasin
 
trigger dbms
trigger dbmstrigger dbms
trigger dbmskuldeep100
 
SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceMark Ginnebaugh
 
Normalization
NormalizationNormalization
NormalizationWangu Thupa
 

Was ist angesagt? (20)

Dbms and rdbms ppt
Dbms and rdbms pptDbms and rdbms ppt
Dbms and rdbms ppt
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Adbms 17 object query language
Adbms 17 object query languageAdbms 17 object query language
Adbms 17 object query language
 
Database Presentation
Database PresentationDatabase Presentation
Database Presentation
 
DBMS _Relational model
DBMS _Relational modelDBMS _Relational model
DBMS _Relational model
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Advance database system(part 4)
Advance database system(part 4)Advance database system(part 4)
Advance database system(part 4)
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
4. plsql
4. plsql4. plsql
4. plsql
 
Oracle Architecture
Oracle ArchitectureOracle Architecture
Oracle Architecture
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJ
 
3 process management
3 process management3 process management
3 process management
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modeling
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
Database Security
Database SecurityDatabase Security
Database Security
 
Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation Language
 
trigger dbms
trigger dbmstrigger dbms
trigger dbms
 
SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database Performance
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Normalization
NormalizationNormalization
Normalization
 

Andere mochten auch

V.social campaign
V.social campaignV.social campaign
V.social campaignMichael Scott
 
More than yea or nay day 1 0
More than yea or nay day 1 0More than yea or nay day 1 0
More than yea or nay day 1 0Becknell
 
Taking The Plunge In Blogging 2
Taking The Plunge In Blogging 2Taking The Plunge In Blogging 2
Taking The Plunge In Blogging 2bigpinots
 
Tech pp
Tech ppTech pp
Tech ppCjd002
 
More than yea or nay day 2 0
More than yea or nay day 2 0More than yea or nay day 2 0
More than yea or nay day 2 0Becknell
 
Assignment 1(web)
Assignment 1(web)Assignment 1(web)
Assignment 1(web)Jay Patel
 
Codd rules
Codd rulesCodd rules
Codd rulesJay Patel
 
Acampada
AcampadaAcampada
Acampadapiko217
 
Codd rules
Codd rulesCodd rules
Codd rulesJay Patel
 
Images
ImagesImages
ImagesJay Patel
 
Presentation1
Presentation1Presentation1
Presentation1Jay Patel
 
MĂ­rame a los ojos
MĂ­rame a los ojosMĂ­rame a los ojos
MĂ­rame a los ojospiko217
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software toolsJay Patel
 
Selection sort
Selection sortSelection sort
Selection sortJay Patel
 

Andere mochten auch (15)

V.social campaign
V.social campaignV.social campaign
V.social campaign
 
More than yea or nay day 1 0
More than yea or nay day 1 0More than yea or nay day 1 0
More than yea or nay day 1 0
 
Taking The Plunge In Blogging 2
Taking The Plunge In Blogging 2Taking The Plunge In Blogging 2
Taking The Plunge In Blogging 2
 
Tech pp
Tech ppTech pp
Tech pp
 
More than yea or nay day 2 0
More than yea or nay day 2 0More than yea or nay day 2 0
More than yea or nay day 2 0
 
Assignment 1(web)
Assignment 1(web)Assignment 1(web)
Assignment 1(web)
 
Codd rules
Codd rulesCodd rules
Codd rules
 
Acampada
AcampadaAcampada
Acampada
 
Codd rules
Codd rulesCodd rules
Codd rules
 
Images
ImagesImages
Images
 
Presentation1
Presentation1Presentation1
Presentation1
 
MĂ­rame a los ojos
MĂ­rame a los ojosMĂ­rame a los ojos
MĂ­rame a los ojos
 
Inwork-johdanto 3.12.2013
Inwork-johdanto 3.12.2013Inwork-johdanto 3.12.2013
Inwork-johdanto 3.12.2013
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software tools
 
Selection sort
Selection sortSelection sort
Selection sort
 

Ähnlich wie Anchored data type

Anchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typeAnchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typedhruv patel
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)Nalina Kumari
 
Oracle 11G Development Training noida Delhi NCR
Oracle 11G Development Training noida Delhi NCROracle 11G Development Training noida Delhi NCR
Oracle 11G Development Training noida Delhi NCRShri Prakash Pandey
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answersLakshmiSarvani6
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptxNalinaKumari2
 
DBMS MODULE 3 NOTES ENGINEERING CSE .pdf
DBMS MODULE 3 NOTES ENGINEERING CSE .pdfDBMS MODULE 3 NOTES ENGINEERING CSE .pdf
DBMS MODULE 3 NOTES ENGINEERING CSE .pdfraki082m
 
Oracle11gdevtrainingindelhincr
Oracle11gdevtrainingindelhincrOracle11gdevtrainingindelhincr
Oracle11gdevtrainingindelhincrducat1989
 
chapter9-SQL.pptx
chapter9-SQL.pptxchapter9-SQL.pptx
chapter9-SQL.pptxYaser52
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from pptkingshuk_goswami
 
11i&r12 difference
11i&r12 difference11i&r12 difference
11i&r12 differencevenki_venki
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server iiIblesoft
 

Ähnlich wie Anchored data type (20)

Unit1
Unit1Unit1
Unit1
 
Anchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data typeAnchor data type,cursor data type,array data type
Anchor data type,cursor data type,array data type
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Pl sql
Pl sqlPl sql
Pl sql
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
Oracle 11G Development Training noida Delhi NCR
Oracle 11G Development Training noida Delhi NCROracle 11G Development Training noida Delhi NCR
Oracle 11G Development Training noida Delhi NCR
 
Dbms important questions and answers
Dbms important questions and answersDbms important questions and answers
Dbms important questions and answers
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
 
DBMS MODULE 3 NOTES ENGINEERING CSE .pdf
DBMS MODULE 3 NOTES ENGINEERING CSE .pdfDBMS MODULE 3 NOTES ENGINEERING CSE .pdf
DBMS MODULE 3 NOTES ENGINEERING CSE .pdf
 
Oracle11gdevtrainingindelhincr
Oracle11gdevtrainingindelhincrOracle11gdevtrainingindelhincr
Oracle11gdevtrainingindelhincr
 
chapter9-SQL.pptx
chapter9-SQL.pptxchapter9-SQL.pptx
chapter9-SQL.pptx
 
Oracle report from ppt
Oracle report from pptOracle report from ppt
Oracle report from ppt
 
Ankit
AnkitAnkit
Ankit
 
12 SQL
12 SQL12 SQL
12 SQL
 
12 SQL
12 SQL12 SQL
12 SQL
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 
Plsqlobj
PlsqlobjPlsqlobj
Plsqlobj
 
11i&r12 difference
11i&r12 difference11i&r12 difference
11i&r12 difference
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server ii
 

Mehr von Jay Patel

Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)Jay Patel
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)Jay Patel
 
Quiz(web)
Quiz(web)Quiz(web)
Quiz(web)Jay Patel
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)Jay Patel
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)Jay Patel
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
Cursor
CursorCursor
CursorJay Patel
 
Mutlimedia authoring tools
Mutlimedia authoring toolsMutlimedia authoring tools
Mutlimedia authoring toolsJay Patel
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 textJay Patel
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 textJay Patel
 
Hypertext and hypermedia
Hypertext and hypermediaHypertext and hypermedia
Hypertext and hypermediaJay Patel
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software toolsJay Patel
 
Cursor
CursorCursor
CursorJay Patel
 
Lecturestacks 110802115132-phpapp02
Lecturestacks 110802115132-phpapp02Lecturestacks 110802115132-phpapp02
Lecturestacks 110802115132-phpapp02Jay Patel
 
Introductionofdatastructure 110731092019-phpapp01
Introductionofdatastructure 110731092019-phpapp01Introductionofdatastructure 110731092019-phpapp01
Introductionofdatastructure 110731092019-phpapp01Jay Patel
 
Applicationsofstack 110805072322-phpapp01
Applicationsofstack 110805072322-phpapp01Applicationsofstack 110805072322-phpapp01
Applicationsofstack 110805072322-phpapp01Jay Patel
 
Chapter19 multimedia-091006115642-phpapp02 (1)
Chapter19 multimedia-091006115642-phpapp02 (1)Chapter19 multimedia-091006115642-phpapp02 (1)
Chapter19 multimedia-091006115642-phpapp02 (1)Jay Patel
 

Mehr von Jay Patel (20)

Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Unit 3(rdbms)
Unit 3(rdbms)Unit 3(rdbms)
Unit 3(rdbms)
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)
 
Quiz(web)
Quiz(web)Quiz(web)
Quiz(web)
 
Assignment 2(web)
Assignment 2(web)Assignment 2(web)
Assignment 2(web)
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Inline function(oops)
Inline function(oops)Inline function(oops)
Inline function(oops)
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
Cursor
CursorCursor
Cursor
 
Mutlimedia authoring tools
Mutlimedia authoring toolsMutlimedia authoring tools
Mutlimedia authoring tools
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 text
 
Sound
SoundSound
Sound
 
Lecture6 text
Lecture6   textLecture6   text
Lecture6 text
 
Hypertext and hypermedia
Hypertext and hypermediaHypertext and hypermedia
Hypertext and hypermedia
 
Multimedia software tools
Multimedia software toolsMultimedia software tools
Multimedia software tools
 
Cursor
CursorCursor
Cursor
 
Lecturestacks 110802115132-phpapp02
Lecturestacks 110802115132-phpapp02Lecturestacks 110802115132-phpapp02
Lecturestacks 110802115132-phpapp02
 
Introductionofdatastructure 110731092019-phpapp01
Introductionofdatastructure 110731092019-phpapp01Introductionofdatastructure 110731092019-phpapp01
Introductionofdatastructure 110731092019-phpapp01
 
Applicationsofstack 110805072322-phpapp01
Applicationsofstack 110805072322-phpapp01Applicationsofstack 110805072322-phpapp01
Applicationsofstack 110805072322-phpapp01
 
Chapter19 multimedia-091006115642-phpapp02 (1)
Chapter19 multimedia-091006115642-phpapp02 (1)Chapter19 multimedia-091006115642-phpapp02 (1)
Chapter19 multimedia-091006115642-phpapp02 (1)
 

KĂŒrzlich hochgeladen

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

KĂŒrzlich hochgeladen (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Anchored data type

  • 1. Anchored data type An anchored data type is a data type that is defined to be the same as that of another object. If the underlying object data type changes, the anchored data type also changes.  An anchored type defines a data type based on another SQL object such as a  Column  Global variable,  SQL variable,  SQL parameter  Row of a table or view. Features of the anchored data type An anchored type defines a data type based on another SQL object such as a column, global variable, SQL variable, SQL parameter, or the row of a table or view. A data type defined using an anchored type definition maintains a dependency on the object to which it is anchored. Any change in the data type of the anchor object will impact the anchored data type. If anchored to the row of a table or view, the anchored data type is ROW with the fields defined by the columns of the anchor table or anchor view. This data type is useful when declaring variables in cases where you require that the variable have the same data type as another object, for example a column in a table, but you do not know exactly what is the data type. An anchored data type can be of the same type as one of: a row in a table a row in a view a cursor variable row definition a column in a table a column in a view a local variable, including a local cursor variable or row variable a global variable Anchored data types can only be specified when declaring or creating one of the following: a local variable in an SQL procedure, including a row variable a local variable in a compiled SQL function, including a row variable a routine parameter a user-defined cursor data type using the CREATE TYPE statement. It cannot be referenced in a DECLARE CURSOR statement. a function return data type a global variable To define an anchored data type specify the ANCHOR DATA TYPE TO clause (or the shorter form ANCHOR clause) to specify what the data type will be. If the anchored data type is a row data type, the ANCHOR ROW OF clause, or one of its
  • 2. synonyms, must be specified. These clauses are supported within the following statements: DECLARE CREATE TYPE CREATE VARIABLE In this version, global variables can only be anchored to other global variables, a column in a table, or a column in a view. Restrictions on the anchored data type Review the restrictions on the use of the anchored data type before declaring variables of this type or when troubleshooting problems related to their use. The following restrictions apply to the use of anchored data types, including types specified using the PL/SQL %TYPE attribute: Anchored data types are not supported in inline SQL functions. Anchored data types cannot reference nicknames or columns in nicknames. Anchored data types cannot reference typed tables, columns of typed tables, typed views, or columns of typed views. Anchored data types cannot reference declared temporary tables, or columns of declared temporary tables. Anchored data types cannot reference row definitions associated with a weakly typed cursor. Anchored data types cannot reference objects with a code page or collation that is different from the database code page or database collation. Anchored data type variables An anchored variable is a local variable or parameter with a data type that is an anchored data type. Anchored variables are supported in the following contexts: SQL procedures o In SQL procedures, parameters and local variables can be specified to be of an anchored data type. Compiled SQL functions o SQL functions created using the CREATE FUNCTION statement that specify the BEGIN clause instead of the BEGIN ATOMIC clause can include parameter or local variable specification that are of the anchored data type. Module variables o Anchored variables can be specified as published or unpublished variables defined within a module. Global variables o Global variables can be created of the anchored data type. Declaring local variables of the anchored data type Declaring local variables or parameters of the anchored data type is a task that you would perform whenever it is necessary that the data type of the variable or parameter remain consistent with the data type of the object to which it is anchored.
  • 3. Before you begin The object of the data type that the variable will be anchored to must be defined. About this task Procedure 1. Formulate a DECLARE statement a. Specify the name of the variable. b. Specify the ANCHOR DATA TYPE TO clause. c. Specify the name of the object that is of the data type that the variable is to be anchored. 2. Execute the DECLARE statement from a supported DB2Âź interface. Results If the DECLARE statement executes successfully, the variable is defined in the database with the specified anchor data type. Example The following is an example of an anchored data type declaration in which a variable named v1 is anchored to the data type of a column named c1 in a table named emp: DECLARE v1 ANCHOR DATA TYPE TO emp.c1; What to do next Once the variable is defined it can be assigned a value, be referenced, or passed as a parameter to routines. Example: Variable declarations of anchored data types Examples of anchored data type declarations can be useful references when declaring variables. The following is an example of a declaration of a variable named v1 that has the same data type as the column name in table staff: DECLARE v1 ANCHOR DATA TYPE TO staff.name; The following is an example of a CREATE TYPE statement that defines a type named empRow1 that is anchored to a row defined in a table namedemployee: CREATE TYPE empRow1 AS ROW ANCHOR DATA TYPE TO ROW OF employee; For variables declared of type empRow1, the field names are the same as the table column names. If the data type of the column name is VARCHAR(128), then the variable v1 will also be of data type VARCHAR(128). Examples: Anchored data type use in SQL routines
  • 4. Examples of anchored data type use in SQL routines are useful to reference when creating your own SQL routines. The set of examples below demonstrate various features and uses of anchored data types in SQL routines. The anchored data type features are demonstrated more so than the features of the SQL routines that contain them. The following is an example that demonstrates a declared variable that is anchored to the data type of a column in a table: CREATE TABLE tab1(col1 INT, col2 CHAR)@ INSERT INTO tab1 VALUES (1,2)@ INSERT INTO tab1 VALUES (3,4)@ CREATE TABLE tab2 (col1a INT, col2a CHAR)@ CREATE PROCEDURE p1() BEGIN DECLARE var1 ANCHOR tab1.col1; SELECT col1 INTO var1 FROM tab1 WHERE col2 = 2; INSERT INTO tab2 VALUES (var1, 'a'); END@