Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8299525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:11:02+00:00 2026-06-08T16:11:02+00:00

The web seems a bit short on working examples for something that should be

  • 0

The web seems a bit short on working examples for something that should be quite common. A plain Jane example of “Get me some records”. This is my first ever Stored proc and all I want is to see some records. Why is that so flipping hard? 😉 I figure that if I can get one example that works, I can tune it from there into something I can really use. This is taken from another example I found on the web. Doesn’t compile because CURSOR declaration is a syntax error of some sort.

CREATE PROCEDURE "SCHEMA"."GETRESULTSET (
    IN "p1" VARCHAR(30))
DYNAMIC RESULT SETS 1
BEGIN       
DECLARE CURSOR cur1 WITH RETURN ONLY TO CLIENT FOR 
 SELECT partitioninfo FROM SCHEMA.SessionInfo where username = p1;    
  OPEN cur1;    
END;

Anyway, sure could use a clue. I saw an example where the CURSOR was declared separately from the SQL but then there wasn’t an example that showed how to get the variable into the SQL when it was declared as a VARCHAR. The example I am working off of was pretty old but it’s the best I could find.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:11:03+00:00Added an answer on June 8, 2026 at 4:11 pm

    A Teradata MACRO would be a better solution for what you have described.

    REPLACE MACRO [MyDB].GetResultSet(p1 VARCHAR(30)) AS (
    SELECT "Partition"
      FROM DBC.SessionInfo
     WHERE UserName = :p1;
    );
    
    EXEC MyDB.GetResultSet
    

    While a stored procedure could be used to accomplish the task cursor based logic used in other popular database systems (Oracle, SQL Server, etc.) can lead to bad programming habits in Teradata. Generally, processing large cursors in Teradata degrades performance. Many things that you have have used cursor for in other DBMS’ are better served to be done with SET based logic where possible.

    That being said cursors can be used successfully in Teradata to perform certain tasks that require conditional logic or dynamic SQL processing. I hope this helps and if you have a more concrete example you need help with I’d be happy to offer some suggestions.

    Edit:
    This DDL for your procedure works against Teradata 13.10:

    CREATE PROCEDURE "SCHEMA"."GETRESULTSET" (
        IN "p1" VARCHAR(30))
    DYNAMIC RESULT SETS 1
    BEGIN       
    DECLARE cur1 CURSOR WITH RETURN ONLY TO CLIENT FOR 
     SELECT "Partition" FROM "SCHEMA".SessionInfo where username = p1;    
      OPEN cur1;    
    END;
    

    The cursor name has to proceed the CURSOR key word. PartitionInfo is not a valid column on DBC.SessionInfo. Not sure if “Schema” gets replaced by MyBatis or not, so you may have to tweak the SELECT statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The current trend in web applications seems to be towards using GET requests for
In every benchmark that I found on the web it seems that Ruby is
I working on a ASP.NET web project where Ajaxpro.2 is referenced, and it seems
I am working on a Sinatra web app that needs to save any email
Since the format of the response of a web service request seems to be
We seems to be abstracting a lot of logic way from web pages and
I am using SQL Server 2008 Web Edition and it seems my SQL queries
I've seen a few web searches and responses to this but it seems they
In my web.config file there are below entries. It seems like it is used
I have what seems like a simple problem. I have a Spring web app,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.