Home » SQL & PL/SQL » SQL & PL/SQL » dbms_output.put_line
dbms_output.put_line [message #224024] Mon, 12 March 2007 12:34 Go to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Hi all.

I would like to seek help on how to display my output in a specific position

dbms_output.put_line(code);

I would like to displace the output of the (code) in
character 8 & 9.

Thank you very much.
Re: dbms_output.put_line [message #224038 is a reply to message #224024] Mon, 12 March 2007 13:30 Go to previous messageGo to next message
orausern
Messages: 817
Registered: December 2005
Senior Member
make this change:

dbms_output.put_line(' '||code);


where the ' ' is equal to 7 blank spaces. simple, does it work?
Re: dbms_output.put_line [message #224040 is a reply to message #224024] Mon, 12 March 2007 13:31 Go to previous messageGo to next message
orausern
Messages: 817
Registered: December 2005
Senior Member
make this change:

dbms_output.put_line(' '||code);


where the ' ' is equal to 7 blank spaces. simple, does it work?
Re: dbms_output.put_line [message #224047 is a reply to message #224040] Mon, 12 March 2007 13:47 Go to previous messageGo to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Thanks much for your reply. But because from the character 1-7 I have an output called c_ty.

Here the example of my output


Norton78 (It should be Norton 78)
Salem79 ( Salem 79)
galax80 ( Galax 80)

Could you please tell me how to do and thank you very much for helping me.
Re: dbms_output.put_line [message #224053 is a reply to message #224047] Mon, 12 March 2007 15:00 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Can you not adapt the already given answer?
dbms_output.put_line(c_ty||' '||whatever);
Re: dbms_output.put_line [message #224054 is a reply to message #224024] Mon, 12 March 2007 15:10 Go to previous messageGo to next message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
dbms_output.put_line(c_ty||' '||substr(code,7,2));
Re: dbms_output.put_line [message #224070 is a reply to message #224047] Mon, 12 March 2007 18:16 Go to previous messageGo to next message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
lamnguyen14 wrote on Mon, 12 March 2007 18:47
Here the example of my output

I suspect that isn't quite how you posted it. You can use [code] tags to post preformatted text.
Re: dbms_output.put_line [message #224179 is a reply to message #224070] Tue, 13 March 2007 06:29 Go to previous messageGo to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Hi.

Thanks much. I'd tried

dbms_output.put_line(c_ty||' '||substr(code,7,2));

But It did not work. The output of the code did not display.
Re: dbms_output.put_line [message #224207 is a reply to message #224024] Tue, 13 March 2007 07:06 Go to previous messageGo to next message
ddkdhar
Messages: 68
Registered: February 2007
Member

TAKE NORTON78
IF YOU WANT IT AS NORTAN{SPACE)78
IF YES
TRY THIS
DBMS_OUTPU.PUT_LINE( SUBSTR('TEXT',1,6)||' '||SUBSTR('TEXT',7))

[Updated on: Tue, 13 March 2007 07:21]

Report message to a moderator

Re: dbms_output.put_line [message #224213 is a reply to message #224207] Tue, 13 March 2007 07:12 Go to previous messageGo to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Please, let me know more about NORTON78. I don't know anything about NORTON78. I'm a very newbie in Oracle. Thanks much.

However, I tried as you told me, and get the error message like this:

SQL> DBMS_OUTPU.PUT_LINE( SUBSTR('TEXT',1,6)||SUBSTR('TEXT',7));
SP2-0734: unknown command beginning "DBMS_OUTPU..." - rest of line ignored.
Re: dbms_output.put_line [message #224214 is a reply to message #224213] Tue, 13 March 2007 07:15 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This conversation takes too much time and effort without any success. You are painting a picture without canvas and colours.

Would it cost you too much if you copy-pasted actual output of your sample code? Something like this:
SQL> l
  1  begin
  2    dbms_output.put_line('first part ' || substr('123456789', 7, 2));
  3* end;
SQL> /
first part 78

PL/SQL procedure successfully completed.

SQL>

So you see: Bill's suggestion, actually, displays 7th and 8th characters of the 'code' string. If you didn't get anything, perhaps your 'code' string is shorter than 7 characters?

It is hard to detect what is wrong because you hide information (and I can't figure the reason).

P.S. "Norton78" is just an example string; as far as I can tell, it isn't the name of any Oracle product.
Re: dbms_output.put_line [message #224216 is a reply to message #224024] Tue, 13 March 2007 07:16 Go to previous messageGo to next message
ddkdhar
Messages: 68
Registered: February 2007
Member

ARE YOU USING PLSQL..

[Updated on: Tue, 13 March 2007 07:16]

Report message to a moderator

Re: dbms_output.put_line [message #224227 is a reply to message #224213] Tue, 13 March 2007 07:55 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
lamnguyen14 wrote on Tue, 13 March 2007 08:12
Please, let me know more about NORTON78. I don't know anything about NORTON78. I'm a very newbie in Oracle. Thanks much.



Duh! That's the string YOU provided us.
Re: dbms_output.put_line [message #224229 is a reply to message #224216] Tue, 13 March 2007 07:56 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
ddkdhar wrote on Tue, 13 March 2007 13:16
ARE YOU USING PLSQL..

DBMS_OUTPUT works in PL/SQL, not SQL.
Re: dbms_output.put_line [message #224235 is a reply to message #224214] Tue, 13 March 2007 08:16 Go to previous messageGo to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Hi all

I'm not hiding my information but I just don't know how to explain myself. I'm so sorry for that.

Here is my table:
P CITY   P C
- ------ - -
N Norton 7 8
S Salem  7 9
E Galax  8 0
W Brito  8 1


**********************
Here is my code:

declare
  cursor c1 is select * from cities;
  my_city		varchar2(7);
  my_code		varchar2(2);
begin
  for v_rec in c1 loop
  my_city := v_rec.pre||v_rec.city;
  my_code := v_rec.precode||v_rec.code;

  dbms_output.put_line(my_city||my_code);
  end loop;
end;


*********************
Here is my output:
SQL> @ c:/dbms.sql
NNorton78
SSalem79
EGalax80
WBrito81

PL/SQL procedure successfully completed.


*******
However, I want all my_code is display in the position 8 & 9

NNorton78 (It's ok)
SSalem79  (It should be SSalem 79)
EGalax80  (It should be EGalax 80)
WBrito81  (It should be WBrito 81)


Please help. Thanks much.


[Mod-Edit: added code tags]

[Updated on: Tue, 13 March 2007 08:19] by Moderator

Report message to a moderator

Re: dbms_output.put_line [message #224236 is a reply to message #224235] Tue, 13 March 2007 08:19 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
use rpad on the city field
And use code tags next time please. It makes things far more readable.

[Updated on: Tue, 13 March 2007 08:19]

Report message to a moderator

Re: dbms_output.put_line [message #224237 is a reply to message #224024] Tue, 13 March 2007 08:20 Go to previous messageGo to next message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
It's starting to make sense

declare
cursor c1 is select * from cities;
begin
for v_rec in c1 loop
  dbms_output.put_line(rpad(v_rec.pre||v_rec.city,7,' ')||v_rec.precode||v_rec.code);
end loop;
end;

[Updated on: Tue, 13 March 2007 08:20]

Report message to a moderator

Re: dbms_output.put_line [message #224242 is a reply to message #224236] Tue, 13 March 2007 08:29 Go to previous messageGo to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
Hi

Thanks much for your responses. And what is code tags. How to use it? Please show me
Re: dbms_output.put_line [message #224243 is a reply to message #224024] Tue, 13 March 2007 08:31 Go to previous messageGo to next message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
see the following link

http://www.htmldog.com/reference/htmltags/code/
Re: dbms_output.put_line [message #224247 is a reply to message #224243] Tue, 13 March 2007 09:04 Go to previous messageGo to next message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
I would like to say thank you to all of you for helping my with my output and the info. I'm so new in this field. I don't know anything. I would appreciate that.
Re: dbms_output.put_line [message #224250 is a reply to message #224243] Tue, 13 March 2007 09:16 Go to previous messageGo to next message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
http://www.orafaq.com/forum/?section=readingposting&t=help_index&44553
Re: dbms_output.put_line [message #224258 is a reply to message #224250] Tue, 13 March 2007 10:04 Go to previous message
lamnguyen14
Messages: 119
Registered: March 2007
Location: Virginia
Senior Member
I got it. Thank for all of you.
Previous Topic: ORA-29278: SMTP transient error: 421 Service not available
Next Topic: PL/SQL and Java Servlets
Goto Forum:
  


Current Time: Sat Dec 03 10:01:02 CST 2016

Total time taken to generate the page: 0.11653 seconds