Professional Web Applications Themes

did I break something - Microsoft SQL / MS SQL Server

Hi shank, Can you post the code of your trigger and script to create your tables and populate them with sample data? "shank" <rr.com> wrote in message news:phx.gbl... ...

  1. #1

    Default Re: did I break something

    Hi shank,

    Can you post the code of your trigger and script to create your tables and
    populate them with sample data?


    "shank" <rr.com> wrote in message
    news:phx.gbl... 


    Jacco Guest

  2. #2

    Default Re: did I break something

    The table is a static table. Not sure what code I can produce for that. This
    is the trigger code. I made a similar trigger on the Orders table and it
    works fine. This one also worked until I did my little query thingy. Upon
    reflection, I was doing some kind of circular population. When I queried to
    brings records from ArchiveOrderDetails and populate OrderDetails, the
    trigger was also trying to archive the records back into
    ArchiveOrderDetails. I don't know if that would would "break" something....

    CREATE TRIGGER tr_ArchiveOrderDetails ON OrderDetails
    FOR INSERT
    AS
    DECLARE OrderID varchar(12)
    SET OrderID = (SELECT OrderID FROM OrderDetails WHERE ID =
    IDENT_CURRENT('Orders'))
    BEGIN
    INSERT INTO OrderDetailsArchived
    (OrderID, OrderNo, Description, Qty, PriceEach,
    PriceLine)
    SELECT OrderID, OrderNo, Description, Qty, PriceEach, PriceLine
    FROM OrderDetails
    WHERE (OrderID = OrderID)
    END




    "Jacco Schalkwijk" <co.uk> wrote in message
    news:phx.gbl... [/ref]
    from [/ref]
    any 
    >
    >[/ref]


    shank Guest

  3. #3

    Default Re: did I break something

    I just posted the trigger code in another response.
    Something just came to mind though. OrderDetails may be get populated with
    many records in one transaction. That's the products table. Although the
    whole transaction will have the same OrderID, the ID field will be changing
    for each record. WHERE IDENT_CURRENT = ID
    Is that the problem? If so, how could I get around it?
    thanks!

    "Jacco Schalkwijk" <co.uk> wrote in message
    news:phx.gbl... [/ref]
    from [/ref]
    any 
    >
    >[/ref]


    shank Guest

  4. #4

    Default Re: did I break something

    Pls refer to the following link

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm
    _8_des_08_0lo3.asp

    HTH,
    Srinivas Sampangi


    "shank" <rr.com> wrote in message
    news:phx.gbl... [/ref]
    > I'm guessing that this means "insert all the records from the last
    > transaction"
    > Is that correct?
    > thanks again!
    >
    > "sampangi" <com> wrote in message
    > news:phx.gbl... [/ref]
    this [/ref]
    > with [/ref][/ref]
    the 
    > > changing [/ref][/ref]
    tables [/ref]
    > would [/ref]
    > some [/ref]
    > re-populated [/ref]
    > archive [/ref][/ref]
    break 
    > >
    > >[/ref]
    >
    >[/ref]


    sampangi Guest

  5. #5

    Default Re: did I break something

    The inserted pseudo-table contains a copy of the rows inserted by the
    current insert statement. Check out 'inserted and deleted tables' in
    the SQL Server Books Online <createdb.chm::/cm_8_des_08_0lo3.htm>.

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP

    -----------------------
    SQL FAQ links (courtesy Neil Pike):

    http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
    http://www.sqlserverfaq.com
    http://www.mssqlserver.com/faq
    -----------------------

    "shank" <rr.com> wrote in message
    news:phx.gbl... 
    term [/ref]
    > I'm guessing that this means "insert all the records from the last
    > transaction"
    > Is that correct?
    > thanks again!
    >
    > "sampangi" <com> wrote in message
    > news:phx.gbl... [/ref]
    insertions.Try this [/ref]
    PriceEach, [/ref][/ref]
    populated [/ref][/ref]
    Although the 
    > > changing [/ref][/ref]
    tables [/ref][/ref]
    it [/ref][/ref]
    deleted [/ref]
    > re-populated [/ref]
    > archive [/ref][/ref]
    break 
    > >
    > >[/ref]
    >
    >[/ref]


    Dan Guest

Similar Threads

  1. Paragraph break and column break the same?
    By android@adobeforums.com in forum Adobe Indesign Macintosh
    Replies: 4
    Last Post: December 21st, 11:59 PM
  2. OT -- OT (take a break)
    By Murray in forum Macromedia Dreamweaver
    Replies: 42
    Last Post: August 8th, 09:23 AM
  3. Page break
    By Jon Kraft in forum PHP Development
    Replies: 1
    Last Post: July 31st, 10:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139