|
on user input in multiple fields or selecting from different tables based on some varying criteria ... and even this can be done with static SQL!This is the only way to do some things like filtering a result set
based
Declare MyCursor Cursor For
Select ...
From ...
Where Column1 = Case when :HostInput1 <> 0 then :HostInput1 Else
Column1 End
And Column2 = Case When :HostInput <> '' then :HostInput2 Else
Column2 End
And Column3 > '2000-01-01' Then :HostInput3 else Column3 End
....
Order By Case When :Sort = 1 Then Column1 End, Case When :Sort = 1 Then
Column4 End
Case When :Sort = 2 Then Column2 End,
Case When :Sort = 3 Then Column3 End, Case When :Sort = 3 Then Column1
.....
The only situation where you really need dynamic SQL is when the table/file/schema to be accessed is not known at compile time.
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.