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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Database in PL/SQL, HTML form

Status
Not open for further replies.

dmaranan

Programmer
Aug 14, 2001
46
US
This should be a simple script, but I am having difficulty figuring out how to do it.
Basically I want to query a database column through PL/SQL via the web.

For example, lets say a user wants to find all instances of “computer, keyboard, and mouse” in my database. I want to be able to search through a column and find all instances where those terms exist.

On a form in html users input their search parameters (computer keyboard mouse).

Those parameters are than passed to a variable (search_param = computer keyboard mouse);

Finally a search is done based on those parameters in SQL:

SELECT *
FROM table_computer
where column_hardware in (search_param);

Unfortunately this doesn’t work. Any ideas?
 

How about using LIKE?

SELECT *
FROM table_computer
where column_hardware LIKE '%'||search_param||'%';




Robbie

"The rule is, not to besiege walled cities if it can possibly be avoided" -- Art of War
 
That statement works for single queries. However, if I want to include two or more search terms, the select statement fails.
 
I think you'll need a procedure with the capability to dissect a comma-delimited list (I think there is a procedure called dbms_utility.comma_to_table that may help here). Build a query with each term in the list as an OR condition in your WHERE clause, then execute the query using dynamic SQL and return the results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top