Building command based on response to ACCEPT statement
Building command based on response to ACCEPT statement
(OP)
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
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
0




