2

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'
Mowgli
  • 3,422
  • 21
  • 64
  • 88

2 Answers2

3

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.

Community
  • 1
  • 1
Mike Christensen
  • 88,082
  • 50
  • 208
  • 326
  • `CLF` is set as Constant `CONSTANT varchar2(1) := chr(10);` – Mowgli Sep 17 '12 at 16:37
  • mike thanks for explaining and helpful link, so in that link, can you please explain what `'Mr '` selects? – Mowgli Sep 17 '12 at 16:42
  • also in my case `CLF` is it changing the type? – Mowgli Sep 17 '12 at 16:42
  • Not sure what you mean about *what 'Mr ' selects*. Can you elaborate? `cLF` is just adding linefeeds to your statement, they really have no purpose except for readability. Perhaps the statement is being logged somewhere. – Mike Christensen Sep 17 '12 at 16:47
1

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.