Reputation: 13
I made this account just for this question because I'm really not sure how to word it properly for google to pick up on it. So here goes...
I was working on a query for a group project that I was assigned in my database II course. I made 2 and was working on a third when I wanted to see if I could do something like the following.
declare
Emp_ID := 03;
Salary_Increment := 2.0 --constants do not change
Salary_ID := 03;
Current_Salary := 47500
Updated_Salary := Current_Salary * 2.0
BEGIN
dbms_output.put_line('The Employee with the ID of' +Emp_ID 'will receive a 2% bonus.');
dbms_output.put_line('This Employees new salary will be: ' +Updated_Salary ');
end;
I attempted to do this previously but with a more simple code snippet. Figured I would see if I could do this just to simplify how much I have to type out.
TL;DR - Can I use a reference like +Emp_ID in a Oracle SQL dbms output?
Upvotes: 1
Views: 50
Reputation: 35900
In oracle, There are two ways of concating the string.
||
operator.Like this.
dbms_output.put_line('The Employee with the ID of' || Emp_ID || ' will receive a 2% bonus.');
CONCAT
method.Like this:
dbms_output.put_line(CONCAT(CONCAT('The Employee with the ID of', Emp_ID), ' will receive a 2% bonus.'));
Note that CONCAT
uses only two parameter as input. So you need to use it multiple times to concat more than 2 strings.
Cheers!!
Upvotes: 1
Reputation: 50017
The string concatenation operator is ||
in PL/SQL, so you'd want to write
dbms_output.put_line('The Employee with the ID of' || Emp_ID || ' will receive a 2% bonus.');
Upvotes: 0