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 6248035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:59:01+00:00 2026-05-24T12:59:01+00:00

Here I got a scenario: When I press a button in client application (developed

  • 0

Here I got a scenario: When I press a button in client application (developed in Delphi) a stored procedure is activated. The stored procedure first declares a cursor for a select statement which returns two columns-BankID and BankCategoryID.Then I need to fetch each row inside the cursor into a record and check for the BankCategoryID and return a resultset according to the BankCategoryID like:

CASE WHEN fetched_record.BankCategoryID=1  THEN
    SELECT STATEMENT1 WHEN fetched_record.BankCategoryID=2 THEN
    SELECT STATEMENT2 and so on...

and then I return the result set retrieved from any of the above cases to my client application. Is thi possible?

  • 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-05-24T12:59:02+00:00Added an answer on May 24, 2026 at 12:59 pm

    Perhaps you’d want to use an IF as a control statement within your cursor?

    WHILE @@FETCH_STATUS = 0
    BEGIN
        IF @BankCategoryID=1  
        BEGIN
           SELECT Baz From Bat;
           DECLARE @Spam bit; 
           SELECT @Spam = 0;
        END
    
        IF @BankCategoryID=2  
        BEGIN
           SELECT Foo FROM Bar;       
        END
      FETCH NEXT FROM MyCursor INTO @BankID, @BankCategory
    END
    

    Here’s a sample TSQL cursor. You’d be loading your two column values into 2 variables: @BankID and @BankCategoryID. i.e. FETCH NEXT FROM MyCursor INTO @BankID, @BankCategoryID

    Aside: I’m wondering if this could be done all without a cursor? In either case, the above should work for you in implementing more TSQL statements in each iteration of your cursor.

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

Sidebar

Related Questions

Here's the scenario-- you've got a JSON object on the browser, and let's say
Here's my scenario: I've got a table of (let's call them) nodes. Primary key
Here's my scenario: I've got a div on Page A. When an event happens
Here's the scenario: I've got a big file filled with all sorts of eclectic
Here's my scenario. I've got SharePoint 2010 running on one server, with an SQL
So i bet i got you curious with that title. =) Here's the scenario
hey guys, here's a simple scenario NServiceBus Client/Server setup. The Message is a custom
Here's the scenario: I've got a regular hyperlink on my .ascx. (no I have
Here's the scenario: On my iPhone app (OS 3.1.2), I've got view 1 which
Ok, here's my simple scenario. I've got collection of strings that I'm binding to

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.