Re: [sqlite] Check if file exists in SQL syntax?

2014-10-11 Thread Krzysztof
Thanks Keith!

2014-10-11 2:01 GMT+02:00 Keith Medcalf :
>
> You do not say what operating system, but for example, on Windows, the 
> following function works:
>
> SQLITE_PRIVATE void _GetFileAttributes(sqlite3_context *context, int argc, 
> sqlite3_value **argv)
> {
> sqlite3_result_int(context, 
> GetFileAttributesW(sqlite3_value_text16(argv[0])));
> }
>
> which is then declared to SQLite function interface (for connection db) thus:
>
> nErr += sqlite3_create_function(db, "GetFileAttributes", 1, 
> SQLITE_ANY|SQLITE_DETERMINISTIC,  0, _GetFileAttributes,0, 0);
>
> Returning the file attributes for the given pathspec, or -1 if it does not 
> exist.
>
>
> SQLite version 3.8.7 2014-10-09 15:08:17
> Enter ".help" for usage hints.
> Connected to a transient in-memory database.
> Use ".open FILENAME" to reopen on a persistent database.
> sqlite> select getfileattributes('D:\');
> 22
> sqlite> select getfileattributes('D:\momo');
> -1
> sqlite> select getfileattributes('D:\source\sqlite\sqlite3s.exe');
> 32
> sqlite> select getfileattributes('D:\source\sqlite');
> 16
> sqlite>
>
> You do similar on Unices just substitute the appropriate call to get the file 
> attributes ...
>
>>-Original Message-
>>From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
>>boun...@sqlite.org] On Behalf Of Krzysztof
>>Sent: Friday, 10 October, 2014 12:21
>>To: General Discussion of SQLite Database
>>Subject: [sqlite] Check if file exists in SQL syntax?
>>
>>Hi,
>>
>>I'm collecting file names (full paths) in sqlite table. Each day I
>>need to remove non existing files from this table (thousands records).
>>For now I'm selecting all records and then checking if file exists
>>using C++ routine and if not then deleting it. I'm wondering if SQLite
>>has such function (could not find it in core functions). For example I
>>would like to call something like:
>>
>>CREATE TABLE my_table {
>>  id INTEGER PRIMARY KEY,
>>  filename TEXT,
>>  tags TEXT
>>}
>>
>>DELETE FROM my_table WHERE NOT FileExists(filename)
>>
>>Regards
>>___
>>sqlite-users mailing list
>>sqlite-users@sqlite.org
>>http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Will someone be able to explain this weird outcome...

2014-10-11 Thread tonyp

Well, OK, but you attributed the quote to the wrong person. :)

-Original Message- 
From: Simon Slavin

Sent: Saturday, October 11, 2014 2:38 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Will someone be able to explain this weird outcome...


On 10 Oct 2014, at 9:27pm, to...@acm.org wrote:


sqlite> select "7,915" - "5,021";
2

But, would someone explain the result of 2?  Sorry for this child-like
question, but I can't find the how the result of 2 came to be displayed.


7 - 5 = 2

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users