Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Query Question, Need Help ASAP!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
manmit.walia@gmail.com - 22 Jul 2007 17:58 GMT
Hello Fellow Members,

Background:

Hopefully someone out there can help me. Here is the situation. I have
a documents table which stores "documents". A document can either be a
folder or a actually document(word, excel ...). This is determined by
a field in the table called 'Type' which is either a '0' or '1'

The table stores the following data for each 'document'
--------------------------------------------------------------------------------
DocID - int
Document - Actual document in bytes
LeafName - Actual document name
Type - Determines type of document (0 - document, 1- folder)
DirName - Which folder the document resides in (can be null)

Problem:

I want to create a query which navigates through the entire table and
deletes all documents. For example, if a user has a folder called
(Temp) and that folder has 30 documents and another folder called
(Temp2) that also has documents. Now the user wants to delete (Temp).
So what I want the query to do is go through the database and delete
then entire folder (Temp) and all of its contents associated with it.

Question:

How can I traverse through the table to delete the documents?

All of your help would be greatfull.

VLead Consulting, Inc.

http://www.vleadconsulting.com
Sergey Poberezovskiy - 23 Jul 2007 03:28 GMT
Hi,

I do not believe that could be done in one query - the number of levels
below your Temp folder is unknown. You will need to open a cursor (or
equivalent - depending on the database) and walk down your hierarchy tree,
removing content of every subfolder level separately.

> Hello Fellow Members,
>
[quoted text clipped - 31 lines]
>
> http://www.vleadconsulting.com
rival@newsgroups.nospam - 23 Jul 2007 15:02 GMT
Although I hate to say it (because I hate them with a passion), using a
database trigger may be the answer.  I'm assuming you're using SQL Server.  
Create a delete trigger for the table which when you are deleting a folder
will fire to delete all the folders and documents where the DirName is the
name of the folder you are deleting.

> Hello Fellow Members,
>
[quoted text clipped - 31 lines]
>
> http://www.vleadconsulting.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.