Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL output formatting question/problem...please help
PL/SQL output formatting question/problem...please help [message #4363] Mon, 02 December 2002 19:25 Go to next message
billy
Messages: 9
Registered: March 2002
Junior Member
I have a pl/sql output problem. I need to output this line, but cannot get it right.

Kim Cox's phone number is (715) 555-1234

Here is my script. I cannot get the 's behind Cox and the ( ) around 715.

SQL> DECLARE
2 faculty_last_name varchar2(20) := 'Cox';
3 faculty_first_name varchar2(20) := 'Kim';
4 faculty_phone varchar2(20) := '7155551234';
5 BEGIN
6 DBMS_OUTPUT.PUT_LINE(faculty_first_name ||' '|| faculty_last_name ||
7 's' || ' ' || 'phone number is' || ' ' || faculty_phone);
8 END;
9 Input truncated to 1 characters
/
Kim Coxs phone number is 7155551234

PL/SQL procedure successfully completed.
Re: PL/SQL output formatting question/problem...please help [message #4365 is a reply to message #4363] Mon, 02 December 2002 21:32 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9094
Registered: November 2002
Location: California, USA
Senior Member
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2    faculty_last_name  VARCHAR2 (20) := 'Cox';
  3    faculty_first_name VARCHAR2 (20) := 'Kim';
  4    faculty_phone      VARCHAR2 (20) := '7155551234';
  5  BEGIN
  6    DBMS_OUTPUT.PUT_LINE
  7      (faculty_first_name
  8       || ' '
  9       || faculty_last_name
 10       || '''s phone number is ('
 11       || SUBSTR (faculty_phone, 1, 3)
 12       || ') '
 13       || SUBSTR (faculty_phone, 4, 3)
 14       || '-'
 15       || SUBSTR (faculty_phone, 7));
 16  END;
 17  /
Kim Cox's phone number is (715) 555-1234

PL/SQL procedure successfully completed.
Re: PL/SQL output formatting question/problem...please help [message #4433 is a reply to message #4363] Sun, 08 December 2002 20:29 Go to previous message
Sanket Naik
Messages: 4
Registered: December 2002
Junior Member
Used ''''|| 's' instead of 's'
Previous Topic: missing SELECT keyword error
Next Topic: full outer join
Goto Forum:
  


Current Time: Thu May 16 05:59:17 CDT 2024