Group Discounts available for 3+ students and Corporate Clients

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 In-depth knowledge on Teradata click on:

“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, 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 *


Please Enter Your Details and Query.
Three + 6