0

Here is my one of my tries without sucess:

var myVar VARCHAR;
exec :myVar:= 'm';
select * from users where lower(name) like lower(':myVar%')

myVar is the variable i want to inject in the string

Hope to have explained my question well. Thanks in advance.

1
  • you cant write a variable in quotes first clear this out. Commented Feb 23, 2019 at 18:09

2 Answers 2

2

Don't put the variable inside the quotes:

select * from users where lower(name) like lower(:myVar) || '%'
Sign up to request clarification or add additional context in comments.

Comments

0

A few things.

var myVar VARCHAR2(2); --varchar2, not varchar
exec :myVar:= 's%'; -- put the wildcard here, it's just easier

select * from employees where lower(first_name) like lower(:myVar)

run everything via F5

enter image description here

1 Comment

This is perhaps very correct because it reduces the seperate concatenation and takes in the input initiallization itself

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.