Extract data into a single line
Hi good morning all,Here's my problem: my goal is to have a single flat txt file with a single line!
That being said can someone tell me how to retrieve my oracle table data in a txt file, with the news that my table has a single colum (varchar 250); and I have 200 rows in this table;
the output should be only a single line without end!
Thank you for your great support;
I try with all possible overall; (set pagesize 0 tab settled out of SPACE SET SET NEWPAGE 0 0 trimspool set set verify off set set recsep [off set echo off... off position) but no way to work!
user647922 wrote:
Thank you all for the reply! Dear BLUSHADOW! I try but I get an error that I can't understand:
SQL > declare
cursor cur_e is
Select to_char (MASTRECORD_EDU, 'fm9999') as ln
of operant.fic_bdf;
v_fh UTL_FILE. TYPE_DE_FICHIER;
Start
v_fh: = UTL_FILE. FOPEN ('W_DIR', 'testout.txt', 'w');
for e in cur_e
loop
UTL_FILE. PUT(v_fh,e.LN);
end loop;
UTL_FILE. FCLOSE (v_fh);
end;
/
declare 2 3 4 5 6 7 8 9 10 11 12 13 14
*
ERROR? line 1:
ORA-01722: invalid number
ORA-06512:? line 8Help, please!
This means that one of your MASTRECORD_EDU values is not a valid number. Question by data, not code Office.
Tags: Database
Similar Questions
-
The simple aggregate data of a certain number of lines into a single line on 10g xe
Hi all, is it solution for 10g xe how to aggregate the data of a certain number of rows in a single line.
Basic data:
DEPTNO ENAME
---------- ----------
20 SMITH
ALLEN 30
WARD 30
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
SCOTT 20
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
need to update table B with this release
DEPTNO EMPLOYEES
---------- --------------------------------------------------
10 CLARK, KING, MILLER
20 SMITH, FORD, ADAMS, SCOTT, JONES
30-ALLEN, BLAKE, MARTIN TURNER, JAMES, WARD
concerning
GordanHello
The deliimter (the 2nd argument) in SYS_CONNECT_BY_PATH should never appear in the elements be concatenated (the 1st argument). Use a different delimiter; It can be more than 1 character, if you wish.
For example:SELECT deptno , LTRIM ( SYS_CONNECT_BY_PATH (ename, '`') , '`' ) AS employees FROM ( SELECT deptno , ename , ROW_NUMBER () OVER ( PARTITION BY deptno ORDER BY ename ) AS curr FROM emp ) WHERE CONNECT_BY_ISLEAF = 1 START WITH curr = 1 CONNECT BY curr = PRIOR curr + 1 AND deptno = PRIOR deptno ;
Furthermore, the code you posted was the way to Oracle 9 use SYS_CONNECT_BY_PATH. In Oracle 10, it is simpler and more effective to use CONNECT_BY_ISLEAF, as shown above.
If you really want to use a delimiter that appears in the data, then you can use some other characters in SYS_CONNECT_BY_PATH and then use REPLACE on the results, like this:
SELECT deptno , REPLACE ( LTRIM ( SYS_CONNECT_BY_PATH (ename, '`') , '`' ) , '`' , ',' ) AS employees FROM ...
Of course, if you do this, you will not be able to tell if "CLARK, KING, MILLER" is 1, 2 (e.g., 'CLARK' and 'KING, MILLER') or 3 elements.
-
Data in multiple lines concatenated into a single line to separate id
Hello
I have a t1 like this table:
create table t1
(number of c1,
number of C2,
C3 number (4.2)
);
Data in the table are such as:
----------------------------------------
C1 | C2 | C3 |
-----------------------------------------
102. 1. 1.1 |
102. 1. 1.2 |
102. 2. 2.1 |
103. 2. 2.1 |
103. 2. 2.2 |
-----------------------------------------
How to display data by using a query above?
------------------------------------------------------
C1 | C2 | C3 |
-------------------------------------------------------
102. 1, 2 | 1.1, 1.2, 2.1 |
103. 2. 2.1, 2.2.
------------------------------------------------------
Thank youSo you're after what we call 'Aggregation in the chain.'
Check this link as it highlights several techniques:
Aggregation of string techniques
A Re: Concat ranks of the values in a single column Michael
At Re: multiple lines in a single line in the 'single column Table' followed by reason of Billy on the conduct of a stragg first.
In addition, 11 GR 2 has the LISTAGG function.
-
How to get multiple row data in a single line in SQL
I have a cust_card_dtls table. This table contains the different clients card details. A customer can have a single card or several cards.
SQL > select * from cust_card_dtls;
CUST_ID CARD_NO
--------------- ----------
1 111
2 222
3 333
4 444
5 555
6 666
1 777
1 888
2 999
I wan to query these data by that I can get all of a particular customer card numbers in a single line.
i.e.
1 111 777 888
2 222 999
3 333
4 444
5 555
6 666
Any way to do it? Thanks in advance.Just replace 2 with 4 as
select LTRIM(SYS_CONNECT_BY_PATH(CARD_NO,','),',')||lpad(',',4-NVL(length(regexp_replace(LTRIM(SYS_CONNECT_BY_PATH(CARD_NO,','),',') ,'[^,]')),0),',') card_str ,CUST_ID from ( select CUST_ID ,CARD_NO ,row_number() over (partition by CUST_ID order by CARD_NO)rno ,row_number() over (partition by CUST_ID order by CARD_NO)-1 rnom1 from cust_card_dtls ) where connect_by_isleaf = 1 connect by prior rno = rnom1 and prior CUST_ID = CUST_ID START WITH RNO = 1
-
extract data into recovery without backups Itunes or Icloud mode
Hello!
Is it possible to extract data from a (4 s) IPhone in recovery mode without all Icloud or ITunes backups AND password of my phone?
(Nothing dodgy on this subject... I am one fearing that someone can extract my data... :-()
Lol it is not possible.
-
How to make a vectorized into a single line drawing open way?
How to make a drawing line converted to outlines in a single open path? I can turn into a vector drawing, but making it a closed path. I ask because I want to control the strokes and the thickness of the line that I made myself. BTW, I know the drawing I posted would be in fact a closed path, but it is just one example. I want to control the race of vectored in general lines.
Thanks to you all! The right answer was to use the "line drawing" preset in the 'Trace Image' dialog box. -
SELECT SQL to merge the text of different lines into a single line
Hello
I need to create a Select statement to merge multiple lines in a single text. I have a table with the following data:
I need to create a query on the table to show a result like this:SQL> DESC doc_comments Name Null? Type ----------------------------------------------------- -------- ------------------------------------ DOC NUMBER COMMENTS VARCHAR2(30) SQL> SELECT * FROM doc_comments 2 / DOC COMMENTS ---------- ---------- 1 Note A 1 Note B 2 Note C 2 Note D 2 Note E 3 Note F 6 rows selected.
A possible solution would be to create a function to merge the text of the various lines and then use it in the query, but I'm not allowed to create any function in the database, I can use a simple SELECT statement.DOC COMMENTS ------------ -------------------------- 1 Note A, Note B 2 Note C, Note D, Note E 3 Note F
Any ideas on how I can do?Assuming that comments contain no vertical bar (|) character:
with doc_comments as ( select 1 doc,'Note A' comments from dual union all select 1,'Note B' from dual union all select 2,'Note C' from dual union all select 2,'Note D' from dual union all select 2,'Note E' from dual union all select 3,'Note F' from dual ) select doc, replace(ltrim(sys_connect_by_path(comments,'|'),'|'),'|',', ') comments from ( select doc, comments, row_number() over(partition by doc order by comments) rn from doc_comments ) where connect_by_isleaf = 1 start with rn = 1 connect by doc = prior doc and rn = prior rn + 1 order by doc / DOC COMMENTS ---------- ---------------------------------------- 1 Note A, Note B 2 Note C, Note D, Note E 3 Note F SQL>
And if the comments may contain the vertical bar (|), then replace the hose in the code above with a character that is not used in the comments.
SY.
-
Several lines into a single line
Hi all
I have a table with the following data
ID collar col_position
1 to 1
1 b 2
1 c 3
1 D 4
I need a sql, select Show out put like this
ID col1 col2 col3 col4
1A b c and d
I use the 10g database. All help is very much appreciated.
-Cordially.
SELECT id, max (col1) col1, col2 max (col2), max (col3) col3 col4 max (col4)
go (select id, col1 decode(col_position,'1',col),
Decode(col_position,'2',col) col2,
Decode(col_position,'3',col) col3,
Decode(col_position,'4',col) col4
x)
Group by id
/
Thank you
Alexander simonnet
-
Insert data into the database lines selected in a gridview
Good night.
I have a little doubt who would like to see clarified.
I want / need to select several rows in a gridview and then insert the selected value of the line in the database.
What should I do to take only the values and send them to the database to help, for example, a stored procedure?
Thank you.Hello
Assuming that already find you a way to determine the selected line in the gridview, the next steps are as simple as,
1 loop through the selected lines in gridview
2. generate the sql insert statement and OracleCommand based on line
3. open OracleConnection
4. call the ExecuteNonQuery methodSee you soon,.
[Nur Hidayat | http://nur-hidayat.net/] -
Problem to extract data from a single column
Hello
I have a requirement where I have to get three records (intf. INTERFACE_DEF_ID, b2b. B2B_TPA_DEF_ID, osb. OSB_INF_DEF_ID) for the select statement for a particular column (val_id)
The following query is in error.
Help, please...
Select
(intf. INTERFACE_DEF_ID or b2b. B2B_TPA_DEF_ID or osb. OSB_INF_DEF_ID) as val_id
Of
ABC. INTERFACE_DEF intf,
ABC. B2B_TPA_DEF b2b,
ABC. OSB_INF_DEF OSB;
Thank you.
Although the errors because it's just syntactically incorrect in all directions. Essentially, the SELECT statement is not yet valid.
Create view abc_v_6 AS
Select INTERFACE_DEF_ID val_id OF ABC. Union INTERFACE_DEF all the
Select B2B_TPA_DEF_ID FROM ABC. B2B_TPA_DEF Union all the
Select OSB_INF_DEF_ID FROM ABC. OSB_INF_DEF;
-
How to merge data from the table with a single line
Hello
I have three tables subscription_type, the address and the person. Here are the details of the table
Person Subscription_type Address
Person_Id AdressType_id Address_id
Person_name Description Address_type_id
Person_id
Address details
There are three types of different address - home, postal and previous.
Each person can have these three different addresses.
I want to create a view that displays all addresses of three of each person in the table of the person in a single line.
Any help please
In your example, there are 2 rows of columns street1, TOWN, SUBURB etc for a single person. To convert this into a single line, with the new columns we could simply use CASES or DECODE in the select as the SQL below. To understand why consolidation function THAT MAX is used - remove the MAX and GROUP BY in SQL keyword and try.
Select full_name
, max (case when description = "Home" then end street1) Home_Street
, max (case when description = "Home" then end suburb) home_suburb
, max (case when description = end of the "Home" then City) home_city
, max (case when description = "Home" then postal code end) home_postcode
, max (case when description = "Home" then end state_name) home_state
, max (case when description = 'Postal' then end street1) Postal_Street
, max (case when description = 'Postal' and then end of suburb) Postal_suburb
, max (case when description = 'Postal' then the city) Postal_city
, max (case when description = 'Postal' and then end of CP) Postal_postcode
, max (case when description = 'Postal' then state_name end) Postal_state
, max (case when description = "Back" then end street1) Prev_Street
, max (case when description = "Back" then end suburb) Prev_suburb
, max (case when description = "Back" then city end) Prev_city
, max (case when description = "Back" then postal code end) Prev_postcode
address a
S State
No p
Subscription_type att
where a.person_id = p.person_id
and a.state_id = s.state_id
and a.address_type_id = att.address_type_id
Full_name group
-
Need help to extract the data into a string of separate brackets
Hello
I have a scenario where I have to extract data into a string that is enclosed in [].
Here's what I want to do...
entry:
[name_first] [name_mi] [name_last]
required output: this must return all data that are placed between square brackets.
name_first
name_mi
name_last
I tried the "REGEXP_SUBSTR' but my version of the database is 9i, and it is available only from 10 g.
Thanks in advance.Hello
You can use SUBSTR and INSTR
This should work in Oracle 9:WITH cntr AS ( SELECT LEVEL AS n FROM dual CONNECT BY LEVEL <= 3 ) , got_pos AS ( SELECT x.txt , c.n , INSTR (x.txt, '[', 1, c.n) AS l_pos , INSTR (x.txt, ']', 1, c.n) AS r_pos FROM table_x x CROSS JOIN cntr c ) SELECT txt , n , SUBSTR ( txt , l_pos + 1 , r_pos - (l_pos + 1) ) AS sub_txt FROM got_pos ORDER BY txt , n ;
Sorry, I don't have an Oracle 9 database now; I had to test this in Oracle 10.
jimmy437 wrote:
... I tried the "REGEXP_SUBSTR' but my version of the database is 9i, and it is available only from 10 g.It's true. Regular expressions are very useful, but they are not available in Oracle 9 (or earlier).
Oracle 9 has a package supplied by Oracle, OWA_PATTERN, which provides regular expression features:
http://docs.Oracle.com/CD/B12037_01/AppDev.101/b10802/w_patt.htm
I know it's the Oracle 10, documentation, but there are in Oracle 9, too.Oracle 9 is very old. You should consider the upgrade.
-
16 lines of data, truncated to 1 line of data?
Alright my program generates a data of 16 lines, as shown below, and here is the block diagram.
what I need, is to generate a data with 1 single line drawn below.
I think the problem is due to the analog digital conversion but I think that it is the more significant method. It would be great if I can truncate to 1 line because it's essentially the same thing.
I have also attached my VI if it would be more help. Thanks in advance, this wall that I'm running into is annoying me.
lol sorry I thought about it again later.
EXTREMELY simple
you need to just create a constant on the 'resolution' from analog to digital and set it on however, many bits (in my case 1)
Thank you!
-
Join the various documents on a single line
Hello
How to unite into a single line a result with more than one record?
That is to say:
Back to this:cod_prod tax tax_name value 1 1 tax1 5 1 2 tax2 10 1 3 tax3 8 2 1 tax1 3 2 2 tax2 6 3 1 tax1 6 4 1 tax1 7 4 2 tax2 12 4 3 tax3 6 4 4 tax4 9
-Oracle Database 11 g Release 11.2.0.1.0 - 64 bit Productioncod_prod tax tax_name value cod_prod tax tax_name value cod_prod tax tax_name value cod_prod tax tax_name value 1 1 tax1 5 1 2 tax2 10 1 3 tax3 8 2 1 tax1 3 2 2 tax2 6 3 1 tax1 6 4 1 tax1 7 4 2 tax2 12 4 3 tax3 6 4 4 tax4 9
-OEL 2.6.32 - 100.0.19.el5Use 'pivot' which is available in oracle 11g
-
concatenate the strings from a column into a single row?
How to concatenate strings from a column into a single line?
Color
------
Red
Orange
Blue
Green
And return a set of results as follows:
Colors
-------------------------
Red, orange, blue, greenVarious ways can be found here:
http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php
Maybe you are looking for
-
Hi all Now you're going to laugh at this, but I have a laptop Toshiba Tecra 720 TRC very crisp, running windows 98 OS. to business accounts etc, but I pay for an ISP connection for it. I recently installed a wireless network around my house and a fri
-
Qosmio F50 - after update BIOS Bluetooth does not work anymore
I need to update BIOS and F50 v 2.20. After update Bluetooth stopped working. Bluetooth in the taskbar icon turned red and I couldn't use any bluetooth device. I got my comp. 3 times to factory State, nothing has changed. After that I uninstalled the
-
Need driver for reader DVD SD-C2302
Hello! I m trying to get the driver for my DVD player a SD-C2302 and I can´t find in the web page Toshiba´s. could is it someone, please, tell me where I can find it? Thank you.
-
Service existing AppleScript Automator to cut and paste the same image in a conversation of Messages
New to Applescript/Automator- I want to be able to have a simple shot that will allow me to paste a particular image in a conversation in Messages... It is the same image that I want every time. But I want to avoid having to go to Messages, search fo
-
HP compaq presario cq5300uk: update of hp compaq presario cq53
Hello I'm looking to upgrade my desktop pc. What I expect: -Amd phenom iix4 965 black edition R7 - Msi I thnik he need to 500watts Maby - a new PSU, my only account 230watts Please can you tell me if I can adapt these elements as well as any recommen