Convert decode oracle pl/sq to ms sql and help required on logic

I have below oracle query need to converted to ms sql. I also want to add a record into journal table when a 
 insert portion is executed  "caseidinserted" and update portion executed then "caseidupdate".
Update table1 target
set curr =
decode(
    select efforts from (
    select source.efforts efforts
      from
        SELECT     a.aid,a.efforts,ab.lcs
            FROM     CIP a, DC ab
            WHERE    a id = ab.id
            AND    a.id = @id
      ) source
      where target.caseid = @caseidupd
      and target.aid = source.aid
    ) tmp, 0, tmp.efforts, curr
modi = getdate( )
where exists
select 1
from table1 tgt
where tgt.aid = target.aid
and tgt.caseid = @caseidupd
insert into table1 values(caseid, aid, modi)
    select @caseidupd, source.aid, getdate()
      from
        SELECT     a.aid,a.efforts,ab.lcs
            FROM     CIP a, DC ab
            WHERE    a id = ab.id
            AND    a.id = @id
      ) source
    where not exists
        select 1
        from table1 target
        where target.aid = source.aid
        and target.caseid = @caseidupd
something like this...
INSERT (caseid,aid,modi)
 select @caseidupd,'appupdated'+source.aid,getdate()
 INSERT (caseid,aid,modi)
  select (@caseidupd,'appinserted'+source.aid,getdate()

Hello,
I am not familiar with Oracle Function. If I understand correctly, you can MERGE to perform INSERT and UPDATE operations on a table in a single statement. Please refer to the following statements:
MERGE INTO table1 AS Target
USING (select @caseidupd, source.aid, getdate()
from
SELECT a.aid,a.efforts,ab.lcs
FROM CIP a, DC ab
WHERE a id = ab.id
AND a.id = @id
) As Source (caseidupd,aid,date )
ON Target.aid = source.aid and target.caseid =source.caseidupd
WHEN MATCHED THEN
UPDATE SET Target.curr=...,--query for get values
Target.modi=getdate()
WHEN NOT MATCHED BY TARGET THEN
INSERT (caseid,aid,modi) values (caseidupd,'appupdated'+source.aid,getdate())
Reference:http://msdn.microsoft.com/en-us/library/bb510625.aspx
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support

Similar Messages

  • Oracle AS connect to MS SQL server - help please.

    hi there
    can anyone tell or show me how to connect Oracle app server to MS sql server? thanks

    Hi Tom,
    For stand-alone OC4J (any version), you need to add an appropriate entry to the "data-sources.xml" file (in the "j2ee/home/config" subdirectory) and put the JDBC driver file(s) into the "j2ee/home/lib" subdirectory. On my OC4J 9.0.3 distribution (on my Windows XP machine), there already is a "ms-sql.xml" file in the "j2ee/home/config/database-schemas" subdirectory. If you don't have one, then you may need to create one, or if you do already have one, you may need to modify it. More information can be found at these Web sites:
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.atlassian.com
    http://www.elephantwalker.com
    Hope this helps you.
    Good Luck,
    Avi.

  • Importing 30 tables into one SQL Table (Help Required)

    Dear Experts,
    I am new in SQL server, actually i need to gather 30 different excel file in one sql server table and i have imported all excel file in different databases, all tables have 186 different columns and datatypes. I couldnt change data type while conversion.
    Now all columns have different data type which are occupying extra space in my database.
    Now the problem is that i need to convert all databases into one database or table. Although i have created a table but i dont have idea how to import all table into one table  and defining datatype in new table while importing the old tables.
    Please help me in this matter or if any body has skype or any other chatting id please do let me know so that i may explain it better.
    Thanking you in advance.
    Best Regards,
    SQL_beginner

    There are several things you can try.  If you have SSIS, take a look at this.
    http://www.singhvikash.in/2013/06/ssis-how-to-load-multiple-excel-files.html
    https://www.simple-talk.com/sql/ssis/importing-excel-data-into-sql-server-via-ssis-questions-you-were-too-shy-to-ask/
    Also, if your files have virtually the same name, like files with dates in the name, you can loop through files in your folder, and increment the loop with each run through.
    DECLARE @intFlag
    INT
    SET @intFlag
    = 1
    WHILE (@intFlag
    <=30)
    BEGIN
    PRINT @intFlag
    declare @fullpath1
    varchar(1000)
    select @fullpath1
    = '''\\path to your files\'
    + convert(varchar,
    getdate()- @intFlag
    , 112)
    + '_your-text-file-name.txt'''
    declare @cmd1
    nvarchar(1000)
    select @cmd1
    = 'bulk insert [dbo].[your-table-name] from '
    + @fullpath1 +
    ' with (FIELDTERMINATOR = ''\t'', FIRSTROW = 2, ROWTERMINATOR=''0x0a'')'
    exec (@cmd1)
    SET @intFlag
    = @intFlag + 1
    END
    GO
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • Dynamic PL/SQL - Urgent help required

    Hi there
    I am trying to write a packaged function which takes the table name and column name as arguments and build a pl/sql table which the function returns.
    Please do find the code below:
    Create or Replace Package Pk_valid_values
    is
    TYPE list_rec is record ( lc_list_desc varchar2(50));
    TYPE list_tab is TABLE of list_rec
    index by binary_integer;
    FUNCTION Fn_fetch_values
    ( p_table_name varchar2,
    p_column_name varchar2 )
    return list_tab;
    End Pk_valid_values;
    Create or Replace Package Body Pk_valid_values
    as
    FUNCTION Fn_fetch_values
    ( p_table_name varchar2,
    p_column_name varchar2 )
    return list_tab
    is
    l_values Pk_valid_values.list_tab;
    i binary_integer := 0;
    lc_element varchar2(50);
    ln_dummy number;
    v_cursor integer;
    lc_string varchar2(2000);
    ln_count number;
    BEGIN
    ln_count := Pk_count_record.Count_record(p_table_name);
    v_cursor := dbms_sql.open_cursor;
    lc_string := 'begin select p_column_name into :felement from '||
    p_table_name||' ; end;';
    dbms_sql.parse( v_cursor,
    lc_string,
    dbms_sql.native );
    dbms_sql.bind_variable( v_cursor,
    ':felement',
    lc_element );
    ln_dummy := dbms_sql.execute( v_cursor );
    for i in 1..ln_count loop
    dbms_sql.variable_value( v_cursor,
    ':felement',
    lc_element );
    l_values(i) := lc_element;
    end loop;
    dbms_sql.close_cursor( v_cursor );
    return( l_values );
    END Fn_fetch_values;
    End Pk_valid_values;
    I get an error "PLS-00382: expression is of wrong type" when I try to create this package.
    Could anyone please let me know where I have gone wrong?
    I have really burst my heads against this.
    Thanks in advance
    Rajeev

    Hi,
    I think it is that you declare a PL/SQL block, not a cursor.
    Try to replace :
    lc_string := 'begin select p_column_name into :felement from '||
    p_table_name||' ; end;';
    with :
    lc_string := 'select ' || p_column_name || ' from ' || p_table_name;
    Or an easier way :
    declare
    TYPE RefCurTyp IS REF CURSOR;
    cr RefCurTyp;
    lc_element varchar2(50);
    begin
    OPEN cr FOR 'select ' || p_column_name || ' from ' || p_table_name;
    LOOP
    FETCH cr INTO lc_element;
    EXIT WHEN cr%NOTFOUND;
    END LOOP;
    CLOSE cr;
    end;
    /Uffe

  • Pl/sql  code  help required

    i have 3 string like below
    string1  varchar2(3000) := ' fonction code=''33'' and the limit for the subfunction is 300. it may have function_code=''100'' ) ) ) )';
    string2  varchar2(2000):='function_code=''100''';
    string3  varchar2(3000);requirement is
    if i found string2 in string1 preceded by four brackets ,example function_code=''100'' ) ) ) )' then
    i have replace to replace the 4th bracket with
    function code is null  )the string1 now will be
    ' fonction code=''33'' and the limit for the subfunction is 300. it may have function_code=''100'' ) ) ) function code is null  )Pls help
    NOte: bracket may or may not have spaces between them
    S

    SQL> declare
      2  string1  varchar2(3000) := 'AND NOT  (     (       (   FUNCTION_CODE = ''88''  )  OR  (   FUNCTION_CODE = ''21''  )  OR  (   FUNCTION_CODE = ''51'' )  OR  (   FUNCTION_CODE = ''85'' )  )  )  )' ;
      3  string2  varchar2(2000):='FUNCTION_CODE = ''85''';
      4  string3  varchar2(3000);
      5  begin
      6  string3 :=regexp_replace(string1,'^(.*)('||string2||')(([[:blank:]]?\)[[:blank:]]?){3})([[:blank:]]?\))(.*)$','\1\2\3function code is null\4\5');
      7  dbms_output.put_line(string3);
      8  end;
      9  /
    AND NOT  (  (  (   FUNCTION_CODE = '88'  )  OR  (   FUNCTION_CODE = '21'  )  OR  (   FUNCTION_CODE = '51' )  OR  (
    FUNCTION_CODE = '85' )  )  ) function code is null )  )
    PL/SQL procedure successfully completed.Best regards
    Maxim

  • Some help required with logic for a dynamic sql query

    i have below code but not sure how to resolve this problem - what i need is to be able to dynamically
    the problem:
    i have a rabbge of paratmeters coming in from a form and need to be able to create a dynamic query string to go into a prepared statement object.
    the problem i have is there are 2 fields year range and year.
    if year range is none i need to create the query string as such :
    where the value of year can be serached on exactly
    str.append("VOLUME_YEAR = ? ");the probelm is if the year range is 5 or year range is 10 i dont know how to maipulate the query string to be able to set the string such that i can then place the year value in the place holder in preparedStatement.setInt(1, year)
    how can i create the intial query string ie.- what are the possible things that i can do. - i'm thinking of things like putting some type of between or such type query statement - but not at all sure how the syntax would go - ie. how would i use the year value and how would i create this dynamic part of the query string so that the JDBC regonises it?
    thanks for any help.
    public String setVolumeYearQuerySt(String year, String yearRange, StringBuffer str){
              String volumeYearQueryString = null;
              Sring doAction= null;
              if (yearRange.equals("None")){str.append("VOLUME_YEAR = ? ");}
              else if(yearRange.equals("5 Years")){doAction = "Nothing";}
              else if (yearRange.equals("10 Years")){doAction = "Nothing";}
              return volumeYearQueryString;
              }

    Saish - thanks a lot for the code example.
    Although, i think its far too advanced for me to understand and try to manipulate it and fit my problem. I'm pretty new to programming as you can probably see from my simple if else type statements. But i'm going to give it a try and see how it goes.
    could you please be kind enough to demonstrate how i could use the above syntax to do the following. --
    i have a year being entered in form .  in the database there is a column year volume which contains year in single year value format and also in a year range  value format - thus as in below - how could i do this -
    eg.
    user can enter a value in the year field a single value or a range value - then he can select +/-5 or 10 yrs range on that value - the DB holds the values as single values and ranges as below -
    one suggested apporach is as follows if a single user is alloweed to enter only a single value in the filed and select a query range +/- 5 etc..
    volume year of �1926-1928� and the user enters �1927�, the query has to find all records where
    look for records that are �less than or equal to� 1927.  It then has to check to see if it contains a range.  For those that it finds containing a range, it has to work out what the �upper� year is and check to see if that is �greater than or equal� to 1927.  If it is, then that is a possible matchanother approach that is suggested is to have a drop down with all years from databse and user is only llowed to select value from drop down and following logic is suggested :
    Because volumes can be received as ranges (e.g. 1964-1966), some extra coding is required where the user asks for a Year Range (such as + or � 5).
    Using the Year selected from the dropdown list, split it into 2 values, a low year and a high year. For example, if �1965-1968� is selected from the year dropdown, split it into �1965� and �1968� for the low year and high year respectively. If �1964� is selected from the year dropdown, split it into �1964� and �1964�. Now take the Year Range that the user has entered into account. For example, if the user has entered 5, subtract 5 from the low year and add 5 to the high year. Using these values, include the following search criteria in the query to the database:-
    (<low year>     BETWEEN
                 left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
         AND     right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1))
    OR     (<high year>     BETWEEN
                 left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
         AND     right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1))regards - i think if i could solve the first approach that would be something good as its most user freindly
    thanks

  • SQL Loader Help required

    HI Team,
    I have requirement to load data in to table using sqlloader, as i am having three level's(Header, Detail, Trailer')
    first two position of data file represents the level like
    00-Header
    01 to 98 -Detail
    99 -Trailer
    each level will have different data structure and we should insert in to the same table
    i Have created table like
    CREATE TABLE APPS.XXD_TEST1
    AA NUMBER,
    TEST12 VARCHAR2(10 BYTE),
    testdt VARCHAR2(10 BYTE),
    testtr VARCHAR2(10 BYTE),
    RECORD_ID NUMBER
    and created sequence for record_id column
    --CREATE SEQUENCE APPS.XXD_TEST1_S
    i have data in the data file like below, i want to load the data in the same order
    000012
    010012
    010012
    020012
    030012
    990012
    000013
    010013
    020013
    030013
    990013
    i was using the folowwing control file
    LOAD DATA
    INFILE Test
    APPEND
    INTO TABLE xxd_test1
    WHEN (1:2) = '00'
    TRAILING NULLCOLS
    test12 POSITION(3:6) CHAR,
    aa POSITION(1:2) INTEGER EXTERNAL "lpad(:aa,2,'0')",
    record_id "xxd_test1_s.nextval"
    INTO TABLE xxd_test1
    WHEN (1:2) != '99' and (1:2) !='00'
    TRAILING NULLCOLS
    testdt POSITION(3:6) CHAR,
    aa POSITION(1:2) INTEGER EXTERNAL "lpad(:aa,2,'0')",
    record_id "xxd_test1_s.nextval"
    INTO TABLE xxd_test1
    WHEN (1:2) ='99'
    TRAILING NULLCOLS
    testtr POSITION(3:6) CHAR,
    aa POSITION(1:2) INTEGER EXTERNAL ,
    record_id "xxd_test1_s.nextval"
    But it was inserted in the following order
    000012
    000013
    010012
    010012
    020012
    020013
    030012
    030013
    990012
    990013
    Please help me with the solution.
    Thanks
    Sriram.

    Hi Karthick,
    we can do the order by caluse if we are having any column common to all the three levels
    here, for me record_type(first two positions) is the only common. but they may be duplicated in the file.
    Sample Data file
    000012
    01
    01
    02
    03
    99
    000013
    01
    02
    03
    99
    (first two positions represent the heirarchy like 00-header,(01-10)-Detail, 99-Trailer)
    this is sample file,it(detail,trailer) contains some extra fields also...but nothing is common to the header, detail and trailer.Can we generate any value which is common to the three levels? with respective to the header value!
    Looking for you solution..
    Regards,
    Sriram.

  • SQL Join help required!

    Hi all
    I need help with a join.
    If you click the image link below, I need to find a way to join table 1 and table 2 to get table3:
    http://img229.imageshack.us/img229/1401/83192078uq8.jpg
    Help would be very much appreciated!
    Thanks in advance.

    with Table1 as(select 1234 as ProjectID,'Smith' as LastName from dual
    union select 1234,'Maria' from dual
    union select 1234,'Victo' from dual),
    Table2 as (select 1234 as ProjectID,200 as Val from dual
    union select 1234,300 from dual
    union select 1234,400 from dual)
    select nvl(a.ProjectID,b.ProjectID) as ProjectID,a.LastName,b.Val
      from Table1 a full join Table2 b
        on 1=0;
    PROJECTID  LASTN  VAL
         1234  Maria  null
         1234  Smith  null
         1234  Victo  null
         1234  null    200
         1234  null    300
         1234  null    400

  • Oracle XML Parser for PL/SQL - troubles with charset

    Hi,
    I'm using Oracle XML Parser for PL/SQL and have some troubles with charset of results xmldom.writeToBuffer and xmldom.writeToCLOB procedures.
    Some tags in my DOM documents contain text values in RUSSIAN (server nls_charset is CL8ISO8859P5). When I write document in varchar2 variable, buffer content is in UTF8 charset ( convert UTF8->CL8ISO8859P5 -OK).
    xmldom.setCharset(doc, 'ISO-8859-5') just after xmldom.newDOMDocument has no effect.
    xmldom.setCharset(doc, 'CL8ISO8859P5') has no effect also.
    Explicit charset direction in third parameter of
    xmldom.writeToBuffer and xmldom.writeToCLOB procedure has no effect.
    When I write document in CLOB, and then read part of CLOB in varchar2 buffer - result contain '?' in place of all russian text characters.
    What's a problem?
    How can I force XML Parser write XML in server charset?
    Oracle XML Parser for PL/SQL v 1.0.2

    I have the same problem. But in my case I am allowed only to use XML Parser for PL/SQL.
    Characterset 'WE8ISO8859P1' is used. And the language is latvian.
    After parsing a XML document and printing its contents, all latvian characters are replaced by "f".
    xmldom.setcharset(doc,'WE8ISO8859P1') has no effect.

  • Need a function name for Sql and Oracle

    Retrieving value of next line by doing opteration in previous row.

    Can you rephrase the question? Or better yet, provide an example? I'm not sure I understand what you are asking.
    My best guess is that you are looking for the analytic functions LEAD or LAG in Oracle, assuming you are on a relatively recent Oracle version. If by "SQL and Oracle" in your subject you mean "SQL Server and Oracle" (SQL is a language that all relational databases implement, SQL Server is Microsoft's relational database), I have no idea how (or if) you can do something similar with a built-in function in SQL Server. You would want to post in a SQL Server group to see how they handle that sort of thing.
    Justin

  • (SQL*PLUS HELP) RUNNING PUPBLD OR HELPINS ASKS FOR SYSTEM_PASS

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-22
    (SQL*PLUS HELP) RUNNING PUPBLD OR HELPINS ASKS FOR SYSTEM_PASS
    ==============================================================
    PURPOSE
    이 내용은 SQL*Plus 상에서 SQL*Plus command의 help를 보기 위한 방법이다.
    Problem Description
    SQL*Plus command의 help를 보기 위해서 helpins를 수행하면
    SYSTEM_PASS is not set이라는 에러 메시지가 발생하는 경우가 있다.
    이 자료는 pupbld 또는 helpins를 수행하기 전에 SYSTEM_PASS 환경변수를
    셋팅하는 방법에 대한 자료이다.
    아래와 같은 에러가 발생하는 경우 조치 방법에 대해 알아본다.
    SYSTEM_PASS not set.
    Set and export SYSTEM_PASS, then restart help (for helpins or
    profile for pupbld) installation.
    Workaround
    none
    Solution Description
    이 스크립트는 system user로 database에 connect되어 수행되어야 한다.
    helpins를 수행하기 위해서는 SYSTEM_PASS 환경변수가 셋팅되어 있어야 한다.
    NOTE
    For security reasons, do not set this variable in your shell
    startup scripts. (i.e. .login or .profile.).
    Set this environment variable at the prompt.
    1. Prompt에서 환경변수를 셋팅하기
    For C shell:
    % setenv SYSTEM_PASS system/<password>
    For Korn or Bourne shells:
    $ SYSTEM_PASS=system/<password> ;export SYSTEM_PASS
    2. Now run "$ORACLE_HOME/bin/pupbld" or "$ORACLE_HOME/bin/helpins".
    % cd $ORACLE_HOME/bin
    % pupbld
    or
    % helpins
    주의사항
    $ORACLE_HOME/bin/pupbld 스크립트와 $ORACLE_HOME/bin/helpins 스크
    립트를 수행하기 위해서는 반드시 SYSTEM_PASS 환경변수를 필요로 한다.
    Reference Document
    <Note:1037075.6>

    check it please whether it is a database version or just you are installing a client. Install Enterprize database on 2k system. I you are running a client software then you are to deinstall it.

  • DB LINK Oracle to SQL Server SQL Server TimeStamp converts to Oracle Date

    Hi All,
    I have created a DB link between Oracle 10g 10.2.0.5 to SQL server 2005 using Oracle 11g gateway. When I execute a query from Oracle that selects data from SQL server using the DBLINK then the column value of type Timestamp from SQL server gets converted to Date data type in Oracle and it losses the time value.
    Is there some way (in gateway configurations or in select query sql ) that the SQL server data type Timestamp gets converted to Oracle's Timestamp?
    Please help.
    Best Regards!
    Irfan
    Edited by: irf_mas on Mar 13, 2012 3:23 AM

    You're getting the ORA-2070 error as the gateway that you are using is not supporting the to_timestamp function in this context. You need to rewrite the code.
    Best would be if you first check out the data format that is sent as a string when you just select the date column - for example:
    data_create_dt
    Jan 11 2012 1:40PM
    Now the easiest way is to make sure the format you are using in your where clause matches the string from the SQL Server:
    select * from "data_ms_view"@FREETDS_DG4ODBC_EMGTW_11_2_0_3 where "data_create_dt"<'Jan 11 2012 1:41PM';
    which will result in:
    data_create_dt
    Jan 11 2012 1:40PM
    BTW,
    it works with all formats the SQL Server understands:
    SQL> select * from "data_ms_view"@FREETDS_DG4ODBC_EMGTW_11_2_0_3 where "data_create_dt">'11-JAN-12 01.40.00.000000000 AM';
    data_create_dt
    Jan 11 2012 1:40PM
    Another way using binds:
    SQL> variable datum varchar2(26);
    SQL> exec select to_char(systimestamp,'MON dd yyyy hh:mi') into :datum from dual;
    PL/SQL procedure successfully completed.
    SQL> print datum
    DATUM
    MAR 19 2012 08:29
    SQL> select * from "data_ms_view"@FREETDS_DG4ODBC_EMGTW_11_2_0_3 where "data_create_dt" <:datum;
    data_create_dt
    Jan 11 2012 1:40PM
    There are several ways to get a result, just make sure you don't use an unsupported function in your statement. A list of supported functions is found in the manual.

  • How to convert Oracle User defined datatype to SQL Server 2014 using SSMA Version 6.0

    I am trying to convert Oracle 11g OE schema to SQL Server 2014, using SSMA version 6.0
    Getting an error in converting the Oracle View to SQL Server
    CREATE OR REPLACE VIEW OC_CUSTOMERS OF OE.CUSTOMER_TYP WITH OBJECT IDENTIFIER (customer_id) AS
    SELECT c.customer_id, c.cust_first_name, c.cust_last_name, c.cust_address,
               c.phone_numbers,c.nls_language,c.nls_territory,c.credit_limit,
               c.cust_email,
               CAST(MULTISET(SELECT o.order_id, o.order_mode,
                                   MAKE_REF(oc_customers,o.customer_id),
                                   o.order_status,
                                   o.order_total,o.sales_rep_id,
                                   CAST(MULTISET(SELECT l.order_id,l.line_item_id,
    l.unit_price,l.quantity,
    MAKE_REF(oc_product_information,
    l.product_id)
    FROM order_items l
    WHERE o.order_id = l.order_id)
                                        AS order_item_list_typ)
                             FROM orders o
                             WHERE c.customer_id = o.customer_id)
                    AS order_list_typ)
         FROM customers c
    *   SSMA error messages:
    *   O2SS0461: Conversion of object view is not supported.
    *   OF OE.CUSTOMER_TYP
    *      WITH OBJECT IDENTIFIER (customer_id)
    CREATE VIEW dbo.OC_CUSTOMERS
    AS
       /*Generated by SQL Server Migration Assistant for Oracle version 6.0.0.*/
       *   SSMA error messages:
       *   O2SS0481: Conversion of statement containing user defined type column 'c.cust_address' not supported.
       *   O2SS0481: Conversion of statement containing user defined type column 'c.phone_numbers' not supported.
       *   O2SS0430: Conversion of multiset conditions is not supported.
       *   CAST(MULTISET
       *      SELECT
       *         o.order_id,
       *         o.order_mode,
       *         MAKE_REF(oc_customers, o.customer_id),
       *         o.order_status,
       *         o.order_total,
       *         o.sales_rep_id,
       *         CAST(MULTISET
       *               SELECT
       *                  l.order_id,
       *                  l.line_item_id,
       *                  l.unit_price,
       *                  l.quantity,
       *                  MAKE_REF(oc_product_information, l.product_id)
       *               FROM order_items  l
       *               WHERE o.order_id = l.order_id
       *            ) AS order_item_list_typ)
       *      FROM orders  o
       *      WHERE c.customer_id = o.customer_id
       *   ) AS order_list_typ)
       SELECT
          c.CUSTOMER_ID,
          c.CUST_FIRST_NAME,
          c.CUST_LAST_NAME,
          c.cust_address,
          c.phone_numbers,
          c.NLS_LANGUAGE,
          c.NLS_TERRITORY,
          c.CREDIT_LIMIT,
          c.CUST_EMAIL,
          NULL
       FROM dbo.CUSTOMERS  AS c   */
    Any suggestion on converting this view would be helpful.
    Kind regards.

    Thanks Lydia Zhang for your reference urls.
    Please let me know if you come across any reference articles related to
    Creating a SQL Server table and View with columns as SQL Server TVP similar to Oracle UDT like
      CREATE TABLE "OE"."CUSTOMERS"
       (    "CUSTOMER_ID" NUMBER(6,0),
        "CUST_FIRST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_FNAME_NN" NOT NULL ENABLE,
        "CUST_LAST_NAME" VARCHAR2(20 BYTE) CONSTRAINT "CUST_LNAME_NN" NOT NULL ENABLE,
        "CUST_ADDRESS" "OE"."CUST_ADDRESS_TYP" ,
        "PHONE_NUMBERS" "OE"."PHONE_LIST_TYP" ,
        "NLS_LANGUAGE" VARCHAR2(3 BYTE),
    And also creating a SQL Server TVP inside an another SQL Server TVP as in Oracle
    create or replace TYPE customer_typ
     AS OBJECT
        ( customer_id        NUMBER(6)
        , cust_first_name    VARCHAR2(20)
        , cust_last_name     VARCHAR2(20)
        , cust_address       cust_address_typ
       , credit_limit       NUMBER(9,2)
        , cust_email         VARCHAR2(30)
        , cust_orders        order_list_typ
    NOT FINAL;
    Kind regards.
    Venkatesha

  • Converting Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis

    I could not able to convert Oracle TIMESTAMP(4) column to SQL datetime column conversion error in ssis.
    I'm connecting OLEDD Oracle Source to OLEDB SQL Destination in SSIS package. I'm trying to insert data from oracle datetime column into sql datetime column. I'm getting some errors.
    Please provide helpful info.

    You can transform the data types directly at the source by writing a proper SQL statement, or you can convert them using the data conversion component.
    Please refer the below link
    http://stackoverflow.com/questions/6256168/how-to-convert-a-timestamp-in-string-format-to-datetime-data-type-within-a-packa

  • Converting Decode to Case

    I'm a beginner with Oracle SQL and I have a select statement with the following code:
    max(decode(EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD, '1000', EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE, '2000', EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE, '4000', EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE))
    I've been asked to create several more columns in a similar manner. My concern is that since this relies on 'decode' which is less efficient than 'case', that adding more columns using this approach will bog down an already not efficient query. Bottom line my problem is that I don't really understand this 'decode' since all the explanations of 'decode' I've found stop at four parameters.
    Could someone please show me how the expression above looks in If-then-else terms as well as comment on how to convert this 'decode' to 'case'? Thanks in advance!

    1) The if-then-else stmt
    -- Longest way
    if EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '1000' then
    return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
    elsif EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '2000' then
    return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
    elsif EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '4000' then
    return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
    else return null;
    end if;
    -- shorter way
    if EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '1000' or
    EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '2000' or
    EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD = '4000' then
    return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
    else return null;
    end if;
    -- shortest if-then-else code
    if EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD in ('1000', '2000', '4000') then
    return value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE;
    else return null;
    end if;
    2) The MAX() function
    The MAX function will return the greatest value of EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE in step 1 above.
    2) Using CASE
    select
    max(case when (EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_CD in('1000','2000','4000'))
    then EDW.V_RECRUIT_TEST_RESULT_HIST.TEST_RESULT_TEST_SCORE end)
    into ...your_item_or_local_variable
    from EDW.V_RECRUIT_TEST_RESULT_HIST;
    Try the code above, good luck
    v/r
    Vien Tran

Maybe you are looking for

  • Why is playback video quality not as good as the source?

    Hi.  I'm not new to PrE but am new to the forum. I've been using PrE 2 for about 7 years.  I got a newer computer running Windows 7 and basically was forced to upgrade to PrE 12 because PrE 2 didn't run very well on the newer machine. Once I installe

  • Can I use  an external hard drive instead of replacing a defective one?

    I'm almost certain I need another hard drive; the current one has been installed less than a year. I'm experiencing regular kernel panics; i've done a clean reinstall. Can I use an external HD as my main drive? Other than the kernel issues, everythin

  • Corporate Directory not working

    We recently changed our DNS servers and the domain suffix used in our environment. We updated the new DNS suffix everywhere we found it. The problem that we have had since we made that change is that the Corporate directory won't come up on the phone

  • Datapump table import, simple question

    Hi, As a junior dba, i am a little bit confused. Suppose that a user wants me to import a table with datapump which he exported from another db with different schemas and tablespaces(He exported with expdp using tables=XX and i dont know the details.

  • Userexit to update purchase docs like sales orders

    Hi, For sales documents, there is a user exit MV45AFZZ which has lot of form routines, that get invoked before saving the sales document. Similarly for purchase orders which is the user exit include which will have such form routines. I want to modif