Home » SQL & PL/SQL » SQL & PL/SQL » CURSOR or resultset or what?
CURSOR or resultset or what? [message #2372] Wed, 10 July 2002 02:06 Go to next message
Andy Rayne
Messages: 1
Registered: July 2002
Junior Member
Hi,

I am a java guy and PL/SQL newbie. I am trying to create a windows explorer type movefile functionality in a procedure.

A quick overview of what im trying to do as you may know a better tried and tested method?

I am moving a source folder up a tree to a target folder. In the case that the target folder has a matching name of subfolder to the source folder the files inside the matching targtet subfolder are overwritten and the non matching file names are simply added to the target sub folder. In the case that the target matching subfolder has matching subfolders then the same process is repeated.

The stumbling block i have hit is i need to select all the items in the source folder. Then form there i need to select all of those items which are files.

I did have the following:

/*select the elements in the source folder.*/
OPEN source_folder_item_ids;

/*select the names of all the files in the source folder*/

FOR File_id in source_folder_item_ids LOOP
CURSOR source_folder_files IS SELECT name, id
FROM File WHERE XFile.id = File_id;
END LOOP;

However as i now know you cant declare a cursor after BEGIN, or can you?

Well i hope its kind of clear what im trying here. In java i would have a resultset to play with and all would be well. Id that the problem though? I am using a java brain?

If anyone has any ideas i'd be delighted to hear them.

Thanks

Andy
Re: CURSOR or resultset or what? [message #2375 is a reply to message #2372] Wed, 10 July 2002 05:26 Go to previous message
Epe
Messages: 99
Registered: March 2002
Member
Hello,

if you ever succeed in moving folders using only PL/SQL, please let me know how !!! As far as I know, PL/SQL is used to access databases...

Anyway, in PL/SQL a program has the following structure :
DECLARE
...
BEGIN
...
END;
You declare a cursor within the declare block, and open it, loop through it and close it between the begin and end.
Using your cursor it would become something like this :
DECLARE
cursor source_folder_files is
select name, id
from file; /*I don't understand your where-clause*/
BEGIN
for i in source_folder_files loop
....
end loop;
END;

Instead of "for i in source_folder_files..." you can
also use "open cursor source_folder_files...", but for details on this matter you better check the (online) Oracle Manuals...

Have fun,

Epe
Previous Topic: Ora Error 1654
Next Topic: constraint question
Goto Forum:
  


Current Time: Fri Apr 26 17:44:20 CDT 2024