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
Mudassar

Shridar 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

Similar Messages

  • 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

  • Report Attributes: Add column link and derived column

    On the Report Attributes page (4000:420), under the Tasks list on the right side of the page, there are 2 links, "Add column link" and "Add derived column". This is the first time I am noticing them.
    The usage is clear, they add columns to the report to function either as a drill-thru link column or just a read-only derived field.
    Doing it this way does NOT modify the source query for the report region.
    Is there any benefit to using this feature versus adding a "null column_link" or "null derived_col" columns to my source query then setting attributes for those columns?
    Thanks

    Well, one disadvantage I can see of using the 'Add Column link' is that if I have more than 1 of such columns, they all show up as '[column link]' on the Report Attributes page with no way to tell what the underlying links are. Instead, if I were to manually add these dummy columns to my query itself, I would give them meaningful column aliases that indicated where they link to.
    Suggestion: Maybe a tooltip could be added to the Report Attributes page for such columns which indicate what the underlying link is without actually going to the Edit page for that column.
    Thanks

  • How to get metadata option list values derived from a table/view using SOAP

    I am writing an ASP.NET application that replicates some of the features of the SCS search interface. I have looked at the GET_DOC_METADATA_INFO service and its SOAP output. It has a few missing pieces of information, like the option list values for a field if that fields values are derived from a separate table/view. Some of the fields I am dealing with also make use of Dynamic Control Lists (DCL). Is there a way to get the DCL info using SOAP? I did notice that the dOptionListKey element contains the name of the view from which the option list values will be derived. However, I cannot find a service that takes the view name as a parameter to return the option list values. I have looked in the services reference manual, but I have not had any luck finding what I am looking for.
    TIA
    - Tyson
    Message was edited by: Add the word 'get' to the subject.
    Tyson

    Hello,
    What error you are getting? You code seems to be ok. I have tested below code and working fine
    XPathNavigator rTable = MainDataSource.CreateNavigator();
    String ddlSectionSelectedValue = Convert.ToString(rTable.SelectSingleNode("/my:myFields/my:ddlSection", NamespaceManager).Value);
    One think you can check that keep dropdown value display name and id same.
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Avoiding derived columns for mapping purposes only

    Hi.  In 2012 has there been any advancement that would alleviate us from adding a derived column simply for the purpose of mapping an existing var or param to an oledb output column? 

    Hi DB042189,
    According to your description, what you would like to do is directly mapping a variable or parameter to an Output column of a Data Flow Task control without adding a new column through the Derived Column transform. If so, this is not supported in SSIS 2012
    currently. I would suggest you submitting a wish at
    https://connect.microsoft.com/sql.
    Connect site is a connection point between you and Microsoft, and ultimately the larger community. Your feedback enables Microsoft to make software and services the best that they can be, and you can learn about and contribute to exciting projects.
    Regards,
    Mike Yin
    TechNet Community Support

  • 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 Ulrike

    Ulrike - 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.

  • 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.YEAR

    Select 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 syntax help needed

    I am struggling getting the following case statement into the derived column format in SSIS
    CASE 
    WHEN SUBSTRING(REPLICATE('0', 9 - LEN(Data)) + CAST(Data AS VARCHAR(9)), 4, 6) IS NULL
    THEN 0
    ELSE RTRIM(SUBSTRING(REPLICATE('0', 9 - LEN(Data)) + CAST(Data AS VARCHAR(9)), 4, 6))
    END
    Here are examples for the data in Data
    row 1 - 1201303
    row 2 - 123456789
    row 3 - null
    row 4 - 12345678
    the first row result would be 201303
    row 2 result would be 456789
    row 3 result would be 0
    row 4 result would be 345678
    Andre Toerien

    I have a problem with the isnull, the isnull needs to be on the first 6 characters as well. 
    Maybe its best explained with the other similar fields
    ISNULL(LEFT((DT_STR,3,1252)CYCLE_YYYYMM,3)) ? "0" : LEFT((DT_STR,3,1252)CYCLE_YYYYMM,3)
    and 
    ISNULL(RIGHT((DT_STR,3,1252)CYCLE_YYYYMM,6)) ? "0" : RIGHT((DT_STR,6,1252)CYCLE_YYYYMM,6)
    We are trying to keep the coding similar on all our fields even if its a but redundant, we moved over from an Adabas system, and in the last example there are actuallt cases with the  first three characters being seen as nulls, if I understand correctly
    the fields in Adabas are right aligned which causes this, so I need to cater for the difference between a true null where I expect a null value to be returned and one where a substring on a left(field,6) return a null which then as to return a 0..
    ISNULL(LEFT((DT_STR,3,1252)CYCLE_YYYYMM,3)) ? "0" : LEFT((DT_STR,3,1252)CYCLE_YYYYMM,3)---this one is actually a substring(field,1,3) and the one below is a substring(field,4,6)
    ISNULL(RIGHT((DT_STR,3,1252)CYCLE_YYYYMM,6)) ? "0" : RIGHT((DT_STR,6,1252)CYCLE_YYYYMM,6)
    some of the vause in sql are actually 0 for the 1,3 and 201302 for the 4,6, same field
    Hope this makes sense, i actually tested this and the data actually is like that. I also need an example of how to handle the second example 
    ISNULL(RIGHT((DT_STR,3,1252)CYCLE_YYYYMM,6)) ? "0" : RIGHT((DT_STR,6,1252)CYCLE_YYYYMM,6) - this is of course the substring 4,6 field
    I am serious;y considering leaving the derived column if I cannot get this to work, have been struggling with this for a few days
    Andre Toerien

  • How to get user name as a calculated column in Analytic View or Calculation Graphical View?

    Hi Folks,
    I needed something like this. In the output, I needed a column which displays the SESSION USER who is seeing the results of the model.
    In Script , we can have something like this
    SELECT SESSION_USER FROM DUMMY
    How can I do the same using calculated columns in the model?
    Regards,
    Krishna Tangudu

    Hi Nick,
    Since you have said "Month Name", I am guessing you are interested in getting values such as "January", "February" and so on as opposed to 01, 02.... Is that right?
    If so, I don't think there exists a built-in function in HANA that could give you that. A calculated attribute with a case or if statement on the hard-coded descriptions (January, February...) for month values (01,02...) derived from the data column (BEZDT) is what I can think of.
    Thanks,
    Anooj

  • 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.

  • Checkbox derived column in report

    I added an HTML checkbox that has the same name for every row and a value of the pk for that row to a report. I also added a submit button.
    The submit button branches back to the same page.
    If I don't check ANY checkbox buttons the submit button just takes me back to the same report. If I even click one checkbox, I get a 404 "Page cannot be found" with the url saying: pls/htmldb/wwv_flow.accept
    why is this procedure doing this? How can I add a derived column containing a checkbox to a report for selection of report rows for further processing or adding of these rows to a "shopping cart/basket".

    Enough with this ..... link
    http://www.oracle.com/technology/products/database/htmldb/howtos/checkbox.html
    How many times do we have to see it in the forum....Enough.....
    Its so frustrating giving the same link time and time again...And the funny
    part is that most people's questions has nothing to do with that. But
    still some geniuses give the same link....I just feel so sorry for people
    who are struggling to get a answer and some idiots give the same link

  • How to cast an object in JSF?

    I am working on a travel application. A user can have several bookings and a booking can have several components. A component can be either air or hotel. I want to list the user's bookings on the client using JSF datatable.
    <h:dataTable var="component" value="#{booking.components}">
    Now depending upon the class of component I need to present different information.
    My question is how to cast the variable in JSF ?
    Thanks

    You can use the String value of Object#getClass()#getName() to lookup the classname and evaluate it in the 'rendered' attribute.
    Basic example:
    package mypackage;
    public class Animal {}
    package mypackage;
    public class Cat extends Animal {}
    package mypackage;
    public class Dog extends Animal {}
    package mypackage;
    public class Fish extends Animal {}MyBeanpublic List<Animal> getList() {
        List<Animal> animals = new ArrayList<Animal>();
        animals.add(new Dog());
        animals.add(new Cat());
        animals.add(new Fish());
        return animals;
    }JSF<h:dataTable value="#{myBean.list}" var="item">
        <h:column>
            <h:outputText value="It's a Cat" rendered="#{item.class.name == 'mypackage.Cat'}" />
            <h:outputText value="It's a Dog" rendered="#{item.class.name == 'mypackage.Dog'}" />
            <h:outputText value="It's a Fish" rendered="#{item.class.name == 'mypackage.Fish'}" />
        </h:column>
    </h:dataTable>As far there is no way to cast objects in JSF.
    Edit
    If you find it useful, move the classname request to the superclass:
    public class Animal {
        public String getType() {
            String className = getClass().getName();
            return className.substring(className.lastIndexOf('.') + 1);
    }Which makes life easier without struggling with package names:<h:outputText value="It's a Cat" rendered="#{item.type == 'Cat'}" />
    <h:outputText value="It's a Dog" rendered="#{item.type == 'Dog'}" />
    <h:outputText value="It's a Fish" rendered="#{item.type == 'Fish'}" />Message was edited by:
    BalusC

  • 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

  • Output a derived column to a flatfile destination

    I'm a newbie. My source is a sql server table. Then I dropped a derived column icon. And finally a flatfile destination.
    When I open the flatfile destination, it does show the new column as 'Derived Column 1' in the Available Input Columns, but it's not shown in the Available Destination Columns.
    How do I add it to the Available Destination Columns?

    I had to open the flat file connection manager window and manually add a new column.

  • 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
    Simon

    It'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

Maybe you are looking for