Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Page numbers

Page numbers

Scheduled Pinned Locked Moved Database
databasecomquestionlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sebastien Lachance
    wrote on last edited by
    #1

    I have no idea where to start. I have a table names Pages. A field PageID, PageNumber, etc.. (those only two matters). I delete some page and need to take the one at the end of the book(?) and bring it to the place where the page where deleted (Change the PageNumber). I need to do this in a stored proc of sql function. I don't know where to start ! X| sebastien.lachance.blogspot.com

    M 1 Reply Last reply
    0
    • S Sebastien Lachance

      I have no idea where to start. I have a table names Pages. A field PageID, PageNumber, etc.. (those only two matters). I delete some page and need to take the one at the end of the book(?) and bring it to the place where the page where deleted (Change the PageNumber). I need to do this in a stored proc of sql function. I don't know where to start ! X| sebastien.lachance.blogspot.com

      M Offline
      M Offline
      Michael Potter
      wrote on last edited by
      #2

      Here is something to get you started. It really needs to be wrapped in a transaction with a 'SERIALIZABLE' isolation level. Brutal if you have a lot of users. DECLARE PROCEDURE DeletePage ( DECLARE @PageID INTEGER ) AS DECLARE @MaxPageNumber INTEGER SELECT @MaxPageNumber = MAX(PageNumber) FROM Pages DECLARE @PageNumber INTEGER SELECT @PageNumber = PageNumber FROM Pages WHERE PageID = @PageID IF @PageNumber IS NULL BEGIN -- Deal with Bad PageId RAISERROR('Bad PageID',16,1) RETURN 1 END DELETE FROM Pages WHERE PageID = @PageID IF @MaxPageNumber <> @PageNumber BEGIN UPDATE Pages SET PageNumber = @PageNumber WHERE PageNumber = @MaxPageNumber END RETURN 0

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups