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

Similar Messages

  • How to auto update date column without using trigger

    Hi,
    How to write below MYSQL query in Oracle 10g :
    CREATE TABLE example_timestamp (
    Id number(10) NOT NULL PRIMARY KEY,
    Data VARCHAR(100),
         Date_time TIMESTAMP DEFAULT current_timestamp on update current_timestamp
    I need to auto update the Date_Time column without using trigger when ever i update a record.
    Example shown below is from MYSQL. I want to perform the below steps in ORACLE to auto update Date_Time column.
    mysql> INSERT INTO example_timestamp (data)
    VALUES ('The time of creation is:');
    mysql> SELECT * FROM example_timestamp;
    | id | data | Date_Time |
    | 1 | The time of creation is: | 2012-06-28 12:37:22 |
    mysql> UPDATE example_timestamp
    SET data='The current timestamp is: '
    WHERE id=1;
    mysql> SELECT * FROM example_timestamp;
    | id | data | Date_Time |
    | 1 | The current timestamp is: | 2012-06-28 12:38:55 |
    Regards,
    Yogesh.

    Is there no functionality in oracle to auto update date column without using trigger??
    I dont want to update the date column in UPDATE statement.
    The date column should automatically get updated when ever i execute an Update statement.

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

  • 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

  • Drill down in Table or Pivot for derived column

    Hi All,
    I have a requirement like Top 5 products should show the product names and remaining should go to *'Others'*. I achieved it by using Rank function and case when.
    ex: case when rank(product) <=5 then product else 'Others' end
    Now the problem is, I am not getting the Drill option for this column. When I use product column without case when or case when on same column like
    case when product = 'xyz' then 'abc' else product end. In this case drill is working.
    Can anybody suggest me to get the drill on the derived columns.
    Thanks in advance

    A similar thread was recently talked about here:
    In OBIEE charts, how do you make drill downs work on custom formulas?
    With a calculated column, you need to make sure the source query and destination query have the EXACT same formula and the same name for the field. If it is not 100% identical, it may not work correctly. (I typically use the NAVIGATE function to get to the second query rather than the Drill function.)
    Now in some cases, if you try to create a second drill down query with more details in it, the original formula doesn't work the way you want it to. The calculated formulas have to make sense in both source query and destination query in order to work properly. If you have a ranking of the Top 5 Products in the source query, the destination query also has to have the same ranking of Top 5 products in order to work. If you add more fields into the destination query (e.g., adding on product attributes, or # of records associated with that product name etc.), then sometimes the ranking / aggregation in the destination doesn't add up the same way. This causes the system to think that the formulas are different and prevents the drill down.
    I managed to get around this by having a 3rd query in between the original summary view and the detailed data view. So the sequence would be (for example):
    - Dashboard based summary query (including the calculated ranked product names formula)
    - drill down into virtually identical query (add on one slight bit of difference here, for example adding on a second Product Name field ... not a calculated version, but the actual name). Create a drill down this time by clicking on the regular Product Name field (don't drill down on the custom formula)
    - final detailed drill-down query
    You can format this intermediary drill down query to explain to users that they need to click a second time.
    It's not ideal, but it should work. Hope this helps.
    Ted

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

  • 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

  • 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

  • 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

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

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

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

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

Maybe you are looking for