Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 24th, 2003, 01:39 PM
twifosp twifosp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 twifosp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Variable Syntax Queries

Greetings all. I'm not sure if what I'm trying to accomplish is possible, so bear with me.

I'm trying to make a single statement which variable where statements.

For example:
Declare @variable varchar(20)
set @variable = 'segment'
Declare @syntax_variable varchar(50)
set @syntax_variable = 'where column = '@variable''

Select Column
from DataBase
@syntax_variable = @variable

So the output that the server would get would be:

Select Column
From DataBase
where column = 'segment'


This way I could set my front end web page to be able to set values for what operators I use with if statements.

I already do this with VB using line joins &_ and &vbcrlf. But I'd rather keep the sql out of the source and use a stored procedure.

The above code obviously does not work, but its the only way I can illustrate what I'm trying to accomplish.

Any ideas?

Last edited by twifosp : July 24th, 2003 at 01:41 PM.

Reply With Quote
  #2  
Old July 25th, 2003, 03:29 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
If you are going to hardcode variable values in the stored procedure why not just define the values explicitly or use some sort of logic based on incoming values.

Reply With Quote
  #3  
Old July 26th, 2003, 01:19 PM
twifosp twifosp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 twifosp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The values can't be defined.

For example if I have a where statement based on a column value, then that is fine. I can always have that where statement. But I need the functionality to be able to choose more than one or ALL column values. Making that where statement and or additional ands optional.

I could accomplish this by making my query after several if statements, but when you are potentially doing this with 7 columns, it gets nasty quick.

I figured out a way to do this, using a huge varchar to store my query in, unfortunetly it doesn't seem to want to work in a stored proc and I can't figure out why.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Variable Syntax Queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway