Re: PL/SQL host commands in a loop

From: DanHW <danhw_at_aol.com>
Date: 28 Apr 1999 01:30:54 GMT
Message-ID: <19990427213054.09262.00000399_at_ng-cm1.aol.com>


>
>I wondered if someone could point me in the right direction on this
>one? I'm trying to write a procedure that writes a set of directories
>to a set of text files (under Windows NT) using the following loop:
>
>while direc <= max_direc loop
>host ('dir /b c:\brieven\'||to_char(direc)||'
>>c:\'||to_char(direc)||'.txt');
>direc := direc + 1;
>end loop;
>
>I'm a bit puzzeled as to why the host command fails within the loop
>but works perfectly outside it or in a SQL file. The type of loop
>construciton seems to be immaterial and the same thing happens if you
>put an alert after the host call to give it time to execute.
>
>Actually, the whole issue of getting data between the host and PL/SQL
>seems problematic. Are there any good resources (books, web sites) I
>can go to in order to get some answers?

From your snippet, itr is not clear if yiu initialize 'direc'. If you do not, then it is NULL the first time the loop condition is tested, which will not be <= max_direc, so nothing will be done.

I tried doing a host from NT, and had much better success if I did the command like this:
'cmd dir /b....', rather than just 'dir /b...'

In addition, you can put an option (I think it is either /k or /c) that will keep the window open after the command executes (the other closes it). From this you might be able to see the problem.

HTH
Dan Hekimian-Williams Received on Wed Apr 28 1999 - 03:30:54 CEST

Original text of this message