Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

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

$
0
0
    • I have below oracle query need to converted to ms sql. I also want to add a record into journal table when a 
  1.  insert portion is executed  "caseidinserted" and update portion executed then "caseidupdate".
  2. 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()


    Viewing all articles
    Browse latest Browse all 23857

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>