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

Cursors in Teradata


It is a stored memory area where the result set store and we can navigate the result set we can read one by one row from result set]

Based on the operations there are 2 types of cursors

  1. Position cursor
  2. Non- position cursor


Position cursor

Position cursor are updatable cursor


Non – position cursor

Non – position cursor are read only


Cursor Declaration

We can declare cursor

  1. INSIDE A Procedure[procedure cursor]
At TekSlate, we offer resources that help you in learning various IT courses. We avail both written
 material and demo video tutorials. To gain in-depth knowledge and be on par with practical
 experience, then explore Online Teradata Training.

Implicitly cursor

  1. By using dynamic SQL
  2. By using Embedded SQL etc


Cursor declaration is generally in two ways

For loop cursor

The scope of the cursor is within the for loop only


Declaration cursor

The scope of the cursor is between begin and END statement only


Cursor process

It is 5 steps process

  1. Declaring the cursor
  2. Opening the cursor
  3. Fetching the data from the cursor
  4. Working with rows of cursor
  5. Closing the cursor
Learn more about Teradata Interview Questions in this blog post.

Cursor error codes

Ex: If cursor is not open but we are trying to close the cursor at that time the SQL code is 7362


Example of procedure cursor

Create procedure SP3()


Declare var1 integer;

Declare var2 character(30);

Declare C1  cursor For

Select party id , party name from party ORDER By party id;

Open C1;

While(SQL Code=o)DO

Fetch C1 into var1, var2;

Insert into party1(Party id, party name) values(var1, var2);

End while

Close cd;


Call SP3()

Select* From party1;

For Indepth knowledge on Teradata click on:

Review Date
Reviewed Item
Cursors in Teradata
Author Rating

“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.”

1 Responses on Cursors in Teradata"

  1. MITCH says:

    The right click is disabled, seriously?? Are you living in stone age ?? is this the top secret sacred code ??

Leave a Message

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

Site Disclaimer, Copyright © 2016 - All Rights Reserved.


Please leave a message and we'll get back to you soon.

I agree to be contacted via e-mail.