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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 trigger on select (or any other way)

Author  Topic 

Wodzu
Yak Posting Veteran

58 Posts

Posted - 2009-04-07 : 07:57:09
Hi folks.

My problem is:

There is a PROGRAM (which can not be modified) which performs selection on TABLE in DATABASE ( TABLE and DATABASE can be modified).

Selection is like this:
SELECT * FROM dbo.Clients WHERE Client_ID = SomeID


Now, I need to prevent (or at least give some warning message) to a user if selected Client doesn't meet some specific requirements: f.e. he did not pay for the last invoice.
PROGRAM doesn't check this requirements and allows to select any client so I am looking a workaround.

Is there anything I can do from the SQL Server side?

Thanks for your time.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-07 : 08:08:03
Yes.
Change the underlying table name and write a view named as the old table name.
In the view, incorporate the mechanisms for checking payments.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-07 : 08:23:43
Oh...
quote:
Originally posted by Wodzu

TABLE and DATABASE can be modified

Create a view which has your billing check logic in it and have the view deliver same columns as table does.
If no payment can be found, return zero records.

Change application to have the view as source table.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Wodzu
Yak Posting Veteran

58 Posts

Posted - 2009-04-08 : 06:35:54
Thanks Peso but table can't be replaced by view cause application makes also insertions to this table.
By "change" I mean, that it can have additioal columns or constraints...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-08 : 06:59:17
You can do INSERT to views.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -