Mowgli
Mowgli

Reputation: 3512

What does 'colon' mean in SQL under WHERE clause?

I have SQL function, it is not written by me.

I am having hard time understanding, what does following condition mean?
specifically :key and ||cLF||'.

WHERE  ' WHERE 1=1 '
       ||cLF||' AND   f.key = :key '
       ||cLF||' AND   i.flag = 0'
       ||cLF||' AND   r.flag = 0'

Upvotes: 3

Views: 7922

Answers (2)

vinodhrajagopal
vinodhrajagopal

Reputation: 153

The query you have pasted is a part of a dynamically constructed SQL statement. Semicolon here points to a bind-place holder, meaning that the actual value for ":key" is passed through an argument and not hard coded.

Read examples on EXECUTE IMMEDIATE.

Upvotes: 1

Mike Christensen
Mike Christensen

Reputation: 91618

First, the || operator is a string concatenation operator. So it looks like the code is building a WHERE clause using conditions specified by cLF. Though I'm not entirely sure why they're tacking on cLF three times there.

The :key syntax refers to a parameter in a parameterized query. Its value will be passed in when the SQL statement you're building is actually run.

Upvotes: 3

Related Questions