Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL: Oracle - Parameters in query

Tags:

sql

oracle

I am trying to use the vs2008 query builder to create a query with a parameter. I know that in sql server it would work with:

select col1,col2
from tbl
where col3=@myParam

How would it be typed in oracle or is it pl/sql? I get the problem in the @myParam part.

like image 714
Alon Amir Avatar asked Jan 18 '10 14:01

Alon Amir


People also ask

How do you write a parameter in SQL query?

Parameters are defined at the beginning of a query using a declare statement. Declare statements start with the keyword DECLARE , followed by the name of the parameter (starting with a question mark) followed by the type of the parameter and an optional default value.

What are SQL query parameters?

SQL queries with parameters, also known as SQL templates, are a flexible and efficient solution for repetitive data reporting requirements, for instance allowing users to easily execute complex join statements with multiple sets of values.

What is the use of double ampersand && in SQL queries?

Use the double-ampersand (&&) if you want to reuse the variable value vvithout prompting the user each time. 14 rows selected. You can use the double-ampersand (&&) substitution variable if you want to reuse the variable value without prompting the user each time. The user vill see the prompt for the value only once.

What is V parameter Oracle?

V$PARAMETER displays information about the initialization parameters that are currently in effect for the session. A new session inherits parameter values from the instance-wide values displayed by the V$SYSTEM_PARAMETER view. Column. Datatype.


1 Answers

Oracle SQL parameters are specified using :

SELECT col1, col2 FROM tbl WHERE col3=:myParam

You will have to be careful when specifying this as an OracleParameter though, as some libraries miss off the :, and some require it to bind correctly.

like image 138
thecoop Avatar answered Sep 23 '22 08:09

thecoop