views:

497

answers:

5

What does ":" stand for in a query ?

INSERT INTO MyTable (ID) VALUES (:myId)

How does it fetch the desired value?

Edit: Also what is that sign called? I wanted to search on google, but what's the name for ":"?

Chosen Answer: Chose the answer for the link and the upvotes. But also check Jeffrey Kemp's answer

+2  A: 

It is a named parameter.

In C#, you prefix the parameter with @ (see here).

kgiannakakis
That's not a function of C#. It's ADO.NET, and it can be changed.
John Saunders
+4  A: 

This is a tag for a named query parameter, and is not part of the query's actual syntax. The tag is replaced with some value specified in the code that makes the query before it is actually run.

Will Vousden
+8  A: 

That's called a bind variable in Oracle.

what's the name for ":"?

Colon.

OMG Ponies
A: 

that's also the parameter syntax for a Delphi query

Leslie
+5  A: 

What does ":" stand for in a query?

A bind variable. Bind variables allow a single SQL statement (whether a query or DML) to be re-used many times, which helps security (by disallowing SQL injection attacks) and performance (by reducing the amount of parsing required).

How does it fetch the desired value?

Before a query (or DML) is executed by Oracle, your program will create a cursor. Your program issues the SQL to be parsed for that cursor, then it must bind values for each bind variable referred to by the SQL. How this is done depends on the language.

What is that sign called?

A colon.

Jeffrey Kemp