Not with built-in facilities, AFAIK. Starting with version 10, you could use "directory access servers" (a special kind of proxy tables) to do so, and version 16 has introduced a bunch of file-related procedures. If you do know the possible file names, you could try to use xp_read_file to read the contents. However, in my tests that does not work to "read" directories. Ah, Breck was faster... Note that xp_read_file is server-based, i.e. the database engine needs to be allowed to access the files, which often requires particular permissions within a network.
(05 Mar '18, 11:23)
Volker Barth
Replies hidden
Comment Text Removed
> Breck was faster who? :)
(05 Mar '18, 12:09)
Breck Carter
Sigh, I should not use a mobile to answer questions... Reimer was the one I meant...
(05 Mar '18, 12:21)
Volker Barth
|
Once upon a time, there was Calling GetOpenFileName() From SQL I took a look at this option but decided against it after I read the 'Libertine answer'.
(06 Mar '18, 03:24)
Jongee
Replies hidden
Hm, IMHO Breck's point was not the particular Windows API function to open a file but to show how you can call API functions via the external call interface. That way you could also use C based POSIX functions like opendir() or FindFirstFile() from the WINAPI. Not easy, if you are not familiar with C, I guess, but doable...
(06 Mar '18, 06:13)
Volker Barth
|
Of course you can also use xp_cmdshell with an OS-level command to list files, here for Windows... -- Code snippet to use xp_cmdshell to list directory contents on Windows via DIR /b -- with output redirection for the file ("> ...") list or an error ("2> ..."). begin declare ret_code int; declare dir_list long varchar; declare err_desc long varchar; ' Hard coded pathes within the current users dir tree - list according PDF files ret_code = call xp_cmdshell('DIR /b C:\\Users\\MyName\\Documents*.pdf > C:\\Users\\MyName\\MyDirList.txt 2> C:\\Users\\MyName\\MyDirError.txt', 'no_output'); ' xp_cmdshell returns 0 for success and <> 0 otherwise if ret_code = 0 then set dir_list = xp_read_file('C:\\Users\\MyName\\MyDirList.txt'); ' one possible "error": no file is found else set err_desc = xp_read_file('C:\\Users\\MyName\\MyDirError.txt'); end if; select ret_code, dir_list, err_desc; end; There are more samples in this forum for xp_cmdshell... Note that the DIR command will both return an error for non-existing and empty directories. The error text will depend on the OS language. Of course you should delete the result files afterwards, probably by another use of xp_cmdshell... |
AFAIK there's no functionality in ASA9 to browse folder contents. Directory access servers were introduced with the following version, SA10.
Slightly OT: it would be possible to check for existence of a file using xp_read_file(<filepath>) and checking the result (NOT NULL if file exists and has size > 0).
I found reference to the xp_read_file function but as the documents are stored on a network, I am struggling to get this to work.