473,811 Members | 3,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COLUMN WITH WORD_WRAP IN PL/SQL ????

I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in
PL/SQL!!!!!!

I know this can be done in SQL*Plus as show below but how can I take
this command and have it work in PL/SQL ??? Any ideas, samples ?????

Thanks in advance

George Lewycky
ge*****@nyct.co m
=============== =============== =============== =============== ==
COLUMN remark FORMAT A20 WORD_WRAP
the selected column remark is given a width of 20 characters. The
contents of the field is printed 20 characters to the line with the
break ending after a full word on each line. This will mean some
records actual print on more than one line.
Word-wrap in PL/SQL ???
Can COLUMN with WORD_WRAP from SQL*Plus be used in PL/SQL ??

Also note that in the first command you must enter the expression
exactly as you entered it (or will enter it) in the SELECT command.
Otherwise, SQL*Plus cannot match the COLUMN command to the appropriate
column.
To wrap long values in a column named REMARKS, you can enter
SQL> COLUMN REMARKS FORMAT A20 WRAP
For example:
CUSTOMER DATE QUANTITY REMARKS
---------- --------- -------- --------------------
123 25-AUG-86 144 This order must be s
hipped by air freigh
t to ORD

If you replace WRAP with WORD_WRAP, REMARKS looks like this:
CUSTOMER DATE QUANTITY REMARKS
---------- --------- -------- ---------------------
123 25-AUG-86 144 This order must be
shipped by air freight
to ORD

If you specify TRUNCATE, REMARKS looks like this:
CUSTOMER DATE QUANTITY REMARKS
---------- --------- -------- --------------------
123 25-AUG-86 144 This order must be s
Jul 19 '05 #1
5 15895
VC
Hello,

You can insert a 'new line' character (Windows would require a 'cr', in
addition):

create table t1 as select rpad('test', 210, '*') x from dual;
select substr(x, 1,70)||chr(10)| |substr(x, 71, 70)||chr(10)||s ubstr(x,
141,70) from t1;

Rgds.
"george lewycky" <ge*****@nyct.c om> wrote in message
news:68******** *************** ***@posting.goo gle.com...
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in
PL/SQL!!!!!!

I know this can be done in SQL*Plus as show below but how can I take
this command and have it work in PL/SQL ??? Any ideas, samples ?????

Thanks in advance

George Lewycky
ge*****@nyct.co m
=============== =============== =============== =============== ==
COLUMN remark FORMAT A20 WORD_WRAP
the selected column remark is given a width of 20 characters. The
contents of the field is printed 20 characters to the line with the
break ending after a full word on each line. This will mean some
records actual print on more than one line.
Word-wrap in PL/SQL ???
Can COLUMN with WORD_WRAP from SQL*Plus be used in PL/SQL ??

Also note that in the first command you must enter the expression
exactly as you entered it (or will enter it) in the SELECT command.
Otherwise, SQL*Plus cannot match the COLUMN command to the appropriate
column.
To wrap long values in a column named REMARKS, you can enter
SQL> COLUMN REMARKS FORMAT A20 WRAP
For example:
CUSTOMER DATE QUANTITY REMARKS
---------- --------- -------- --------------------
123 25-AUG-86 144 This order must be s
hipped by air freigh
t to ORD

If you replace WRAP with WORD_WRAP, REMARKS looks like this:
CUSTOMER DATE QUANTITY REMARKS
---------- --------- -------- ---------------------
123 25-AUG-86 144 This order must be
shipped by air freight
to ORD

If you specify TRUNCATE, REMARKS looks like this:
CUSTOMER DATE QUANTITY REMARKS
---------- --------- -------- --------------------
123 25-AUG-86 144 This order must be s

Jul 19 '05 #2
ge*****@nyct.co m (george lewycky) wrote in message news:<68******* *************** ****@posting.go ogle.com>...
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in
PL/SQL!!!!!!


Hello George,

I'm not entirely sure what you mean by wrapping lines in PL/SQL,
I assume you mean dbms_output or utl_file. So here's a procedural
approach that uses dbms_output.

The procedure uses substr to break the input string up into chunks
of the required linesize, then instr to search backwards from the
end for the first space character. It loops until the input string
has been processed.

SQL> create or replace procedure word_wrap (
2 p_str varchar2, p_linesize pls_integer, p_sep varchar2 := ' ')
3 as
4 l_str long := p_str || p_sep;
5 l_line long;
6 l_pos pls_integer;
7 begin
8 while l_str is not null loop
9 l_line := substr(l_str, 1, p_linesize);
10 l_pos := instr(l_line, p_sep, -1);
11 l_line := substr(l_line, 1, l_pos);
12 dbms_output.put _line(l_line);
13 l_str := substr(l_str, l_pos + 1);
14 end loop;
15 end;
16 /

Procedure created.

SQL>
SQL> var s varchar2(1000)
SQL> begin
2 :s := 'I am trying to take a field description for a column';
3 :s := :s || ' of about 200+ bytes and wrap the field into 3';
4 :s := :s || ' lines of 70 bytes apiece in PL/SQL';
5 end;
6 /

PL/SQL procedure successfully completed.

SQL> set serverout on
SQL> exec word_wrap(:s, 70)
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

SQL> exec word_wrap(:s, 50)
I am trying to take a field description for a
column of about 200+ bytes and wrap the field
into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

Hopefully if it's not what you want, there's something in there to
give you some idea.

--
Martin Burbridge
select translate('1o2o 40536b7b8b9c_m' ,'12456789_','p ***@eu.o')
address from dual ---> pobox 002 is full of spam and not read;
Jul 19 '05 #3
Let me re-explain myself.

I have a description field totalling 220 bytes and I need to print
the field from a table into a file using my PL/SQL program.

Currently my print code (below) is chopping the field up from 1st-70th bytes,
and then 71st - 140th byte, but I found in SQL*Plus a built-in (see first post)
text wrap feature and I trying to find an equivalent to use
in PL/SQL !!! Because the splitting will truncate words, etc and
doesnt look too professional.

Hope that makes it clearer

George Lewycky

item_text := substr(lines_re cord.item_descr iption,1,70);
if length(lines_re cord.item_descr iption) > 70 then
item_text2 := substr(lines_re cord.item_descr iption,71,69);
end if;

DBMS_OUTPUT.put _line (' ' || item_text || ' ' || to_char
(lines_record.e xtended_amount, '99,999,999.99' ));

if length(lines_re cord.item_descr iption) > 70 then
DBMS_OUTPUT.put _line (' ' || item_text2);


Hello George,

I'm not entirely sure what you mean by wrapping lines in PL/SQL,
I assume you mean dbms_output or utl_file. So here's a procedural
approach that uses dbms_output.

The procedure uses substr to break the input string up into chunks
of the required linesize, then instr to search backwards from the
end for the first space character. It loops until the input string
has been processed.

SQL> create or replace procedure word_wrap (
2 p_str varchar2, p_linesize pls_integer, p_sep varchar2 := ' ')
3 as
4 l_str long := p_str || p_sep;
5 l_line long;
6 l_pos pls_integer;
7 begin
8 while l_str is not null loop
9 l_line := substr(l_str, 1, p_linesize);
10 l_pos := instr(l_line, p_sep, -1);
11 l_line := substr(l_line, 1, l_pos);
12 dbms_output.put _line(l_line);
13 l_str := substr(l_str, l_pos + 1);
14 end loop;
15 end;
16 /

Procedure created.

SQL>
SQL> var s varchar2(1000)
SQL> begin
2 :s := 'I am trying to take a field description for a column';
3 :s := :s || ' of about 200+ bytes and wrap the field into 3';
4 :s := :s || ' lines of 70 bytes apiece in PL/SQL';
5 end;
6 /

PL/SQL procedure successfully completed.

SQL> set serverout on
SQL> exec word_wrap(:s, 70)
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

SQL> exec word_wrap(:s, 50)
I am trying to take a field description for a
column of about 200+ bytes and wrap the field
into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

Hopefully if it's not what you want, there's something in there to
give you some idea.

Jul 19 '05 #4
ge*****@nyct.co m (george lewycky) wrote in message news:<68******* *************** ****@posting.go ogle.com>...
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in
PL/SQL!!!!!!
Hello George,

I'm not entirely sure what you mean by wrapping lines in PL/SQL,
I assume you mean dbms_output or utl_file. So here's a procedural
approach that uses dbms_output.

The procedure uses substr to break the input string up into chunks
of the required linesize, then instr to search backwards from the
end for the first space character. It loops until the input string
has been processed.

SQLcreate or replace procedure word_wrap (
2 p_str varchar2, p_linesize pls_integer, p_sep varchar2 := ' ')
3 as
4 l_str long := p_str || p_sep;
5 l_line long;
6 l_pos pls_integer;
7 begin
8 while l_str is not null loop
9 l_line := substr(l_str, 1, p_linesize);
10 l_pos := instr(l_line, p_sep, -1);
11 l_line := substr(l_line, 1, l_pos);
12 dbms_output.put _line(l_line);
13 l_str := substr(l_str, l_pos + 1);
14 end loop;
15 end;
16 /

Procedure created.

SQL>
SQLvar s varchar2(1000)
SQLbegin
2 :s := 'I am trying to take a field description for a column';
3 :s := :s || ' of about 200+ bytes and wrap the field into 3';
4 :s := :s || ' lines of 70 bytes apiece in PL/SQL';
5 end;
6 /

PL/SQL procedure successfully completed.

SQLset serverout on
SQLexec word_wrap(:s, 70)
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

SQLexec word_wrap(:s, 50)
I am trying to take a field description for a
column of about 200+ bytes and wrap the field
into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

Hopefully if it's not what you want, there's something in there to
give you some idea.

--
Martin Burbridge
select translate('1o2o 40536b7b8b9c_m' ,'12456789_','p ***@eu.o')
address from dual ---pobox 002 is full of spam and not read;
Jun 27 '08 #5
Let me re-explain myself.

I have a description field totalling 220 bytes and I need to print
the field from a table into a file using my PL/SQL program.

Currently my print code (below) is chopping the field up from 1st-70th bytes,
and then 71st - 140th byte, but I found in SQL*Plus a built-in (see first post)
text wrap feature and I trying to find an equivalent to use
in PL/SQL !!! Because the splitting will truncate words, etc and
doesnt look too professional.

Hope that makes it clearer

George Lewycky

item_text := substr(lines_re cord.item_descr iption,1,70);
if length(lines_re cord.item_descr iption) 70 then
item_text2 := substr(lines_re cord.item_descr iption,71,69);
end if;

DBMS_OUTPUT.put _line (' ' || item_text || ' ' || to_char
(lines_record.e xtended_amount, '99,999,999.99' ));

if length(lines_re cord.item_descr iption) 70 then
DBMS_OUTPUT.put _line (' ' || item_text2);

>
Hello George,

I'm not entirely sure what you mean by wrapping lines in PL/SQL,
I assume you mean dbms_output or utl_file. So here's a procedural
approach that uses dbms_output.

The procedure uses substr to break the input string up into chunks
of the required linesize, then instr to search backwards from the
end for the first space character. It loops until the input string
has been processed.

SQLcreate or replace procedure word_wrap (
2 p_str varchar2, p_linesize pls_integer, p_sep varchar2 := ' ')
3 as
4 l_str long := p_str || p_sep;
5 l_line long;
6 l_pos pls_integer;
7 begin
8 while l_str is not null loop
9 l_line := substr(l_str, 1, p_linesize);
10 l_pos := instr(l_line, p_sep, -1);
11 l_line := substr(l_line, 1, l_pos);
12 dbms_output.put _line(l_line);
13 l_str := substr(l_str, l_pos + 1);
14 end loop;
15 end;
16 /

Procedure created.

SQL>
SQLvar s varchar2(1000)
SQLbegin
2 :s := 'I am trying to take a field description for a column';
3 :s := :s || ' of about 200+ bytes and wrap the field into 3';
4 :s := :s || ' lines of 70 bytes apiece in PL/SQL';
5 end;
6 /

PL/SQL procedure successfully completed.

SQLset serverout on
SQLexec word_wrap(:s, 70)
I am trying to take a field description for a column of about 200+
bytes and wrap the field into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

SQLexec word_wrap(:s, 50)
I am trying to take a field description for a
column of about 200+ bytes and wrap the field
into 3 lines of 70 bytes apiece in PL/SQL

PL/SQL procedure successfully completed.

Hopefully if it's not what you want, there's something in there to
give you some idea.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5301
by: nimdez | last post by:
Hi, I am working on an existing code base in which a lot of data displayed to the user is formatted in tables. Most tables are printed row-by-row using printf() with "%s" print conversion specification for each column (e.g. printf(%10s %25s %15s\n", pszCol1, pszCol2, pszCol3)). My problem is that when a string is longer the column's width, it overflows the column and takes the table out of alignment. What I want it to do is word-wrap...
4
4966
by: perspolis | last post by:
I have 3 columns in my datatabel name Total,unit,Price. I use a column expression in my project..and in this expression i multiplied two column... for example MyTable.Columns.Expression="Price*Unit"; but when i want to update my datatable an exception arise and says can not update computed column...:( how can i do this???
6
3250
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order entry application. The code below gets line items from a SQL Server database and returns them to a datagrid by way of a DataTable called lineTable. As long as I am just displaying columns in the SQL database everything works well. I now want...
19
25476
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to sort columns based on the column header the user has clicked in both Ascending and Descending formats.
6
10684
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the data on the datasource. It simply gets the first name and last name of an instructor and displays it in the grid. I have two major problems.... One, it doesn't display in the column until the row is saved, (Even after calling a refresh on the...
2
3953
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems there's no support for this. Either that or I'm doing something wrong. Well, enough venting, here's what I need. Using this sample XML file (test.xml):
3
3553
by: TPhelps | last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable datagrid that works. I want to change one of the columns to a hyperlink. The examples I find use a bound column. I can get this to work; however, the column header on the datagrid is not a link/sortable. What am I missing? Thanks in advance.
4
10704
by: Steph. | last post by:
I have a List view displaying data in Detail mode with several columns. How I can get the column index the user clicked on ? (when user click on an item inside the ListView, not on a column hearder..) Thanks for any help !
4
4917
by: Peter Gibbs | last post by:
I need some help with this problem. I'm using Access 2002 with XP. My problem is with a 2-column listbox. My VBA code puts text data into the listbox. The problem is that the text data ocasionally includes commas (,) and full-stops (.) - and when the data is placed in a column, Access confuses the punctuation within the text with delimiters and splits the text across columns.
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10397
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10413
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10138
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7674
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4353
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.