Trigger and Store Procedure help

  • Hi

    I want to insert values in my table after executing one store procedure because i want to store one parameter value of procedure in my table

    My table has Four fields Customer,InvoiceNo,Date,Invoicecode.

    Store procedure has three parameters Customer,Month,Year.

    I want to run Insert trigger after store procedure execution and want to store customer value in customer field and also want to increment invoiceNo by one which at present i am doing with update. Date field will show value of current date and time and Invoicecode will be always same like 'CI/'

     

    Best Regards

     

     

  • I'm afraid you'll have to be more precise if you want to get some useful information...

    What does the "one stored procedure"? What tables are used? On which table will be the trigger?

    Also, you can nor "run trigger after SP execution" - trigger can start automatically during execution of SP, if that SP is inserting data in the specific table where trigger is defined. You can't start a trigger in any other way than by simply inserting into a table.

    If you want to store a parameter with which SP is running, make the INSERT part of stored procedure - don't use trigger.

    And the main thing... What is the question? You described vaguely what you want to do - but did not mention what is your problem.

  • So Sorry ....i posted my question in hurry...

    So My main question is how to run trigger to insert values in a table. My procedure has 3 parameters customer code ,Year,Month. I want to run my trigger when user execute procedure and whatever the value he use for customer parameter i want to store that value in My Invoice table.

    My Invoice table has four fields Customercode,Date,InvoiceNo,Invoicecode and My table is empty I wanted to insert one line everytime when user will execute store procedure.

    InvoiceNo start from 1600 and i want to increment this also,Date field will store curret date and time means Now() and InvoiceCode will be always like 'CS/'.

    I want to store information that on which date user will execute my store procedure for which customer and want to give them particular id by Invoicenumber.

    Thanks a lot ....do apologies if still it's not clear 

     

  • have "insert into invoices (customercode) values (@customercode)" as part of your stored procedure.

    Set the invoice number to an autoincrementing field and set the default for the date to getdate()

    Depending on where you get the invoice code from it can be inserted from the stored proc or set as a default in the table.

     

     


  • OK, thanks, it is more clear now. It is kind of a logging of how often and with which parameters certain SP runs.

    No trigger, the insert must be part of SP... but I see now that mrpolecat has already answered your question.

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

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