Gersi Veshi
Gersi Veshi

Reputation: 1

Set plsql parameters partially

I need to create a query that when i enter partially the value of a parameter until"/" is shown it displays all the row sequences with that parameter in the first part before "/"

I enter as a parameter: pwd

The result of query should be: pwd/1 pwd/2 pwd/3....

Upvotes: 0

Views: 72

Answers (1)

MT0
MT0

Reputation: 167981

If you have a bind variable :parameter then:

SELECT *
FROM   table_name
WHERE  value LIKE :parameter || '/%'

So for some test data:

CREATE TABLE table_name ( id, value ) AS
  SELECT 1, 'pwd/1'     FROM DUAL UNION ALL
  SELECT 2, 'pwd/2'     FROM DUAL UNION ALL
  SELECT 3, 'pwdtest/1' FROM DUAL;

If :parameter is pwd then the output is:

ID | VALUE
-: | :----
 1 | pwd/1
 2 | pwd/2

db<>fiddle here

Upvotes: 2

Related Questions