• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

Macros in TeraData

Macros

Creating a Macro in Teradata

Create macro< macro  name>(<params>)AS(SQL Queries);

 

Replacing a Macro in Teradata

Replace macro< macro  name>(<params>)AS(SQL Queries);

 

Droping  a Macro in Teradata

Drop macro< macro  name>

 

Viewing a Macro in Teradata

SHOW macro< macro  name>

 

Executing a Macro in Teradata

Exec < macro  name>(<params>) OR Execute< macro  name>>(<params>) CREATE macro mc – party2 (partyid1 integer)

As(Select* From party where party id =:party id1 or party name> :party income1;)

Exe mc- party2 (2,20000)

Interested in mastering Teradata Training? Enroll now for FREE demo on Teradata Training.

Using Macros to preserve integrity MACROS may be used for either of the following purpose: 2To insure data integrity that the data conforms to certain or value restrictions 2To insure referential integrity that the data being input as foreign keys have legal primary key values else where in the database Create a s macro which inserts a new party member row with the following restrictions 2Party must be over 21 years of age 2Party must be assigned a valid party code. 2Create macro new – party (pid integer, pname varchar(30),pcode integer, Hired data, birth date)

Learn more about Teradata Interview Questions in this blog post.

As(Roll back work ’Invalid Here’)

Where(:Hired- birth)/365<21;

Roll back work ’Invalid party code’

Where: pcode not in (Select party code from party where party code =: pacode);

Insert into party(Party id, party name, party code, j date)

Values(:pid: p name, :p code: hired););

 

Fail

  exe new party (19,’meer’, 40,’2010-08-06’,’2010-08-06’)

 

Success

exe new  party(19,’meer’,40,’2010-08-06,’’1981-08-06’)

For Indepth knowledge on Teradata click on:

 

Summary
Review Date
Reviewed Item
Macros in TeraData
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Macros in TeraData"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.