Replace "\\\\''" from a derived column
Hi All,
Quick Question : need to replace in a string the value '' (quote quote) by \\'' (antislash antislash quote quote).
This change could be done from a derived column transformation
Obviously REPLACE(field_value,"''","\\\\''") doesn't run...
Thx for your help
Don't understand the following issue :
1/ from a NEW project into a derived colum i enter :
"REPLACE(field1,@[User::varSearch],@[User::varReplacement])"
=> black font : it s running
2/ from an existing project I create the both variable : varSearch, varReplacement
and into a derived colum : "REPLACE(field1,@[User::varSearch],@[User::varReplacement])"
=> red font : it s running
I suppose a format (wstr) or lenght field issue...
Similar Messages
-
"Derived Column" failed because truncation occurred !!!!
HI Friends,
I have got this Error so My package execution keep Failing so Please find my error Below.
Error Message :
Executed as user: BSSLOCAL\DB-CLUS-SQL-Server. Microsoft (R) SQL Server Execute Package Utility Version 11.0.2100.60 for 32-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 08:41:00 Error: 2014-02-03
08:41:13.92 Code: 0xC020902A Source: Upload to Sharepoint Derived Column [14] Description:The "Derived Column" failed because truncation occurred, and the truncation row disposition
on "Derived Column.Outputs[Derived Column Output].Columns[SDate]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component. End Error Error: 2014-02-03 08:41:13.95 Code:
0xC0047022 Source: Upload to Sharepoint SSIS.Pipeline Description: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Derived Column" (14) failed with error code 0xC020902A while processing
input "Derived Column Input" (15). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There
may be error messages posted before this with more information about the failure. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 08:41:00 Finished: 08:41:17 Elapsed: 17.5 seconds. The
package execution failed. The step failed.
Please give me how Can I rectify This Error Thanks For Advance.Hi Cherukuri19,
If I understand correctly, you checked the data type of the input column from the Advanced Editor for the Derived Column component, right? Based on the error message, it seems that the data length of the target column outputted by the component above the
Derived Column (may be the Source Component) is more than 10 characters. However, you just modify the Input Column data type and length from the Derived Column component, hence, the data truncation error occurs. In this condition, you can avoid this issue
by using the following steps:
Keep the original nature of the SDate Input Column, e.g. don’t set the data type of this column to [DT_STR] or set its length.
Use the following expression instead for the Derived Column:
(DT_STR,10,1252)((DT_DBDATE)SDate)
Regards,
Mike Yin
TechNet Community Support -
How can I Derive columns from derived columns? Is it possible?
I am learning SQL on the job at the moment working on application express. But have hit a problem. As you can see below I have 3 tables ATTENDING, EVENTS and BUDGET, in the select statement below I have 2 derived columns but I would like to add SUM(Related_Expenses+ Course_Expenses) for each row. How is this possible?
SELECT
BUDGET.BUDGET_ID,
BUDGET.BUDGET_TYPE,
BUDGET.ALLOCATION,
(select
NVL(SUM(EVENTS.ORDER_AMMOUNT),0)
from EVENTS, C_YEAR
where EVENTS.BUDGET_ID = BUDGET.BUDGET_ID
and EVENTS.YEAR = C_YEAR.YEAR
) as Course_Expenses,
( select
NVL(SUM(NVL(ATTENDING.ACCOMADATION_BT_AMOUNT,ATTENDING.ACCOMODATION_ESTIMATE)),0)+
NVL(SUM(NVL(ATTENDING.TRAVEL_BT_AMOUNT,ATTENDING.TRAVEL_BOOKED_ESTIMATE)),0)+
NVL(SUM(NVL(ATTENDING.TRAVEL_OTHER_CLAIM,ATTENDING.TRAVEL_OTHER_ESTIMATE)),0)+
NVL(SUM(NVL(ATTENDING.SUBSISTENCE_CLAIM,ATTENDING.SUBSISTENCE_ESTIMATE)),0)
from EVENTS, ATTENDING
where ATTENDING.EVENT_ID = EVENTS.EVENT_ID
and EVENTS.BUDGET_ID = BUDGET.BUDGET_ID
and EVENTS.YEAR = C_YEAR.YEAR
) as Related_Expenses
from BUDGET, C_YEAR
where BUDGET.YEAR = C_YEAR.YEARSelect yb.budget_id,
yb.budget_type,
yb.allocation,
(yb.course_expenses + yb.related_expenses) total_expenses
From (SELECT BUDGET.BUDGET_ID,
BUDGET.BUDGET_TYPE,
BUDGET.ALLOCATION,
(select NVL(SUM(EVENTS.ORDER_AMMOUNT),0)
from EVENTS, C_YEAR
where EVENTS.BUDGET_ID = BUDGET.BUDGET_ID
and EVENTS.YEAR = C_YEAR.YEAR) as Course_Expenses,
(select NVL(SUM(NVL(ATTENDING.ACCOMADATION_BT_AMOUNT,ATTENDING.ACCOMODATION_ESTIMATE)),0)+
NVL(SUM(NVL(ATTENDING.TRAVEL_BT_AMOUNT,ATTENDING.TRAVEL_BOOKED_ESTIMATE)),0)+
NVL(SUM(NVL(ATTENDING.TRAVEL_OTHER_CLAIM,ATTENDING.TRAVEL_OTHER_ESTIMATE)),0)+
NVL(SUM(NVL(ATTENDING.SUBSISTENCE_CLAIM,ATTENDING.SUBSISTENCE_ESTIMATE)),0)
from EVENTS, ATTENDING
where ATTENDING.EVENT_ID = EVENTS.EVENT_ID
and EVENTS.BUDGET_ID = BUDGET.BUDGET_ID
and EVENTS.YEAR = C_YEAR.YEAR) as Related_Expenses
from BUDGET, C_YEAR
where BUDGET.YEAR = C_YEAR.YEAR) yb -
Derived column transformation from varchar(8) YYYYMMDD to DATETIME column
It seems I have tried everything, but all I need to do is change a column from varchar(8) to DATETIME. Some lines are blank, zero length strings, and some have dates such as 20140829. All the rows go to an exception table or it just bombs altogether. The
only thing I can get to run is NULL(DT_DATE), but obviously, that won't work in the end.
I tried LTRIM(RTRIM(MyDateColumn) == "" ? (DT_DATE)"1900-01-01" : (DT_DATE)(SUBSTRING(MyDateColumn,1,4) + "-" + SUBSTRING(MyDateColumn,5,2) + "-" + SUBSTRING(MyDateColumn,7,2))
I got truncation errors on that.
Sometimes I got an error: An error occurred while attempting to perform a type cast.
I tried DT_DATE, DT_DBDATE and DB_DBTIMESTAMP
I even tried putting GETDATE() in there or a literal date such as "2014-08-29" like (DT_DBDATE)"2014-08-29"
This wouldn't even compile: MyDatCeolumn == "" ? NULL(DT_DBDATE) : (DT_STR,10,1252)((DT_DBDATE)MyDateColumn)
I tried many variations on these. I either got truncation errors or the transformation would turn red and stop, or the expression wouldn't work (turns red when you leave the row).
Review:
Source MyDateColumn VARCHAR(8) NULL; Target MyDateColumn DATETIME; Source values in format of "" (blank) or "20140829". The blanks should end up null, or maybe a literal date like Jan 1, 1900, and the actual dates should be transformed
to DATETIME.
Should not be that hard. Thanks in advance for help.Hi duanewilson,
Please create a Derived Column transformation and a new column, then use the following expression for the expression field:
(DT_DATE)(SUBSTRING([MyDateColumn],1,4) + "-" + SUBSTRING([MyDateColumn],5,2) + "-" + SUBSTRING([MyDateColumn],7,2))
If you have any feedback on our support, please click
here.
Elvis Long
TechNet Community Support -
SSIS: Using CASE Statement Within A Derived Column Transformation Expression
The following is my Data Flow:
Ole DB Source > Copy Column > Derived Column >Ole DB Command
My OLE DB Source has the following SQL command task:
SELECT *
FROM Repair R
LEFT OUTER JOIN Vehicle V
ON R.SN = V.SN
AND R.Reg = V.Reg
LEFT OUTER JOIN Product P
ON R.PID = P.PID
This yields a column of concern for me named PartNumber, which are represented by the following 2 formats:
The following are my Copied Columns:
Input Column = PartNumber
Output Alias = Copy of PartNumber
The following are my Derived Column expressions:
Derived Column Name Derived Column Expression
Name Replace 'PartNumber' LEFT(PartNumber,FINDSTRING(PartNumber,"-",1) - 1)
Copy of Name Replace 'Copy of PartNumber' RIGHT([Copy of PartNumber],LEN([Copy of PartNumber]) - FINDSTRING([Copy of PartNumber],"-",1))
So My PartNumber Column is Replaced with ######### of type
string and the Copy of PartNumber column is replaced with
#### of type int
As I stated earlier PartNumber also is in the format of %-%-% which raises the following question:
How can I replace PartNumber Column with NULL if in format of
%-%-% and take the PartNumber and put it in new column named
SubPart while keeping all the logic within SSIS objects?
So in essence I want to do something like the following:
PartNumber = CASE
WHEN 'PartNumber' LIKE '%-%-%'
THEN ABC = PartNumber AND PartNumber IS NULL
END
I have tried the case statement in a Derived Column expression and is not working. Would I add the
CASE statement to the SQL command task in my OLE DB Source?
I hope this question is concise for you.If it must be in SSIS, I would put a derived column stage earlier in the process to do my check for me. Then in the second derived column stage do the check against each output column (part, subpart, copy of part) to decide which way it goes
PS Not sure if it's a 2012 function but SSIS has a function called TOKEN that will allow you to pull your subparts for you rather than the left/right you are doing -
Derived Column: Assigning and and Using as a Condition
Hi,
I have 1 derived column component with 2 derived columns (see below).
1st derived col:
DerivedColName: col1
Derived Column: Replace 'col1'
Expression: REPLACENULL(col1, col1_DHH)
2nd derived col:
DerivedColName: col2
Derived Column: Replace 'col2'
Expression: ISNULL(col1) ? col2_DHH : col2
As you can see, col1 is being used as a condition to determine the value to assign to col2.
But at the same time, col1 is assigned with a value that depends on the result of REPLACENULL.
My question is, is col1's value in (ISNULL(col1) ? col2_DHH : col2) the original value i.e. before it evaluates the REPLACENULL expression?
I have tested this and it seems that col1 value is the original value (which is what i need). I just want to confirm from you guys that this is always the case i.e. it is deterministic.
Thanks!If they're in same derived column then it takes original value ie prior to start of derived column
If you want evaluated value to be used for second expression then you need to use two derived tasks and join first to second with precedence constraint with option On Success
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Derived column without trigger
Hello eveyone,
I was wondering if anyone can tell me if it is possible to have a computed column on a Oracle Table (like in Excel formula's). Let's suppose this example:
CREATE TABLE MYTABLE
BIRHTDAY DATE,
AGE NUMBER(10,4) (= (SYSDATE-BIRHTDAY) / 365) )
);This is an example; I know this does not make any sense. But that's the idea. I know I can have a column which can be updated through triggers (after insert/update of a given columns), or I can also create a view.
But is there any way to create a derived column with its logica defined within the create table statement?
Thanks for your help,
O.Hi,
If yoo are on a lower version then one option you have is a view.
Keep your data as it is, write a view which will do the calculation and show you the result.
For example(a very basic one)
drop table test;
create table test (sal number, comm number);
alter table test add (emp_id number);
insert into test values (1,2,1);
insert into test values (3,2,2);
insert into test values (4,1,3);
insert into test values (5,2,4);
commit;
create or replace view v_test as select emp_id,sal,comm,sal+comm total from test;
select * from v_test;Cheers!!!
Bhushan -
Hi,
I have a requirement to derive month value from the variable.
The variable 'carInputMonth' holds the values 01 or 02 or 03 ...12 based on the input parameter.
My requirement is to load the target file with Month column and the value should be 'Jan', 'Feb',..'Dec'. So I have to derive the month name from month number.. I though to write a case statement in the derived column but it is not working for me. Please
advise.
Thanks.Hi Amaya14,
Based on your description, you want to create a derived column that corresponding to the values of variable 'carInputMonth': 'Jan', 'Feb',…'Dec' for '01', '02',… '12'.
After testing the issue in my environment, we can use the expression as the derived column in Derived Column Transformation:
@[User::carInputMonth] == "01" ? "Jan" : @[User::carInputMonth] == "02" ? "Feb" : @[User::carInputMonth] == "03" ? "Mar" : @[User::carInputMonth] == "04" ? "Apr" : @[User::carInputMonth] == "05" ? "May" : @[User::carInputMonth] == "06" ? "Jun" : @[User::carInputMonth] == "07" ? "Jul" : @[User::carInputMonth] == "08" ? "Aug" : @[User::carInputMonth] == "09" ? "Sep" : @[User::carInputMonth] == "10" ? "Oct" : @[User::carInputMonth] == "11" ? "Nov" : @[User::carInputMonth] == "12" ? "Dec" : ""
Besides, please verify that the variable name is completely matched. We can drag the correct variable from ‘Variables and Parameters’ group to replace @[User::carInputMonth] in my expression above.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to cast a column of a derived column in a view to NULL
I have a derived column in my view and this column by default is picked up as not null.
I want to cast it to null how can i do it ?
Actual column
column1 varchar(3) not null
Expected column
column1 varchar(3) null
MudassarShridar I havent defined it but the derived column has been picked up as not null which is strange
CREATE VIEW test
AS
SELECT
CASE
WHEN COMPANY_SIZE IS NULL then 'a'
ELSE 'b'
END AS
column1 ----- added derived column identifier
,[Company_Size] AS [CompanySize]
FROM xyz
Mudassar -
Can't change the connection string of SSIS package with derived columns?
We upgraded SQL server 2008 to 2012, copied and converted all SSIS packages from Visual Studio 2008 to 2010. When I opened a package in VS 2010 and tried to change the connection string, in the local connection managers, if the data source is another
SSIS package B(.dtsx file) with derived columns, I can't change the connection string of package B. When I opened the file connection manager editor for package B and tried to locate a dtsx file in another location, saved the change, reopened the project.
Package B still pointed to previous file. Other packages without derived columns work fine. Any thoughts?We are using the package deployment model and refer to other packages in the same project. If
we changed the path of package B (with derived columns) to "D:\Visual Studio 2010\xxxx", and refer it in package A, in the A's connection manager, the connection string of package B is still its previous location "D:\Visual
Studio 2008\xxxx". When we ran the package A in the SQL server agent, the data source is still
"D:\Visual
Studio 2008\xxxx", so how can I change it to "D:\Visual
Studio 2010\xxxx"? Why has the package C (without derived columns) no such problem? thanks. -
Multiple report fields from single physical column.
Hi Experts,
I have a physical table like below. Multiple records for a single customer id. The no of Address_type may increase in future.
Customer_id Address_Type Address
101 Primary abcdefgh
101 Secondary 234oij3mb4
101 Billing mdmnweoij4
102................etc.
My Requirement on OBIEE is to display report as below.
Customer_ID, Primary_Address, Secondary_Address, Billing_Address.
101 abcdefgh 234oij3mb4 mdmnweoij4
Multiple report fields ( Primary_Address, Secondary_Address, Billing_Address ) are derived from same physical column ADDRESS.
I tried to duplicate the Address column on the report thrice and added conditions like Address_Type = Primary/Secondary/Billing for those three fields respectively.
But only of the field is getting correct data and rest of duplicate columns are null.
Tried FILTER function on OBI Answers, but the function fails saying it should be used only on measures.
Thought the alternative would be to define multiple logical columns at BMM layer. Created multiple alias for same table at physical layer and correspondingly created LTS for each on a single logical table. Defined Fragmentation/Where conditions.
LTS1 - Address_Type = PRIMARY
LTS2 - Address_Type - SECONDARY
LTS3 - Address_Type - BILLING
Created multiple logical columns from each LTS like Primary_Address, Secondary_Address, Billing_Address from LTS1, LTS2, LTS3 respectively.
This time, am getting data for all the fields on the report but getting cartesian result.
Can someone guide me whether my approach is correct or any other alternate best approach to achieve the desired result.
Note: I have the data Address on multiple physical rows for a customer, rather Not in a single row. which is causing me problem.
Thanks...
Ramchand.Hi Srini VEERAVALLI,
I have lot many other fields in the same report coming from other tables.
Does the Pivot table option for above mentioned Address fields affect other columns?
If Yes, Can there be any other alternative? Am thinking of Opaque View at Physical layer to bring all Addresses on a single row.
Thanks...
Ramchand. -
Create a derived column based on a value within the file name
I am importing a CSV file which is easy enough, but I have an issue where I need to manufacture a couple of column values based on the filename of the input. So this same process will import different types of records to the same table in sql server.
I need to pull out the record code from the file name.
For instance, say I can use the same package to input two different CSV files. One is named Input_M02_Data.csv and one named Input_B15_Data.csv. I need to create a derrived column and store the record code there (i.e.: M02 or B15) based
on which file it came out of.
fyi-
I also need to create a second column for Dept based off of the file name as well. M02 is dept 45 and B15 is dept 99 which I also need to insert into this table when I import the data from the .csv file.
Any help is greatly appreciated!Hi Jason,
According to your description, you want to add two derived columns based on the file name to also insert into table. One stores the value between two “_” within file name, another stores the department based on that column.
If in this scenario, we can add a variable FileName that stores the filename, then add the two variables as derived columns like below in the Derived Column Transformation:
Name:
SUBSTRING(@[User::FileName],FINDSTRING(@[User::FileName],"_",1)+1,FINDSTRING(@[User::FileName],"_",2)-(FINDSTRING(@[User::FileName],"_",1)+1))
Dept:
@[User::Name] =="M02"?"dept 45":@[User::Name] =="B15"?"dept 99":"dept 00"
The following screenshot is for your reference:
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
If you have any feedback on our support, please click
here.
Katherine Xiong
TechNet Community Support -
Adding Rank for a Column in SSIS Derived Column
H
I want to add rank to a column in ssis in a derived column actually.
Can u please tell how to add it and the syntax for adding it in a derived column.Thanks,
Can you please give the script for the same.
I am unable to write the script for my logic to implement in SSIS.
I will be very thankful if some one could help me with it.
Thanks in Advance.
Sam thats too generic there would be several ways to solve one problem ...
can u tell us what is ur source [i mean table view THE DATA which records tuples you suspect is having duplicates ]
on what basis u decide duplicate ? and what row qualifies to go into destination ... for eg say ur source is
select id,name, date from source_table
duplicacy could mean id and name being repeated multiple times and may be business rule is like pick up rec with latest date vale if thats the case go for source as :
select id, name,max(date) from sourcetable
group by id,name
if all the columns are repeating in your source table may be use DISTINCT ...
would be great if u give ur destination, source and business requirement ..
if you have got primary key violations and any record qualifies then may be simply at destination component set Ignore failure property and ur job is done ...
may be removing duplicate at source itself ... might solve ur problem
check out more on duplicates : http://blog.sqlauthority.com/2009/06/23/sql-server-2005-2008-delete-duplicate-rows/
i hope u got the idea ...
Hope that helps ... Kunal -
Reference the value of a Derived Column
Hi Folks.
Starting a new tread on this because the title fo the original thread which I was replying to does not address the specific issue i have now.
If I add a [derived column] to the report definition and give put the following in the HTML Expression..
<input type="file">
Then I get the file browser for each row.
Now how can I reference the value of the derived column on a row by row basis. What is the syntax for referring to the column value?
Any assistance greatly appreciated.
Many thanks
SimonIt's a case of "Close, but no cigar" I'm afraid.
Whilst this solution will capture the 'string' selected in the column. APEX still will not put the file into the APEX_APPLICATION_FILES table.
This would appear to be the final missing link in the chain.
Should you, or anyone, know how to do this, please post a reply. I did find seom info in this thread...
insert multiple files from a single form
but I'm finding it hard to follow, especially as the original tutorial link no longer works.
This page, by Denes Kubicek seems to do the trick for him...
http://htmldb.oracle.com/pls/otn/f?p=31517:161:474655789644959::NO
Have asked him if he will post the backend code.
Simon -
How can I implement an user function in a derived column of a report ?
Hello,
I've a report and added a derived column.
In this column should be displayed the result of a function.
GETANZGJMONATE ( to_date(#START_AFA#,'DD.MM.YYYY'), #ND#, :P302_GJ );
How can I implement this?
Thanks in advance
Regards UlrikeUlrike - I would do this in the SQL statement (there may be other ways).
Presumably START_AFA and ND are table columns?
Presumably you've also created the GETANZGJMONATE function?
So, something like this should work (this also assumes that START_AFA is of a DATE type - you'll need the TO_DATE call if not):
SELECT COL1
, COL2
, START_AFA
, ND
, GETANZGJMONATE (START_AFA, ND, :P302_GJ)
from TABLE
where ...
Can't remember if you have to grant any particular execute permissions on the function ('grant execute on GETANZGJMONATE to public', for example) when you call it from SQL on a page, but you could try that if the function call fails.
Depending on what's in :P302_GJ and what the function parameter data type is, you might need to use the '&P302_GJ.' syntax or TO_NUMBER etc.
Hope this helps.
Regards,
John.
Maybe you are looking for
-
Completion Confirmation of PM orders before goods movement
Hi, Is there any settings available to stop completion confirmation of PM orders before goods movement (release purchase requisitions, create purchase order, goods issuance and good receipt), if stock, non stock material and external service are assi
-
Satellite A350-12D PSAL6E: how to boot Win 8.1 without pushing power button
Hi, is there a way to boot the OS(WIN8.1) [system status: shut down] without pulling the screen first up and pushing the power button? FYI: I 'm using a external HDMI connected monitor/screen! I know of the feature wake on keyboard via BIOS, but usin
-
I can't get the bookmark panel to open in a pdf once published to our intranet
Hi. I set a pdf file to open with bookmarks and page showing. When I upload it to a web site on our intranet, it will open on some computers but not all the time. It is really frustrating and I need to find a solution. Any suggestion? Is there an
-
Graphics2D does not work in IE
the problem i'm facing is that when i run an applet, using Graphics2D class, in the appletviewer it works fine but the same applet does'nt work in the internet explorer and gives the runtime errors com.ms.security.SecurityException[flag.paint]: java.
-
Use of DbEnv::set_isalive and DbEnv::set_thread_id
Hi BDB version is 4.6.18. The reference documentation says that these function can be set any time during the life of an application. When I set these functions before opening the environment then an exception other than the DbException occurs. But w