Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
spookweb
Starting Member
2 Posts |
Posted - 2004-06-15 : 12:26:35
|
| Greetings...I am just getting started with T-SQL and I am trying to figure out how to do a few things.1. is there anyway to import variables from an external source, say the PHP script or JAVA applet performing the database insertion, into the table that the T-SQL trigger is associated to?from what I have read, i am gathering that this is not possible, but please could someone confirm this? which brings me to my next question, which would be a workaround for my case:2. is there a way to easily retrieve the values of the last insert ? (this would be the insert that fires the trigger)TIA!Chris |
|
|
spookweb
Starting Member
2 Posts |
Posted - 2004-06-15 : 12:31:11
|
| oops i think i worded the first question wrong...1. is there anyway to import variables from an external source, say the PHP script or JAVA applet performing the database insertion (and activating the trigger)? |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-06-16 : 06:55:28
|
| 1. no idea...2. select * from table where tableid = @@identityGo with the flow & have fun! Else fight the flow :) |
 |
|
|
JasonGoff
Posting Yak Master
158 Posts |
Posted - 2004-06-16 : 09:46:46
|
| 1. also no idea..., although investigate using stored procedures, and passing parameters to the stored proc to do the insertion. You could then pass the parameter from your calling code into the stored proc, which could then do whatever you wanted to do with it in the query.2. Spirit1's answer will get you the last record inserted into the table (you can also use ident_current('table')). If you want to examine the data from within the trigger code, look at the inserted table. This contains all rows about to be inserted (or just inserted) into the table. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-06-16 : 13:05:06
|
| I've looked at making data available from the application to the trigger, and decided it was too hard! What sort of stuff are you wanting to communciate between the two?(for example, one of the things we wanted was the User ID making the most recent change [we have a column in the table to store that] and we found a system variable "user_name()" that does the same thing, so we used that)Kristen |
 |
|
|
|
|
|
|
|