Hi Martijnvs,
I tried the new updated procedure with log data into the table but it is not inserting the values in the table.I tried commenting the /*select syb_quit()*/ if that would be the reason but it still doesn't work.Need to do any change??
create procedure sp__checkipaddress
as
begin
--declare variable
declare @ip varchar(12)
if exists(select * from user_info where username=suser_name())
print 'user exists'
else
print 'doesnot exists'
--lookup ipaddress of current process
select @ip = ipaddr from master..sysprocesses where spid=@@spid
select @ip= substring(@ip,1,char_length(@ip)-charindex(".",reverse(@ip)))
--check if ipaddress is in the approved-list
if not exists (select 1 from approved_clients where ipaddress = @ip)
begin
--if not:
--log data into table
insert into client_logging(loginname, source_ip, eventtime)
values (suser_name() , @ip, getdate() )
--and terminate connection
/*select syb_quit()*/
end
return 0
end
go
1> select * from client_logging
2> go
loginname source_ip eventtime
------------------------- --------------- --------------------------
(0 rows affected)
Thanks,
Meda