Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

parameter wild card

Status
Not open for further replies.

sonny1974

Technical User
Feb 25, 2007
161
US
i want to do a parameter in my sql

where ord_table.project like {?Project}%

i but its not working, so bascially if the person enters the first 5 digits of the project number , it doesnt matter what appears after the 5 numbers on project number
 
Sonny, I presume that you wish to prompt for your "parameter" from a SQL*Plus prompt, right? Here is some code that will do that. (You must save this code to a script to run it properly...you cannot just run this as a copy and paste, due to the "ACCEPT...PROMPT" code.) I'll name the script "sonny.sql".

Section 1 -- Contents of "ord_table":
Code:
select * from ord_table;

  PROJECT NAME
--------- -----
123456789 abc
 23456789 def
123450003 ghi
Section 2 -- Contents of "sonny.sql":
Code:
set verify off
accept proj prompt "Enter the first 5 digits of the projects to show: "
select * from ord_table
where ord_table.project like '&proj%'
/
Section 3 -- Invocation and Results of "sonny.sql":
Code:
SQL>  @sonny
Enter the first 5 digits of the projects to show: 12345

   PROJECT NAME
---------- --------------------
 123456789 abc
 123450003 ghi
Let us know if this answers your question.



[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top