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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:12:38+00:00 2026-06-15T22:12:38+00:00

I was doing update of big table in Sybase and had following code (declarations

  • 0

I was doing update of big table in Sybase and had following code (declarations skipped):

-- get minimum id 
set rowcount 1 
select @min_id = id from table1 where id matches_some_condition

set rowcount 10000 -- batch size

select @max_id = id from 
(select id from table1 where id >= @min_id and some_condition) a order by id

-- do updates
while (1 = 1)
 begin
   update table1
   set a = some_value
   where id >= @min_id and id <= @max_id and further_conditions

   waitfor delay '00:00:01'

   select @min_id = @max_id
   select @max_id = id from 
    (select id from table1 where id >= @min_id and further_conditions
    ) a order by id

   if @min_id >= @max_id
      break

 end

So it’s usual idea as you can see: take some ordered column (id) and update rows where id is between N and M. Loop until all rows are updated.

As you might see, in order to get @max_id I used set rowcount 10000 and then select @max_id = id from (select id from table1 where id >= @min_id and further_conditions) a. Now I need to do such update on database which is running Sybase ASE 12.0. The problem is that derived tables are only supported from 12.5, so select id from (select id from table1) a is not working. Any ideas how to fix it, perhaps algorithm can be changed? Of course, I can do needed updates with the help of cursor, but I was wondering if there was some better way.

  • 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-15T22:12:40+00:00Added an answer on June 15, 2026 at 10:12 pm

    Try to change code:

     select @max_id = id from 
        (select id from table1 where id >= @min_id and further_conditions
        ) a order by id
    

    to:

     select @max_id = max(id) from 
     from table1 
     where id >= @min_id and further_conditions
    

    or

     select @max_id =  id 
     from table1 
     where id >= @min_id 
     and further_conditions
     order by id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing an ajax get request works as expected using the following code: $.ajax({ type:
This is what i am doing update t1 set x=a,y=b where a and b
I am doing a very simple update on a table, which also triggers a
Update: I updated this after doing some digging and realizing that this might be
UPDATE: I also tried implementing UITextViewDelegate delegate and then doing in my controller: -
I have a gridview inside an update panel, that is doing inline editing. When
Doing the getting started of Sinatra. I get this error: ./sinatra.rb:5: undefined method `get'
Doing my first SL4 MVVM RIA based application and i ran into the following
I have a very big table with a lot of rows, every row has
I have to do a big update script - not an SPL (stored procedure).

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.