9

What does := mean in oracle when we use it Please give me some demonstrations... and also how do we usually use a dynamic query in a stored procedure in oracle...

moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
  • 2
    Welcome to SO. It is a Q&A site, not a forum, which places some obligations on *you* as a questioner to post questions in a suitable fashion Please ask two questions as two separate threads. There is no charge for asking questions, and combining unrelated questions in one post just makes it harder to accept answers. – APC Aug 06 '13 at 12:49
  • 1
    Also, you can easily answer these questions yourself by reading the documentation. The PL/SQL doc explains `:=` http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/fundamentals.htm#CIHHFHJG and dynamic SQL: http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/dynamic.htm#CACDDACH – APC Aug 06 '13 at 12:53

1 Answers1

20

:= is the assignment operator in PL/SQL (Oracle's procedural extension to SQL). You use this to assign values to variables. If you just use = then this is checking for equality rather than assigning a value.

Here is a very simple example using the assignment operator to assign values to variables:

Declare
   v1 number;
   v2 number;
   res number;
Begin
   --initialise values
   v1 := 2;
   v2 := 2;
   res := v1 + v2;
   dbms_output.put_line(res);
end;

I think you will need to be a bit more specific about what you want to know about dynamic SQL. As the comment above suggests, it would also be best to raise one thread per question as these are unrelated.

ChrisProsser
  • 12,598
  • 6
  • 35
  • 44