May 29, 2004 at 2:31 pm
Hi all,
We have a table called WASI.
WASI table has a Trigger called “updateWASI”.
Could you please let me know how to call the “updateWASI” trigger from Java?
Here is the “updateWASI” Trigger:
CREATE TRIGGER [dbo].[updateWASI] ON dbo.WASI FOR INSERT, UPDATE AS
declare @@theage real
declare @@subj_num int, @@WASI_DATE datetime
declare tmpupdatecurWASI cursor for select subj_num, WASI_DATE from inserted
open tmpupdatecurWASI
fetch next from tmpupdatecurWASI into @@subj_num, @@WASI_DATE
WHILE (@@fetch_status <> -1)
begin
IF (@@fetch_status <> -2)
begin
exec adm_getage @@subj_num, @@WASI_DATE, @@theage output
if not update(userkey)
update WASI set userkey = convert(char(19),getdate(),100)+rtrim(user), WASI_AGE = @@theage where subj_num = @@subj_num and WASI_DATE = @@WASI_DATE
else
update WASI set WASI_AGE = @@theage where subj_num = @@subj_num and WASI_DATE = @@WASI_DATE
end
fetch next from tmpupdatecurWASI into @@subj_num, @@WASI_DATE
End
deallocate tmpupdatecurWASI
Thanks in advance.
Abrahim
May 29, 2004 at 11:15 pm
Triggers are ONLY fried as a result of an SQL DML, i.e. insert, delete or update. In your case it will be fired by an update on the table.
You can not fire or interact with triggers in any other way.
If you need to call the code in the trigger listed above for some reason, then create a stored procedure that contains the same code and taking into account the fact that INSERTED table is only available in triggers,and the statement( if not update(fieldname) are available only in triggers), so , you have to read the update rows from another source. Then call the trigger from any other program code like Java using a JDBC/ODBC/OLEDB connection..
May 30, 2004 at 11:03 am
Salim,
It makes sence.
Thank you very much.
Abrahim
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply