The forum will be down for maintenance over the weekend of August 18-20, 2017. The forum will be shut down on the evening (EDT) of Friday, August 18. Downtime is unknown but may be up to two days. The forum will be restarted as soon as maintenance is complete.

Hello,

i need a sql statement to count files in a folder strukture

this should be the result Startpath is users Folderpath ;Filecount /Users/miller ; 5 Files /Users/miller/test ; 20 Files /Users/smith/ ; 664 Files

asked 18 Sep '13, 09:26

emil123's gravatar image

emil123
1111
accept rate: 0%

sorry, i need a DQL (like SQL) skript with direct output without a file.

(19 Sep '13, 07:02) emil123
Replies hidden
2

I don't understand your point:

Both suggestions offer a SQL statement to build a normal result set (and with directory access servers, you will need some more statements to set up the according proxy table, as Reimer has shown). They don't output to a file.


In case your question doesn't deal with SAP Sybase SQL Anywhere but with PHP/Doctrine/DQL, then I guess you're asking in the wrong forum...

(19 Sep '13, 08:41) Volker Barth

Have a look at "Directory access servers" SA12 DCX. Using CREATE SERVER, CREATE EXTERNLOGN and CREATE EXISTING TABLE you will be able to scan the folder (and subfolders, if specified). Example:

CREATE SERVER "FolderSample" CLASS 'DIRECTORY' USING 'ROOT=C:/Users;SUBDIRS=1;CREATEDIRS=NO;READONLY=YES';
CREATE EXTERNLOGIN "dba" TO "FolderSample";

CREATE EXISTING TABLE "sirius"."UserDir" (
    "permissions" VARCHAR(10) NOT NULL,
    "size" BIGINT NOT NULL,
    "access_date_time" "datetime" NOT NULL,
    "modified_date_time" "datetime" NOT NULL,
    "create_date_time" "datetime" NOT NULL,
    "owner" VARCHAR(20) NOT NULL,
    "file_name" VARCHAR(260) NOT NULL,
    "contents" LONG BINARY NOT NULL
) AT 'FolderSample;;;.';

select file_name from UserDir where file_name like '%.csv'

permanent link

answered 18 Sep '13, 11:59

Reimer%20Pods's gravatar image

Reimer Pods
4.2k334583
accept rate: 11%

edited 18 Sep '13, 15:00

When using SA 16, you would prefer to use the brand new Directory and file system procedures, particularly the sp_list_directory system procedure.

permanent link

answered 18 Sep '13, 12:04

Volker%20Barth's gravatar image

Volker Barth
30.9k309457667
accept rate: 33%

edited 18 Sep '13, 12:05

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×20

question asked: 18 Sep '13, 09:26

question was seen: 1,068 times

last updated: 19 Sep '13, 08:53