Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building command based on response to ACCEPT statement

Status
Not open for further replies.

mjcole

Mechanical
Jan 8, 2003
1,063
Hello,

I'm relatively new to SQL and was wondering if its possible to do the following.

I have written a small .sql script that creates a select statement from a series of ACCEPT parameter prompts.

As I have it now I have prompts that get input for columns to select, table to select from & where clause

select &col from &table where &where
&col columns to select
&table table to select from
&where where clause

I was wondering if it's possible to add an order by clause to the select command that would only be part of the command if the user entered a string for ordering the data and would leave out the order by statement if no string was entered at the order by prompt

If the following data was entered
orderby: col1 DESC
then the select statement would be as follows
select &col from &table where &where orderby &orderby

If nothing was entered at ordrerby: prompt
then the select statement would not include order by &orderby.

Any help would be appreciated.

Thank you,
Michael

bu_plate.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor