Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5942639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:16:56+00:00 2026-05-22T16:16:56+00:00

I’m trying to convert some Oracle stored procedures to MSSQL I did some basic

  • 0

I’m trying to convert some Oracle stored procedures to MSSQL I did some basic SP’s but I’m having a trouble converting SP’s with cursors.

here’s a example :-

create or replace procedure   PR_DELETE_FOLDER(indexedFolder NUMBER,indexedPath VARCHAR2,userCode VARCHAR2,folpath VARCHAR2,idpath VARCHAR2,folderid NUMBER) as


cursor c1(pfolid in NUMBER) is 
   SELECT folder.PARENTFOLDER, folder.FOLDERNAME, folder.FOLDERID ,sys_connect_by_path(folder.FOLDERNAME,'>>') FOLDERPATH , sys_connect_by_path(folder.FOLDERID,'>>') FOLDERIDPATH
   FROM T_FOLDER folder 
   START WITH folder.PARENTFOLDER =pfolid
   CONNECT BY PRIOR  folder.FOLDERID=folder.PARENTFOLDER;

cursor c2(folid in NUMBER) is SELECT DOCUMENTID,DOCUMENTNAME from T_DOCUMENT where folder = folid;

begin 
for r1 in c1(folderid) loop
      update T_FOLDER  set last_update=sysdate,STATUS=0 where folderid=r1.FOLDERID;
      update T_FOLDER set foldercount = foldercount-1 where folderid = r1.PARENTFOLDER;
     -- insert into T_FOLDER_AUDIT values(SEQ_FOLDER_AUDIT.nextval,r1.FOLDERID,'Delete a folder',userCode,sysdate,sysdate,userCode,userCode,1);
      insert into t_historical_event values(SEQ_HISTORICAL_EVENT.nextval,r1.FOLDERID,null,'com.affno.adms.folder.Folder',null,'Updated',userCode,r1.FOLDERNAME,sysdate,sysdate,sysdate,userCode,userCode,1);

              for r2 in c2(r1.FOLDERID) loop

                update T_DOCUMENT set LAST_UPDATE = sysdate,ISUPDATEINDEXES=1,MODIFIEDBY=userCode,STATUS=0 where documentid = r2.DOCUMENTID;
                update T_FOLDER  set doccount=doccount-1 where folderid=r1.FOLDERID;
                insert into T_DOCUMENT_AUDIT values(SEQ_DOC_AUDIT.nextval,'delete',r2.DOCUMENTID,'Original',sysdate,sysdate,userCode,userCode,1,userCode);
                insert into t_historical_event values(SEQ_HISTORICAL_EVENT.nextval,r2.DOCUMENTID,null,'com.affno.adms.document.Document',null,'Deleted',userCode,r2.DOCUMENTNAME,sysdate,sysdate,sysdate,userCode,userCode,1);

              end loop;

end LOOP;

end;  

I’m not familiar with MSSQL cursors so I got no clue on this issue.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T16:16:56+00:00Added an answer on May 22, 2026 at 4:16 pm

    There are examples in the msdn article:
    DECLARE CURSOR (Transact-SQL)

    USE AdventureWorks2008R2;
    
    GO
    DECLARE vend_cursor CURSOR
        FOR SELECT BusinessEntityID, Name, CreditRating FROM Purchasing.Vendor
    OPEN vend_cursor
    FETCH NEXT FROM vend_cursor;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.