Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 15264

SQLSERVER Function with cursor

$
0
0

Hi All,

Am basically from oracle, i have a function with cursor here i have created in oracle. May you please help me in modifying this into sqlserver. FUNCTION fun_din (id IN NUMBER, dim IN VARCHAR2 DEFAULT ' < ')
RETURN VARCHAR2
IS
  param varchar2(2000);
  cursor c1 is 

  select name
  from (select id, inf
        from task
        start with id = pid
        connect by prior pid = id) ids
        left join info on task.id = info.inf;

BEGIN

  for c2 in c1 
  loop
    if length(param) > 0 then
      param := dim || param;
    end if;

    param := c2.dim || param;
  end loop;


Viewing all articles
Browse latest Browse all 15264

Trending Articles



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