Converting column data into rows in oracle 10g
sample data:
PATID NA2 NA3 NA4
1 3 4 5
1 34 45 56
1 134 245 356
2 134 245 356
2 334 275 56
2 4 275 56
2 4 5 56
how to display the above data like
PATID NA2 NA3 NA4
1 ID1 ID2 ID3 ID4 ID1 ID2 ID3 ID4 ID1 ID2 ID3 ID4
3 34 134 4 45 245 5 56 356
2 134 134 4 4 245 275 275 5 356 56 56 56
Many examples are here:
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
(and you can do a search on this forum as well to find more)
edit
Your sample data is not very clear, by the way.
Please post a CREATE TABLE and some INSERT statements, just enough to put up the testcase.
Use the tag before and after posting examples, so formatting will be maintained.
See the [FAQ|http://forums.oracle.com/forums/help.jspa] for more information regarding tags (scroll a bit down)...
Edited by: hoek on Jan 26, 2010 5:23 PM
Similar Messages
-
Hi,
I need the output from columns to rows in oracle 10g.
this is my original output using some select query,
select a.created_by,b.modified_by from created_tp a,modified_tp b where a.col_id=b.col_id.
created_by modified_by
Siva Raja
but i need this same output by rows like
user--anything fine
Siva
Raja
Thanks
SivaHi,
select case l when 1 then a.created_by
else b.modified end
from created_tp a,modified_tp b, (select level l from dual connect by level <= 2)
where a.col_id=b.col_id. -
Hi All,
Can any one plzz help me out how to convert columns in to rows.
I am having data as follows:
Date1 Date2 Date3 Date4 Date5 Date6
I need the Out put as Below
Date
Date1
Date2
Date3
Date4
Date5
Date6
Thanks in Advance
Regards
Praveenyou can do this by using OTN's search engine:
http://forums.oracle.com/forums/search.jspa?objID=f75&q=converting+columns+into+raws -
How to convert blob data into clob using plsql
hi all,
I have requirement to convert blob column into clob .
version details
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
DECLARE
v_blob temp.blob_column%TYPE;------this is blob data type column contains (CSV file which is inserted from screens)
v_clob CLOB; --i want to copy blob column data into this clob
v_warning NUMBER;
BEGIN
SELECT blob_column
INTO v_blob
FROM temp
WHERE pk = 75000676;
DBMS_LOB.converttoclob (dest_lob => v_clob,
src_blob => v_blob,
amount => DBMS_LOB.lobmaxsize,
dest_offset => 1,
src_offset => 1,
blob_csid => 1, -- what is the use of this parameter
lang_context => 1,
warning => v_warning
DBMS_OUTPUT.put_line (v_warning);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLCODE);
DBMS_OUTPUT.put_line (SQLERRM);
END;I am not getting what is the use of blob_csid , lang_context parameters after going the trough the documentation .
Any help in this regard would be highly appreciated .......
Thanks
Edited by: prakash on Feb 5, 2012 11:41 PMPost the 4 digit Oracle version.
Did you read the Doc for DBMS_LOB.CONVERTTOCLOB? - http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm
The function can convert data from one character set to another. If the source data uses a different character set than the target you need to provide the character set id of the source data.
The blob_csid parameter is where you would provide the value for the source character set.
If the source and target use the same character set then just pass zero. Your code is passing a one.
>
General Notes
You must specify the character set of the source data in the blob_csid parameter. You can pass a zero value for blob_csid. When you do so, the database assumes that the BLOB contains character data in the same character set as the destination CLOB.
>
Same for 'lang_context' - your code is using 1; just use 0. It is an IN OUT
>
lang_context
(IN) Language context, such as shift status, for the current conversion.
(OUT) The language context at the time when the current conversion is done.
This information is returned so you can use it for subsequent conversions without losing or misinterpreting any source data. For the very first conversion, or if do not care, use the default value of zero. -
How to upload data into form of Oracle EBS R12 using ATS ver 9.0
Hi experts,
Could you please guide me how to upload data into form on Oracle EBS R12 using Oracle Application Testing Suite verson 9.(The simpliest way)
For example: I need to create user account on Oracle EBS. Normally, I use Dataloader to upload the data, however it just can upload one by one record, cannot upload multi record at same time. Moreover if the performance of server is low, so I will get the issue when using dataloader.
Thanks in advance
Best Regards
HieuHi you can create Virtual users to enter data. Note than you have to name the objects accordingly.
For Example default recording provided by Open script is ObjectNAME_(Index No of the object).
when you record one iteration the name of any object would be ObjectNAME_(0)
You can then create virtual users so the index will increment as the total number of Virtual users increases. Also you have to handle which row of your test data would get mapped to which Virtual user in the script run session.
Thanks -
How to convert BLOB data into string format.
Hi,
I have problem while converting blob data into string format.
for example,
Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
will get me the first 4000 byte of BLOB .
When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
declare
my_var CLOB;
BEGIN
for x in (Select X from T)
loop
my_var:=dbms_lob.substr(x.X,32767,1)
end loop
return my_var;
I comfortably convert 32k BLOB field to string.
My problem is how to convert blob to varchar having size more than 32K.
Please help me to resolve this,
Thanx in advance for the support,
NileshNilesh,
. . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
-- resulting string:
☺AW(⌂özßHAA
Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
Regards,
Noel -
How to access Data Guard option in Oracle 10g OEM
Hi All,
I have Oracle 10g ENTERPRISE EDITION on Unix envoirement. I want to setup logical standby Database through Data Guard technology. But when I brows through OEM I do not find Link for DATA GUARD????
1) How to access Data Guard option from oracle 10g OEM.
2) Does It come with Enterprise Edition OR I have to install it separately.
Regards,
DarshanI am managing almost everything through EM Grid Control. It is easy to setup and configure.
Anyways, if you have read the documentation on
Oracle® Data Guard Concepts and Administration and setup your environment accordingly then you should not have any problems. Atleast I can assure you that your production database will not be affected by it.
Just make sure that you follow each step and read thoroughly. If you have spare machines then you can test and record your configuration before performing it on your production db. This link will provide you with the information on DataGuard.
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14239/concepts.htm
If you think that way then you will never be able to do any new stuff since you will always fear that something might go wrong. Go ahead pal, try it on test machines and you will know that it is not that difficult.
There are real experts who help people like us in this forum and I know that they are doing a pretty good job.
All the best.
Rgds
Adnan -
How to convert system Date into DD-MMM-YYYY Format
hi friends,
please help me How to convert system Date into DD-MMM-YYYY Format.
Regards
YogeshHI..
data: w_dt(11) type c,
w_month(2),
w_mon(3).
w_month = p_date+4(2). **p_date = given date**
case w_month.
when '01'.
w_mon = 'Jan'.
when '02'.
w_mon = 'Feb'.
when '03'.
w_mon = 'Mar'.
when '04'.
w_mon = 'Apr'.
when '05'.
w_mon = 'May'.
when '06'.
w_mon = 'Jun'.
when '07'.
w_mon = 'Jul'.
when '08'.
w_mon = 'Aug'.
when '09'.
w_mon = 'Sep'.
when '10'.
w_mon = 'Oct'.
when '11'.
w_mon = 'Nov'.
when '12'.
w_mon = 'Dec'.
endcase.
Now...
concatenate p_date6(2) '-' w_mon '-' p_date0(4) into w_dt.
write w_dt. -
Is it possible to convert LabView data into OLE variant?
Hi. I'm using Activex Data Objects (ADO) to communicate with MySQL. Some ActiveX methods give OLE variant output, with "Variant Type" like "VT_ARRAY|VT_UI1", "VT_UI1" or "VT_BSTR". With some deduction and trial and error is relatively simple to extract data from this OLE variants and convert them to LabView data types. The problem is when I try to input variant data to some ActiveX methods, it almost always give me errors, I suppose because it expects the same type of the outputs, this is: OLE variants. Now, the question is: ¿Is there any way to convert LabView data into OLE variant data? ¿How?
I've been searching and found a lot of posts about problems when passing variant data into ActiveX, saying that sometimes SAFEARRAYs are needed, sometimes saying that there were some bugs in LV6, giving some workarounds to this bug and saying that it is fixed in LV7.1, but the supposed workarounds don't work and the bug is still present in LV7.1, if it is really a bug.
I think that if I could put LV data into OLE variant shape I may find an answer and solution to this matter.
Thank you
Daniel R.
UdeC - ChileBelow I describe how to handle OLE Variants, but I wanted to mention that LabVIEW does have a Database Connectivity toolkit (http://sine.ni.com/nips/cds/view/p/lang/en/nid/6429) that has already created a set of VIs for ADO. You might check that out first.
However, handling OLE Variants in LabVIEW is automatic. LabVIEW itself has a variant datatype. When you use the ActiveX property or invoke nodes and one of the parameters is an OLE Variant, it is automatically converted to a LV Variant. You can then use the LV Variant VIs (such as "Variant to Data" and "To Variant").
Brian Tyler
http://detritus.blogs.com/lycangeek -
Convert the date into user default date formate
I am wrinting a bdc and i want to convert the date into user default date farmate ..please suggust the functiom module should i use...
actually by using dats or d type you can get the user specific date itself.
but if u have different dates format that need to be converted to the user specific date then you can follow below procedure
1. retrieve the user format from usr01
SELECT SINGLE datfm
INTO w_datfm
FROM usr01
WHERE bname EQ sy-uname.
pass w_datfm to the below FM (4th import parameter)
2. create Z - FM and retrieve the user secific date
FUNCTION ZFXX_USER_SPECIFIC_DATE.
""Local Interface:
*" IMPORTING
*" VALUE(IW_DAY) TYPE CHAR2
*" VALUE(IW_MONTH) TYPE CHAR2
*" VALUE(IW_YEAR) TYPE CHAR4
*" VALUE(IW_DATFM) TYPE USR01-DATFM
*" EXPORTING
*" VALUE(EW_USER_DATE) TYPE CHAR0008
*1 DD.MM.YYYY
*2 MM/DD/YYYY
*3 MM-DD-YYYY
*4 YYYY.MM.DD
*5 YYYY/MM/DD
*6 YYYY-MM-DD
CASE iw_datfm.
when '1'.
concatenate iw_day iw_month iw_year
into ew_user_date.
when '2'.
concatenate iw_month iw_day iw_year
into ew_user_date.
when '3'.
concatenate iw_month iw_day iw_year
into ew_user_date.
when '4'.
concatenate iw_year iw_month iw_day
into ew_user_date.
when '5'.
concatenate iw_year iw_month iw_day
into ew_user_date.
when '6'.
concatenate iw_year iw_month iw_day
into ew_user_date.
when others.
clear ew_user_date.
endcase.
ENDFUNCTION. -
How we export report data into excel in report 10g
hi can any one tell me
how we export report data into excel in report 10g (except spreadsheet)We can use TEXT_IO Package
-
Splitting comma seperated column data into multiple rows
Hi Gurus,
Please help me for solving below scenario. I have multiple value in single column with comma seperated values and my requirement is load that data into multiple rows.
Below is the example:
Source Data:
Product Size Stock
ABC X,XL,XXL,M,L,S 1,2,3,4,5,6
Target Data:
Product Size Stock
ABC X 1
ABC XL 2
ABC XXL 3
ABC M 4
ABC L 5
ABC S 6
Which transformation we need to use for getting this output?
Thanks in advance !Hello,
Do you need to do this tranformation through OWB mapping only? And can you please tell what type of source you are using? Is it a flat file or a table?
Thanks -
Problem in Converting Database into Archivelog mode (Oracle 10G)
Hi Team,
I come across a strange problem in the ORACLE 10G Server.
I am converting database mode from NoArchivelog to Archivelog mode through RMAN in 10G.
Now When I execute these following commands through RMAN prompt it works properly as shown below?
C:\>rman
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Nov 30 18:01:08 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> connect target /
connected to target database: RAVI (DBID=4025722893, not open)
RMAN> shutdown immediate;
using target database control file instead of recovery catalog
database dismounted
Oracle instance shut down
RMAN> STARTUP MOUNT;
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 167772160 bytes
Fixed Size 1247876 bytes
Variable Size 79693180 bytes
Database Buffers 79691776 bytes
Redo Buffers 7139328 bytes
RMAN> SQL 'ALTER DATABASE ARCHIVELOG';
sql statement: ALTER DATABASE ARCHIVELOG
RMAN> ALTER DATABASE OPEN;
database opened
RMAN>
But this same script when i writes in the backup.ora file & pass to Rman prompt it fails,
File backup.ora contains...
run
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SQL 'ALTER DATABASE ARCHIVELOG';
ALTER DATABASE OPEN;
passed to RMAN as follows...
C:\OracleCode\BACKUP>"C:\oracle\product\10.2.0\db_1\bin\RMAN.EXE" target /"connect target SYSTEM/sreedhar@RAVI" log="C:\ORACLE~2\LOGS\backup_log.log" append cmdfile="C:\ORACLE~2\BACKUP\backup.ora"
RMAN> 2> 3> 4> 5> 6> 7> 8>
then it fails giving the following errors...
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 11/30/2006 18:05:59
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Recovery Manager complete.
The same thing is working in the Oracle 9i but not in the Oracle 10G.
Can Anybody plz help me in this?
Regards,
S.Tiwari
.export ORACLE_SID=<SID>
rman target /cmdfile="C:\ORACLE~2\BACKUP\backup.ora"
it will connect to the default SID, there's no such thing as a default SID, what do you mean?
But what if there are more that one SID available & I
want to connect to SID other than the default SID.just specify the desired SID prior starting rman.
more over the same string is working with 9i but not
with 10G.maybe due to a bug?
to summarize, you have two options it you would like to start up the instance:
either you specify the SID prior starting rman and use os authentication
or
you register the instance statically and use oracle authentication.
regards,
-ap -
How to develope application for converting excel data into oracle database
I am very new to the oracle world. I want to develop application for converting excel sheet into oracle database using oracle forms. I have basic knowldge of oracle but i am totally new to the forms. Can anybody tel me step by step procedure to do this task? Please help me out in this problem.
Thanx in advance.Hello,
just do a "Search" in this forum with words "excell to oracle"... and you could find lot of posts about that, i.e.:
Re: How to load excel-csv file into oracle database
Jose L -
Converting columns to single row
Hi,
I have scenario like this
bw_we account user_defined1 user_defined2 user_defined3
'abc' 1234 5678 6789 0987
abc 2424 64635 8977 789534
def 44382 4924929 9449 242424
def 42488 88488 888324 8888i need to get result set as
gl_account
1234
5678
6789
0987
2424
64635
8977
789534
.all the values in each row should be converted into one column..is there any oracle function do this?In 10g you'll have to do something like the following to UNPIVOT the results:
SQL> WITH test_data AS
2 (
3 SELECT 'abc' AS BW_WE, 1234 AS ACCOUNT, 5678 AS USER_DEFINED1, 6789 AS USER_DEFINED2, 0987 AS USER_DEFINED3 FROM DUAL UNION ALL
4 SELECT 'abc' AS BW_WE, 2424 AS ACCOUNT, 64635 AS USER_DEFINED1, 8977 AS USER_DEFINED2, 789534 AS USER_DEFINED3 FROM DUAL UNION ALL
5 SELECT 'def' AS BW_WE, 44382 AS ACCOUNT, 4924929 AS USER_DEFINED1, 9449 AS USER_DEFINED2, 242424 AS USER_DEFINED3 FROM DUAL UNION ALL
6 SELECT 'def' AS BW_WE, 42488 AS ACCOUNT, 88488 AS USER_DEFINED1, 888324 AS USER_DEFINED2, 888 AS USER_DEFINED3 FROM DUAL
7 )
8 -- END SAMPLE DATA
9 SELECT DECODE
10 (
11 RN
12 , 1, ACCOUNT
13 , 2, USER_DEFINED1
14 , 3, USER_DEFINED2
15 , 4, USER_DEFINED3
16 ) AS COLLAPSED_COL
17 FROM TEST_DATA
18 CROSS JOIN (SELECT ROWNUM RN FROM DUAL CONNECT BY LEVEL <= 4)
19 /
COLLAPSED_COL
1234
2424
44382
42488
5678
64635
4924929
88488
6789
8977
9449
888324
987
789534
242424
888
16 rows selected.
Maybe you are looking for
-
Loading data one page at a time
I have 200 records to load in a java server page. I felt loading all these records will affect performance. So I wanted to load 15 records on each pass. However, on the second pass I obtained a nullpointerException(ResultSet -JDBC). Any suggestion on
-
Can I install Windows 7 System Builder Addition on a MacBook Pro?
Can I install Windows 7 System Builder Addition on a MacBook Pro?
-
Username creation using PAPI-WS code
Hi all, I am testing the code in the online example for PAPI-WS i.e. BPM-PapiWs-JaxWs-Example.... I have my process running and PAPI Web Services started.. I have my username and password as test , test... I am getting errors in username password aut
-
Ask for a sql sentence(procedure) for copy data to themselves' table
two tables order and orderitem,there are relationship table; order's id is PK orderitem's id is PK,and parentId is FK. and all id are created by sequences:order_id_seq and orderitem_id_seq. order id name 1 aaa 2 bbb orderitem id parentId num 1 1 100
-
Hi, can you show me an example of "perform on commit" with variables.