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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:52:51+00:00 2026-05-16T14:52:51+00:00

I have a temp table with 13,000 rows. Most of the rows have a

  • 0

I have a temp table with 13,000 rows. Most of the rows have a numeric price (100) but some are quoted in 32nds, i.e. 100-30 = 100 + 30/32 = 100.9375. (Some even have fractions of a 32th)

I am opening a cursor FOR UPDATE and iterating over the temp table. It takes so long to execute, I am not even sure it is working (my DBA says the exec plan looks ‘strange’)

Can anyone suggest why this is so ridiculously slow?

Better still, could anyone suggest a better alternative? I have control over how the temp table is created, but I don’t fancy trying to compact the logic for 100-30 to 100.9375 into a single update statement.

I’d like to write a function to do this, but as far as I can tell, I have to install Java to enable UDFs?!

Lastly, any idea why Sybase is such an awful, primitive database even at version 12?

My stored proc:

DECLARE cur CURSOR FOR SELECT ticket_no, price_st, price, cur FROM #t FOR UPDATE OF price
DECLARE
    @ticket_no INT,
    @price_st VARCHAR(20), 
    @price FLOAT, 
    @int FLOAT, 
    @32s FLOAT, 
    @frac VARCHAR(6), 
    @num FLOAT, 
    @denom FLOAT

    OPEN cur
    FETCH cur INTO @ticket_no, @price_st

    WHILE (@@SQLSTATUS != 2)
    BEGIN

        IF isnumeric(@price_st) = 1 
            BEGIN
                SELECT @price = convert(FLOAT, @price_st)
            END
        ELSE
            BEGIN
                -- Convert a price like '99-22 3/4' to 
                --   99 + (22/32) + (3/4 * 1/32)
                SELECT @int = convert(FLOAT, substring(@price_st, 1, charindex('-', @price_st)-1))
                SELECT @32s = convert(FLOAT, substring(@price_st, charindex('-', @price_st)+1, 2))
                SELECT @frac = substring(@price_st, charindex(' ', @price_st)+1, 10)
                SELECT @num = convert(FLOAT, substring(@frac, 1, charindex('/', @frac)-1))
                SELECT @denom = convert(FLOAT, substring(@frac, charindex('/', @frac)+1, 3))
                SELECT @price = @int + (@32s / 32) + (@num / (@denom * 32))

            END


        UPDATE #t SET price = @price WHERE CURRENT OF cur

        FETCH cur INTO @ticket_no, @price_st

    END

    CLOSE cur
    DEALLOCATE cur
  • 1 1 Answer
  • 1 View
  • 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-16T14:52:51+00:00Added an answer on May 16, 2026 at 2:52 pm

    Ah! I had a column in the table, with the same name as the cursor:

    DECLARE cur CURSOR FOR SELECT ticket_no, price_st, price, cur FROM #t FOR UPDATE OF price
             ^                                                 ^
    

    This seems to put the Sybase server into a tailspin…

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

Sidebar

Related Questions

I have 1 million rows in MySql table temp and wish to multiply column
I have a temp table in which have one column with four rows. Table
Ok I have a temporary MySQL table with 135,000 rows, from this temporary table
I have the following rows: CREATE TABLE #TEMP (id int, name varchar(255), startdate datetime,
I have temp table #xml that have 2 columns: CREATE TABLE #xml ( id
I have a simple temp-table defined in SQL Server 2008 R2 representing a parent-child
I have several values in a temp table called #tempIQ and I want to
I have written a DB2 query to do the following: Create a temp table
I have a temp table variable with a bunch of columns: Declare @GearTemp table
I' m using sqlite on iphone. I have table with 200 000 records. It'

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.