Q

Selecting records with variable value

I want to select all records that contains a variable value from a table. Is there a way to get it to understand what it is looking for is a variable value and not a literal value?

I want to select all records that contains a variable value from a table. Can I do it like this:
X  :=  '1234';

Select studentID from personnel where studentID like X;

Is there a way to get it to understand what it is looking for is a variable value and not a literal value? I have

tried:

studentID like '%X%'

studentID like '%{X}%'

studentID like "'%"X"%'"

Any ideas welcome.

Try this:
    x := '1234';
     xplus :='%'||x||'%';

    where studentid like xplus;
This was first published in July 2006

Dig deeper on Using Oracle PL-SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close