Splitting a column data into 4 different columns
HI ALl,
I have a column that bring the data friom the database like this :
1.1.01 10.1 M10-08: This is the best deal ever
I want to split that up into 4 columns ( prefrebely in RPD) . 1 column will be 1.1.01, 2nd column as just M or Q ( Depending upon the data) . 3rd Column as M10-08. 4th Column as the vervbage ( eg : this is the best deal ever).
How would i do this. ANy help will be appreciated.
thanks
Hi user599926,
The Business Model and Mapping Layer (logical layer) in the RPD is the right place for this kind of change. Here's what you do
1) Import your physical table into the RPD
2) Drag and drop that table into a BMM folder
4) Right click on the logical table and select "New Object" -> "Logical Column..."
5) Give the column a name
6) Click on the Data Type tab
7) Double click on the Logical Table Source (LTS) *Make sure "Show all logical sources" is checked
8) Uncheck "Show mapped columns"
9) Check "Show unmapped columns"
10) you should now only see your new column.
11) Click on the three dots "..." next to the name of the column.
12) Use the SUBSTRING() function on your original field. E.g. SUBSTRING(FIELD1 FROM 1 FOR 6)
13) Hit OK
14) Hit OK
15) Repeat steps 4-14 for 2nd ,3rd and 4th column. They will just have a different FROM and FOR number.
Good luck!
-Joe
Similar Messages
-
Split flat file column data into multiple columns using ssis
Hi All, I need one help in SSIS.
I have a source file with column1, I want to split the column1 data into
multiple columns when there is a semicolon(';') and there is no specific
length between each semicolon,let say..
Column1:
John;Sam;Greg;David
And at destination we have 4 columns let say D1,D2,D3,D4
I want to map
John -> D1
Sam->D2
Greg->D3
David->D4
Please I need it ASAP
Thanks in Advance,
RH
sqlImports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports System.IO
Public Class ScriptMain
Inherits UserComponent
Private textReader As StreamReader
Private exportedAddressFile As String
Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
Dim connMgr As IDTSConnectionManager90 = _
Me.Connections.Connection
exportedAddressFile = _
CType(connMgr.AcquireConnection(Nothing), String)
End Sub
Public Overrides Sub PreExecute()
MyBase.PreExecute()
textReader = New StreamReader(exportedAddressFile)
End Sub
Public Overrides Sub CreateNewOutputRows()
Dim nextLine As String
Dim columns As String()
Dim cols As String()
Dim delimiters As Char()
delimiters = ",".ToCharArray
nextLine = textReader.ReadLine
Do While nextLine IsNot Nothing
columns = nextLine.Split(delimiters)
With Output0Buffer
cols = columns(1).Split(";".ToCharArray)
.AddRow()
.ID = Convert.ToInt32(columns(0))
If cols.GetUpperBound(0) >= 0 Then
.Col1 = cols(0)
End If
If cols.GetUpperBound(0) >= 1 Then
.Col2 = cols(1)
End If
If cols.GetUpperBound(0) >= 2 Then
.Col3 = cols(2)
End If
If cols.GetUpperBound(0) >= 3 Then
.Col4 = cols(3)
End If
End With
nextLine = textReader.ReadLine
Loop
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
textReader.Close()
End Sub
End Class
Put this code in ur script component. Before that add 5 columns to the script component output and name them as ID, col1, co2..,col4. ID is of data type int. Create a flat file destination and name it as connection and point it to the flat file as the source.
Im not sure whats the delimiter in ur flat file between the 2 columns. I have use a comma change it accordingly.
This is the output I get:
ID Col1
Col2 Col3
Col4
1 john
Greg David
Sam
2 tom
tony NULL
NULL
3 harry
NULL NULL
NULL -
How to display rows of data into different columns?
I'm new to SQL and currently this is what I'm trying to do:
Display multiple rows of data into different columns within the same row
I have a table like this:
CREATE TABLE TRIPLEG(
T# NUMBER(10) NOT NULL,
LEG# NUMBER(2) NOT NULL,
DEPARTURE VARCHAR(30) NOT NULL,
DESTINATION VARCHAR(30) NOT NULL,
CONSTRAINT TRIPLEG_PKEY PRIMARY KEY (T#, LEG#),
CONSTRAINT TRIPLEG_UNIQUE UNIQUE(T#, DEPARTURE, DESTINATION),
CONSTRAINT TRIPLEG_FKEY1 FOREIGN KEY (T#) REFERENCES TRIP(T#) );
INSERT INTO TRIPLEG VALUES( 1, 1, 'Sydney', 'Melbourne');
INSERT INTO TRIPLEG VALUES( 1, 2, 'Melbourne', 'Adelaide');
The result should be something like this:
> T# | ORIGIN | DESTINATION1 | DESTINATION2
> 1 | SYDNEY | MELBORUNE | ADELAIDE
The query should include the `COUNT(T#) < 3` since I only need to display the records less than 3. How can I achieve the results that I want using relational views???
Thanks!!!T#
LEG#
DEPARTURE
DESTINATION
1
1
Sydney
Melbourne
1
2
Melbourne
Adelaide
1
3
Adelaide
India
1
4
India
Dubai
2
1
India
UAE
2
2
UAE
Germany
2
3
Germany
USA
On 11gr2, you may use this :
SELECT t#,
REGEXP_REPLACE (
LISTAGG (departure || '->' || destination, ' ')
WITHIN GROUP (ORDER BY t#, leg#),
'([^ ]+) \1+',
'\1')
FROM tripleg
where leg#<=3
GROUP BY t#;
Output:
1 Sydney->Melbourne->Adelaide->India
2 India->UAE->Germany->USA
Cheers,
Manik. -
Mapping different same column value into different column based on conditio
Hi experts,
We have source as Oracle tables and target also Oracel tables.
Source
Column1|Column2|Column3
Target
trg1|trg2
I need to
insert the value of Column1 into trg1 where column2='xxx'
insert the value of column1 into trg2 where column3='yyy'
After giving the conditions on the mapping, the where conditions are getting clubed with and and I am getting different value than what is excepted. Like the similar way I have the same scenario for most of the columns in my target table. Suggest me how to do it.
Thanks in advance.Hi,
I tried the mapping but getting duplicate records.
case1: Only AND condtion is getting applied automatically as per the joins between tables..i m not able to change the AND to OR condition since there are three table joins.
case2: when i try to execute the separate query for the column, i getting the values once put in case statement only NULL values are getting fetched.
As all my target mapping are like this...lot of issues are getting raised while fetching records...
I have given my scenario once again below.
src1
col1
src2
col1
col2
col3
col4
src3
col1
tar1
col1
col2
mapping given are
tar1.col1 = select src2.col3 where src2.col1='xxx' and src2.col2='yyy' and src2.col4=src1.col1
tar1.col2 = select src2.col3 where src2.col1='aaa' and src2.col2='bbb' and src2.col4=scr2.col1
Kindly suggest how to do the mapping in details...I am stuck bcoz of this mapping......thanks in advance.
Edited by: siva on Nov 23, 2011 12:34 PM -
Splitting one column into different columns.
Hello Experts,
How do i split datetime column into different columns while doing a Select statement.
Ex:
The column "REC_CRT_TS" has data like "2014-05-08 08:23:09.0000000".The datatype of this column is "DateTime". And i want it in SELECT statement like;
SELECT
YEAR(DATETIME) YEAR,
MONTH(DATETIME) MONTH,
DATENAME(DATETIME) MONTHNAME,
DATEPART(DATETIME) WEEKNUM,
DAY(DATETIME) DATE,
DATEPART(DATETIME) HOUR
FROM TABLE_NAME;
The output should look like this;
--YEAR| MONTH | MONTHNAME| WEEKNUM | DATE | HOUR
--2014| 5 | May | 25 | 08 |08
Any suggestions please.
Thanks!
RahmanI made a very quick research and I see in this blog post
http://www.jamesserra.com/archive/2011/08/microsoft-sql-server-parallel-data-warehouse-pdw-explained/
that It also uses its own query engine and not all features of SQL
Server are supported. So, you might not be able to use all your DBA tricks. And you wouldn’t want to build a solution against SQL Server and then just hope to upsize it to Parallel Data Warehouse Edition.
So, it is quite possible that this function doesn't exist in PDW version of SQL
Server. In this case you may want to implement case based month name or do it in the client application.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Not able to display data in different columns using Unicode encoding
Hi,
Iam using Unicode encoding in my Java appln to support Japanese characters while downloading CSV report. But using the Unicode encoding displays all data in the first column of Excel sheet.
Please let me know how to display data in different columns using Unicode encoding in Excel sheet.Hi Venkat,
After extracting data into DSO check the request whether active or not.
Check data in DSO in contents.
If is there any restrictions on info providers in Queries.
Let us know status clearly.......
Reg
Pra -
Breaking the string into different columns
Hi Guys,
I need to break the following string into different columns
'XXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007.'
I am trying to write it using instr and substr , but having some issues .
Is there any other way to do this. If not can someone help me , below is the query that i am working on
SELECT SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', 1, INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1) - 1) col1,
SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007',
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1) + 1,
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1, 2)
- INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1)
- 1
) col2,
SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007',
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 2) + 1,
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 1)
- INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 2)
- 1
) col3
from dual
It is very urgent.
Thanks in advance.npejavar wrote:
It is very urgent.
It doesn't look urgent, you could simply read the manuals for instr and substr or describe any issues or errors you are having, or post sample data so people could help you more easily, or format your code so it is more readable, but you don't bother to do any of those things so if it isn't important to you to extend any effort, why would it be important to us?
If it was really urgent it would be a violation of the conditions of use of these forums.
http://www.catb.org/esr/faqs/smart-questions.html#urgent
http://www.oracle.com/html/terms.html
>
4. Use of Community Services
Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle -
Changing rows into different column names
Hi,
i need to tranpose the rows into differnent column names
my sample data :
id , val
1 3
1 4
1 5
into
id , val1, val2 , val3 , val4 ... valn ..
1 3 4 5
from askTom's i see that it's tranpose into a single column using the ref cursor ?
how can i do made it into different column names ?
kindly advise
tks & rdgsFor example, lets say that you want to order your columns from least value to greatest and that you'll never have more than three values per id. Then you can use the analytic function row_number() like this to create a pivot value.
select id, val,
row_number() over (partition by id order by val) as rn
from your_table;And so your pivot query ends up looking like this.
select id,
max(case when rn=1 then val end) AS val1,
max(case when rn=2 then val end) AS val2,
max(case when rn=3 then val end) AS val3
from (
select id, val,
row_number() over (partition by id order by val) as rn
from your_table
group by id;But notice that I started out by making up answers to Justin's questions. You'll have to supply the real answers. -
Want to insert a XSL file's data into a column of type SYS.XMLTYPE??
Hello Friends
I want to insert a XSL file's data into a column of a table of type SYS.XMLTYPE. Following is the XSL which i want to add into a table please help in.....
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="clinical_study">
<xsl:variable name="status">
<xsl:apply-templates select='overall_status' />
</xsl:variable>
<html>
<head>
<title>Summary</title>
<link href="merckcancer.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="trialtop" class="trialtop">
<div id="trialtophead" class="trialtophead">
<H1>Summary</H1>
</div>
<!-- start of trial body-->
<div id="trialmiddle" class="trialmiddle">
<span class="trialtitle1"><xsl:apply-templates select='brief_title'/></span>
<span class="tealbold">Official Title: </span><xsl:apply-templates select='official_title' />
<span class="tealbold" title="ClinicalTrials.gov Identifier">NCT Id: </span><xsl:apply-templates select='//nct_id'/>
<span class="tealbold">Conditions: </span><xsl:for-each select="//condition[position()!=last()]"><xsl:value-of select="normalize-space(.)" /><xsl:text>, </xsl:text></xsl:for-each>
<xsl:for-each select="//condition[position()=last()]"><xsl:value-of select="normalize-space(.)" /></xsl:for-each>
<span class="tealbold">Phase: </span><xsl:apply-templates select='phase' />
<span class="tealbold">Status: </span><xsl:value-of select="$status" />
<span class="tealbold">Interventions: </span><xsl:for-each select="//intervention[position()!=last()]"><xsl:value-of select="normalize-space(intervention_type)" />: <xsl:value-of select="normalize-space(intervention_name)" /><xsl:text>, </xsl:text></xsl:for-each><xsl:for-each select="//intervention[position()=last()]"><xsl:value-of select="normalize-space(intervention_type)" />: <xsl:value-of select="normalize-space(intervention_name)" /></xsl:for-each>
<xsl:apply-templates select='eligibility'><xsl:with-param name="type">short</xsl:with-param></xsl:apply-templates>
</div><!-- end of middle -->
</div><!-- end of top-->
<div id="detail" class="detail">
<div id="detailtophead" class="detailtophead">
<H1>Details</H1>
</div>
<!-- end of detailtop-->
<!-- start of detail body-->
<div id="detailmiddle" class="detailmiddle">
<span class="trialtitle2">Trial Description:</span>
<span class="trialtitle4"><xsl:apply-templates select='brief_summary/textblock' /></span>
<span class="trialtitle1">Eligibility: </span>
<xsl:apply-templates select='eligibility'><xsl:with-param name="type">long</xsl:with-param></xsl:apply-templates>
</div><!--end of detail middle-->
</div><!-- end of detail top-->
<div id="enroll" class="enroll">
<div id="enrolltophead" class="enrolltophead">
<H1>Enrollment</H1>
</div>
<!-- end of enroll top head-->
<!-- start of enroll body-->
<div id="enrollmiddle" class="enrollmiddle">
<xsl:choose>
<xsl:when test="$status = 'Recruiting'">
This study has participating centers in a number of locations.
To take the next step in learning more about participating in this clinical study please call one of these trial contacts.<p/>
The trial contacts will know this study as <span class="tealbold"><xsl:apply-templates select='//org_study_id'/></span>
or may know the study under the ClinicalTrials.gov identifier <span class="tealbold"><xsl:apply-templates select='//nct_id'/></span>.<p/>
<p/>
<xsl:apply-templates select='overall_contact'/>
<xsl:for-each select="location">
<xsl:call-template name='location'/><p/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
This study is not currently Recruiting, it is <xsl:value-of select="$status" />.
</xsl:otherwise>
</xsl:choose>
</div><!--end of enroll middle-->
</div><!-- end of enroll -->
<div id="credit" class="credit">
<div id="credittophead" class="credittophead">
<H1>Credits</H1>
</div>
<!-- end of credit top head-->
<!-- start of credit body-->
<div id="creditmiddle" class="creditmiddle">
Information about this trial has been gathered from ClinicalTrials.gov. Please see
<a>
<xsl:attribute name="href" >
/ctcpub/redirect.jsp?redirectURL=http://ClinicalTrials.gov
</xsl:attribute>
ClinicalTrials.gov
</a> for more complete information.<p/>
<xsl:apply-templates select='required_header/download_date'/><p/>
<a>
<xsl:attribute name="href" >
/ctcpub/redirect.jsp?redirectURL=<xsl:apply-templates select='required_header/url'/>
</xsl:attribute>
<xsl:apply-templates select='required_header/link_text'/>
</a> <p/>
This trial data was last updated on <xsl:apply-templates select='//lastchanged_date'/><p/>
</div><!--end of credit body-->
</div><!--end of credit-->
</body>
</html>
</xsl:template>
<xsl:template match="brief_title">
<span class="trialtitle"><xsl:value-of select="normalize-space(.)" /></span>
</xsl:template>
<xsl:template match="official_title">
<span class="tealbold">Official Title: </span> <xsl:value-of select="normalize-space(.)" />
</xsl:template>
<xsl:template match="phase">
<span class="tealbold">Phase: </span> <xsl:value-of select="normalize-space(.)" />
</xsl:template>
<xsl:template match="overall_status">
<xsl:value-of select="normalize-space(.)" />
</xsl:template>
<xsl:template match="eligibility">
<xsl:param name="type" />
<xsl:choose>
<xsl:when test="$type = 'short'">
<span class="tealbold">Eligibility: </span> <xsl:call-template name="ages">
<xsl:with-param name="min"><xsl:value-of select="normalize-space(minimum_age)" /></xsl:with-param>
<xsl:with-param name="max"><xsl:value-of select="normalize-space(maximum_age)" /></xsl:with-param>
</xsl:call-template>, <xsl:apply-templates select='gender' />
</xsl:when>
<xsl:when test="$type = 'long'">
<span class="trialtitle">Eligibility: </span>
<span class="tealbold">Age: </span> <xsl:call-template name="ages">
<xsl:with-param name="min"><xsl:value-of select="normalize-space(minimum_age)" /></xsl:with-param>
<xsl:with-param name="max"><xsl:value-of select="normalize-space(maximum_age)" /></xsl:with-param>
</xsl:call-template>
<span class="tealbold">Genders Eligible for Study: </span> <xsl:apply-templates select='gender' />
<xsl:text>
</xsl:text>
<span class="tealbold">Eligibility Criteria: </span>
<xsl:apply-templates select='criteria/textblock' />
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="gender">
<xsl:choose>
<xsl:when test=". = 'Both'">Male or Female</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(.)" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="overall_contact">
<span class="trialtitle">Central Contact: </span>
<xsl:apply-templates select='./first_name' /><xsl:text> </xsl:text>
<xsl:apply-templates select='./middle_name' /><xsl:text> </xsl:text>
<xsl:apply-templates select='./last_name' />
<xsl:apply-templates select='./phone' />
<xsl:apply-templates select='./email' />
</xsl:template>
<xsl:template name="ages">
<xsl:param name="min" />
<xsl:param name="max" />
<xsl:choose>
<xsl:when test="($min != '') and ($max != '')">Between <xsl:value-of select="$min" /> and <xsl:value-of select="$max" /></xsl:when>
<xsl:when test="($min != '') and ($max = '')"><xsl:value-of select="$min" /> and Above</xsl:when>
<xsl:when test="($min = '') and ($max != '')">Under <xsl:value-of select="$max" /></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="brief_summary/textblock">
<span class="trialtitle">Trial Description: </span> <xsl:call-template name="substitute">
<xsl:with-param name="string" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="location">
<span class="trialtitle"><xsl:apply-templates select='.//country' /><xsl:apply-templates select='.//state' /></span>
<xsl:apply-templates select='./facility/name' /><xsl:apply-templates select='.//city' /><xsl:apply-templates select='.//zip' /><xsl:apply-templates select='.//status' />
<xsl:apply-templates select='./contact' />
</xsl:template>
<xsl:template match="contact">
<span class="tealbold">Site Contact: </span>
<xsl:apply-templates select='first_name' />
<xsl:apply-templates select='middle_name' />
<xsl:apply-templates select='last_name' />
<xsl:apply-templates select='phone' />
<xsl:apply-templates select='email' />
</xsl:template>
<xsl:template match="criteria/textblock">
<xsl:call-template name="substitute">
<xsl:with-param name="string" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template match="facility/name"><xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="country"><xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="city">, <xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="zip">, <xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="state">, <xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="status">, <xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="first_name"><xsl:value-of select="normalize-space(.)" /> </xsl:template>
<xsl:template match="middle_name"><xsl:value-of select="normalize-space(.)" /> </xsl:template>
<xsl:template match="last_name"><xsl:value-of select="normalize-space(.)" /></xsl:template>
<xsl:template match="phone">Phone: <xsl:value-of select="normalize-space(.)" />
</xsl:template>
<xsl:template match="email"><xsl:if test='. != ""'>EMail: <xsl:value-of select="normalize-space(.)" />
</xsl:if></xsl:template>
<xsl:template name="substitute">
<xsl:param name="string" />
<xsl:param name="from" select="'
'" />
<xsl:param name="to">
</xsl:param>
<xsl:choose>
<xsl:when test="contains($string, $from)">
<xsl:value-of select="substring-before($string, $from)" />
<xsl:copy-of select="$to" />
<xsl:call-template name="substitute">
<xsl:with-param name="string"
select="substring-after($string, $from)" />
<xsl:with-param name="from" select="$from" />
<xsl:with-param name="to" select="$to" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Please do as early as possible..
thanks in advanceHi I tried with below querry but iam getting an error message?
SQL> Insert into temp_clob_tab
2 SELECT XMLELEMENT("soap:Envelope",
3 XMLATTRIBUTES ('http://www.w3.org/2001/XMLSchema-instance' as "xmlns:xsi",
4 'http://www.w3.org/2001/XMLSchema' as "xmlns:xsd",
5 'http://schemas.xmlsoap.org/soap/envelope/' as "xmlns:soap"),
6 XMLELEMENT("soap:Body"),XMLELEMENT("AddListing",
7 XMLATTRIBUTES ('http://www.christielites.com' as "xmlns" )),
8 XMLELEMENT ( "SCOMCODE",a.SCOMCODE), XMLELEMENT ( "SLOCCODE",SLOCCODE),
9 XMLELEMENT ( "DSTART",DSTART),XMLELEMENT ( "DEND",DEND),XMLELEMENT ( "SECODE",SECODE),
10 XMLELEMENT ( "IAVAIL",IAVAIL),XMLELEMENT ("IOWNED",IOWNED),XMLELEMENT ("SPOSTTRANS",SPOSTTRANS))
11 from LiteExchangeAvailablity a;
SELECT XMLELEMENT("soap:Envelope",
ERROR at line 2:
ORA-00932: inconsistent datatypes: expected CLOB got - -
Split data into different fields in TR
I have a flat file with space (multiple spaces between different fields) as a delimiter. The problem is, file is coming from 3rd party and they don't want to change the separator as comma or tab delimited CSV file. I have to load data in ODS (BW 3x).
Now I am thinking to load line by line and then split data into different objects in Transfer rules.
The Records looks like:
*009785499 ssss BC sssss 2988 ssss 244 sss 772 sss 200
*000000033 ssss AB ssss 0 ssss 0 ssss 0 ssss 0
*000004533 ssss EE ssss 8 ssss 3 ssss 2 ssss 4
s = space
Now I want data to split like:
Field1 = 009785499
Field2 = BC
Field3 = 2988
Field4 = 244
Field5 = 772
Field6 = 200
After 1st line load, go to 2nd line and split the data as above and so on. Could you help me with the code pleaseu2026?
Is it a good design to load data? Any other idea?
I appreciate your helps..Hi,
Not sure how efficient this is, but you can try an approach on the lines of this link /people/sap.user72/blog/2006/05/27/long-texts-in-sap-bw-modeling
Make your transfer structure in this format. Say the length of each line is 200 characters. Make the first field of the structure of length 200. That is, the length of Field1 in the Trans Struc will be 200.
The second field can be the length of Field2 as you need in your ODS, and similarly for Field3 to Field6. Load it as a CSV file. Since there are no commas, the entire line will enter into the first field of the Trans Structure. This can be broken up into individual fields in the Transfer Rules.
Now, in your Start Routine of transfer rules, write code like this (similar to the ex in the blog):
Field-symbols <fs> type transfer-structure.
Loop at Datapak assigning <fs>.
split <fs>-Field1 at 'ssss' into <fs>-field1 <fs>-field2 <fs>-field3....
modify datapak from <fs>
endloop.
Now you can assign Field1 of Trans Struc to Field1 of Comm Struc, Field2 of Trans Struc to Field2 of Comm Struc and so on.
Hope it helps!
Edited by: Suhas Karnik on Jun 17, 2008 10:28 PM -
How to insert data into BLOB column using sql
Hi all,
How to insert data into BLOB column directly using sql .
create table temp
a blob,
b clob);
SQL> /
Insert into temp values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
ERROR at line 1:
ORA-01465: invalid hex number
Please help in this.Thanks,
P Prakashsee this
How to store PDF file in BLOB column without using indirect datastore -
How to parse a delimited string and insert into different columns?
Hi Experts,
I need to parse a delimited string ':level1_value:level2_value:level3_value:...' to 'level1_value', 'level2_value', etc., and insert them into different columns of one table as one row:
Table_Level (Level1, Level2, Level3, ...)
I know I can use substr and instr to get level value one by one and insert into Table, but I'm wondering if there's better ways to do it?
Thanks!user9954260 wrote:
However, there is one tiny problem - the delimiter from the source system is a '|' When I replace your test query with | as delimiter instead of the : it fails. Interestingly, if I use ; it works. See below:
with t as (
select 'str1|str2|str3||str5|str6' x from dual union all
select '|str2|str3|str4|str5|str6' from dual union all
select 'str1|str2|str3|str4|str5|' from dual union all
select 'str1|str2|||str5|str6' from dual)
select x,
regexp_replace(x,'^([^|]*).*$','\1') y1,
regexp_replace(x,'^[^|]*|([^|]*).*$','\1') y2,
regexp_replace(x,'^([^|]*|){2}([^|]*).*$','\2') y3,
regexp_replace(x,'^([^|]*|){3}([^|]*).*$','\2') y4,
regexp_replace(x,'^([^|]*|){4}([^|]*).*$','\2') y5,
regexp_replace(x,'^([^|]*|){5}([^|]*).*$','\2') y6
from t;
The "bar" or "pipe" symbol is a special character, also called a metacharacter.
If you want to use it as a literal in a regular expression, you will need to escape it with a backslash character (\).
Here's the solution -
test@ORA11G>
test@ORA11G> --
test@ORA11G> with t as (
2 select 'str1|str2|str3||str5|str6' x from dual union all
3 select '|str2|str3|str4|str5|str6' from dual union all
4 select 'str1|str2|str3|str4|str5|' from dual union all
5 select 'str1|str2|||str5|str6' from dual)
6 --
7 select x,
8 regexp_replace(x,'^([^|]*).*$','\1') y1,
9 regexp_replace(x,'^[^|]*\|([^|]*).*$','\1') y2,
10 regexp_replace(x,'^([^|]*\|){2}([^|]*).*$','\2') y3,
11 regexp_replace(x,'^([^|]*\|){3}([^|]*).*$','\2') y4,
12 regexp_replace(x,'^([^|]*\|){4}([^|]*).*$','\2') y5,
13 regexp_replace(x,'^([^|]*\|){5}([^|]*).*$','\2') y6
14 from t;
X Y1 Y2 Y3 Y4 Y5 Y6
str1|str2|str3||str5|str6 str1 str2 str3 str5 str6
|str2|str3|str4|str5|str6 str2 str3 str4 str5 str6
str1|str2|str3|str4|str5| str1 str2 str3 str4 str5
str1|str2|||str5|str6 str1 str2 str5 str6
4 rows selected.
test@ORA11G>
test@ORA11G>isotope
PS - it works for semi-colon character ";" because it is not a metacharacter. So its literal value is considered by the regex engine for matching.
Edited by: isotope on Feb 26, 2010 11:09 AM -
Insert data into the column which is having null values.
Hi,
I have a column called "Classification_CD" .This column is having NULL values.I want to insert the data into this column.
I tried to write the query as follows. But it is showing the mesg error "SQL Error: ORA-01400 cannot insert NULL into ("ABC"."A_CMP_W"."A_CMP_SEQ_NUM")"
Can any one please help me out to write query to insert the dat afor this.
Thanks.I think you are taking about updating the null value.So you can do this..
SQL> select * from table_a;
ID SCHEDULED MARK PRID
5 07-NOV-10 T05 7
6 18-SEP-10 T06 8
4 31-JAN-11 T02 2
1 18-JAN-11 T01 2
2 18-JAN-11 T02
3 18-JAN-11 T03 1
6 rows selected.See that prid is Null for id 2
SQL> update table_a
2 set prid =10
3 where id =2;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from table_a;
ID SCHEDULED MARK PRID
5 07-NOV-10 T05 7
6 18-SEP-10 T06 8
4 31-JAN-11 T02 2
1 18-JAN-11 T01 2
2 18-JAN-11 T02 10
3 18-JAN-11 T03 1
6 rows selected.
SQL> But remember while updating u should choose a primary key column in
where condition so that only desired row or record is updated..
Regards
Umesh -
Export transnational data into different client
Dear All Expertise's,
For our Management Audit purpose we have needed urgently copy all FI transnational data into different client in particular year.
As an example:
Source Client: 888
Target client: 700
Company: 1000
Year: 2013
FI Documents type: All
Please help me to get the solution use form your great advice.
SCC8/SCC7 can give us copy all records client to client. But we need only specific company/periods.
Thanks and Best regards
Bishnu
05.05I post the VI. Thanks!
Attachments:
j k thermocouple.vi 151 KB -
SegregatingTable data into different bucket with equal numebr of
Hi Guys,
I wanted to process table data in chunks not all the rows at a time. How can we achieve this in oracle.
Example :
I have one table EMP which has ten thousands rows(10,000) rows. Now these ten thousands rows are joined with other tables to process data and it takes time. So I wanted to pass one thousands rows at a time as an input to the procedures so that processing should happen only with 1 thousands rows at a time. This table does not have any primary key. So it there any method in oracle using that I can segregating the tables data into different buckets with equal number of rows.
I have used DBMS_PARALLEL_EXECUTE but its taking lots of time. Any help will be appreciated.I have one table EMP which has ten thousands rows(10,000) rows. Now these ten thousands rows are joined with other tables to process data and it takes time.
OK... So this is your actual problem. And the solution you are trying to come up with does not sound promising. So lets take a step back and re-think our strategy here. First thing would be how about we see some code? Show us your code that you say is running slow. And we can take it from there. The number 10,000 is a very small number. And if that is causing performance issue then you are in some big trouble.
And also it wouldn't hurt if you could read this Re: 3. How to improve the performance of my query? / My query is running slow. -
Can we send the data into different data target from single datasource how
Hai
can we send the data into different data target from single datasource how ?Hi,
Create the transformation for each target and connect through DTP if you are in BI 7.0
If it is BW 3.5 create transfer rules and load it Info source and then different update rules for different targets then load it using IP.
If you are speaking about loading data from R3 data source to multiple data sources in BI
Then follow the below step.
1)create init IP's and run the IP's with different selection to different DSO(With same selection it is not possible).
2)Then you will have different delta queues for the same data source in RSA7
3)Your delta loads will run fine to different data sources from same DS in R3.
Hope this helps
Regards,
Venkatesh
Maybe you are looking for
-
I've just updated my iPhone4 to iOS 6.0.1 and went through the back-up routine. The back-up routine appeared to partially update, displaying an error, however has brought through my contacts, previous messages and has even maintained my bluetooth co
-
Tables for Single-quantity Inspection Lot Results
Hello! I hope someone could help me out on this one: Please correct me if I'm wrong, but I noticed that in an inspection lot, the results of the inspection is stored in the table QASE, but only if the quantity inspected is greater than one. So, my
-
Implementation of a 3 tier model architecture
Hi, I've just gotten a project to complete where users at 20 customer sites need to gain access to a database in our company and download/upload lots of tables/data from a web page (thru a firewall etc) The way I initally intended to go was using an
-
Send message to SAP inbox - change message CREATOR
Hi, I'm sending a message to a user's SAP inbox using function module SO_OBJECT_SEND. By default, the message creator is set to sy-uname. I need to change this to a generic user e.g. 'SYSTEMUSER'. This is not the same as the SENDER/Author/Owner. I ma
-
Hi getting this error message when moving a group of dng images from lrm5 for editing in elements 12.Works fine if only moving a single image?