This just doesn''t sit right with me...

  • Some Consultants have developed some stored procedures for us when checking through them I found this in one of them:

     

    Insert Into dbo.table_out

     Select  jc_idno, @NewOrderSysid, getdate()

     From  dbo.table_out

     Where  jc_xxxxonline = @order_sysid

    The fact that it's inserting into itself just puts me off slightly... is it just me or should I go back and demand some rescripting?

  • Can you give us more information, such as where the proc is used, its name (sometimes helpful), the rest of the proc, what the purpose of jc_xxxxonline is, etc?

    I can think of a few situations where this might be valid, even though I might do things differently. For example, I could see someone handling backorders by inserting a new record into a table based on the existing backordered record.

  • I would ask what the purpose of the code actually is. There might be a good reason and there might not. It might also be the way they have always seen and done it so they assume that is the only way to do what you asked for.

  • I think somehow I will be going back to them now since I've found more strange things... some I know that are not right.

  • The best way to find out why they coded something a certain way is to ask them.  What I have found is that, most of the time, there is a good reason why things are coded in a certain way.  Now, that reason could be that the author did not know another (maybe better) way to accomplish a task, or that they found a new intuitive way to accomplish a task.  The best way to know is to ask why the decided to take that approach.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply