Cursors in Teradata

12 October, 2020

Related Blogs


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

  • Position cursor
  • Non- position cursor

Position cursor

Position cursor are updatable cursor

Non – position cursor

Non – position cursor is read-only

Cursor Declaration

We can declare a cursor

  • INSIDE A Procedure[procedure cursor]

Inclined to build a profession as Teradata Developer? Then here is the blog post on, explore 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 the 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 the cursor
  5. Closing the cursor

Teradata Interview Questions

Cursor error codes

Ex: If the 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:

About Author


Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .