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.com
================================================== ============
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 5 15842
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)||substr(x,
141,70) from t1;
Rgds.
"george lewycky" <ge*****@nyct.com> wrote in message
news:68**************************@posting.google.c om... 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.com ================================================== ============ 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 ge*****@nyct.com (george lewycky) wrote in message news:<68**************************@posting.google. 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('1o2o40536b7b8b9c_m','12456789_','p***@e u.o')
address from dual ---> pobox 002 is full of spam and not read;
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_record.item_description,1,70);
if length(lines_record.item_description) > 70 then
item_text2 := substr(lines_record.item_description,71,69);
end if;
DBMS_OUTPUT.put_line (' ' || item_text || ' ' || to_char
(lines_record.extended_amount,'99,999,999.99'));
if length(lines_record.item_description) > 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. ge*****@nyct.com (george lewycky) wrote in message news:<68**************************@posting.google. 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('1o2o40536b7b8b9c_m','12456789_','p***@e u.o')
address from dual ---pobox 002 is full of spam and not read;
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_record.item_description,1,70);
if length(lines_record.item_description) 70 then
item_text2 := substr(lines_record.item_description,71,69);
end if;
DBMS_OUTPUT.put_line (' ' || item_text || ' ' || to_char
(lines_record.extended_amount,'99,999,999.99'));
if length(lines_record.item_description) 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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
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...
| |