Date function accepts only DD for date string

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Date function accepts only DD for date string

Navaneeth K N
Hello,

select date('2013-11-04')  -> Works well
select date('2013-11-4')   -> Not working

Is there a way to make the second form working? Currently, I handle this
at the application side. If month/day is less than 10, then prefix it
with 0. But I'm wondering is there a better way to do this at the SQLite
side itself?

--
Cheers,
Navaneeth

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Date function accepts only DD for date string

Clemens Ladisch
Navaneeth K N wrote:
> select date('2013-11-04')  -> Works well
> select date('2013-11-4')   -> Not working
>
> Is there a way to make the second form working?

Only by inserting a zero into the string (which isn't easy
with the built-in SQL functions).


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Which constraint is being violating??

Rafa de Miguel
Hello all,

Is there a way to know which constraint is being violated when you receive
the message constraint error 19:

http://www.sqlite.org/c3ref/c_abort.html #define SQLITE_CONSTRAINT  19   /*
Abort due to constraint violation */

In example: my_column_name UNIQUE constraint

I'm using WebSQL

Thanks in advance!

Rafa

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Which constraint is being violating??

Clemens Ladisch
Rafa de Miguel wrote:
> Is there a way to know which constraint is being violated when you receive the message constraint error 19:
>
> In example: my_column_name UNIQUE constraint

Upgrade SQLite:

sqlite> create table t(x unique);
sqlite> insert into t values(1);
sqlite> insert into t values(1);
Error: column x is not unique

> I'm using WebSQL

Upgrade whatever implementation of WebSQL you're using.


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Which constraint is being violating??

Rafa de Miguel
Thanks Clemens,

I'm not sure how to do that.....

I'm using Google Chrome Version: 28.0.1500.52 which I think is the latest
stable version.

Do I have control about the WebSQL version or it's Chrome whom decide it?

Thanks in advance,

Rafa

El 04/11/13 09:30, Clemens Ladisch escribió:

> Rafa de Miguel wrote:
>> Is there a way to know which constraint is being violated when you receive the message constraint error 19:
>>
>> In example: my_column_name UNIQUE constraint
> Upgrade SQLite:
>
> sqlite> create table t(x unique);
> sqlite> insert into t values(1);
> sqlite> insert into t values(1);
> Error: column x is not unique
>
>> I'm using WebSQL
> Upgrade whatever implementation of WebSQL you're using.
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Which constraint is being violating??

Stephan Beal-3
On Mon, Nov 4, 2013 at 10:26 AM, Rafa de Miguel <
[hidden email]> wrote:

> Do I have control about the WebSQL version or it's Chrome whom decide it?
>

FWIW: i don't know if this matters to you, but WebSQL was dropped from
HTML5-related standardization efforts some time ago (2+ years), being
superseded by IndexedDb. i.e. WebSQL "may" very well be in Chrome
long-term, but it is not (at least for the foreseeable future) a standard
you can rely upon across browsers.

Whether or not that's a problem depends solely on your project.

http://en.wikipedia.org/wiki/Web_SQL_Database

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Since tyranny's the only guaranteed byproduct of those who insist on a
perfect world, freedom will have to do." -- Bigby Wolf
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Which constraint is being violating??

Rafa de Miguel
Yes, I knew that but that info it doesn't really help me too much


El 04/11/13 10:33, Stephan Beal escribió:

> On Mon, Nov 4, 2013 at 10:26 AM, Rafa de Miguel <
> [hidden email]> wrote:
>
>> Do I have control about the WebSQL version or it's Chrome whom decide it?
>>
> FWIW: i don't know if this matters to you, but WebSQL was dropped from
> HTML5-related standardization efforts some time ago (2+ years), being
> superseded by IndexedDb. i.e. WebSQL "may" very well be in Chrome
> long-term, but it is not (at least for the foreseeable future) a standard
> you can rely upon across browsers.
>
> Whether or not that's a problem depends solely on your project.
>
> http://en.wikipedia.org/wiki/Web_SQL_Database
>

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Date function accepts only DD for date string

Simon Slavin-3
In reply to this post by Clemens Ladisch

On 4 Nov 2013, at 7:36am, Clemens Ladisch <[hidden email]> wrote:

> Navaneeth K N wrote:
>> select date('2013-11-04')  -> Works well
>> select date('2013-11-4')   -> Not working
>>
>> Is there a way to make the second form working?
>
> Only by inserting a zero into the string (which isn't easy
> with the built-in SQL functions).

Right.  I recommend that you turn date strings into dates (integers or reals) in your programming language if at all possible.  Most of them have libraries that do this stuff.  SQLite may have a function in that appears to do it but it's not really designed for that.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Which constraint is being violating??

decalek
In reply to this post by Rafa de Miguel
On 04.11.2013 11:46, Rafa de Miguel wrote:
> Yes, I knew that but that info it doesn't really help me too much

FWIW: You probably are aware of this too, but just in case: On the
browsers, especially these without build-in WebSQL (sqlite) support, the
developer can fallback to a C to LLVM IR to JS (asm.js which is
efficiently JIT-ted on FF) build/port as provided by:

https://github.com/kripken/sql.js

(It is possible to build with sqlite version different than currently
bundled amalgamation version - 3.7.17)

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Which constraint is being violating??

Rafa de Miguel
Hello Alex,

Didn't know that, very interesting, could be a good solution on my local
machine but not for the final users of the app.

I actually know which constraint is being violated, but I was thinking on
build a standard message to warn the user on the save action based on the
constraint error message.

I'm afraid that I need to implement that validations manually in js on the
save action :(

Thanks for your help!

Rafa

El 05/11/13 03:12, Alek Paunov escribió:

> On 04.11.2013 11:46, Rafa de Miguel wrote:
>> Yes, I knew that but that info it doesn't really help me too much
>
> FWIW: You probably are aware of this too, but just in case: On the
> browsers, especially these without build-in WebSQL (sqlite) support, the
> developer can fallback to a C to LLVM IR to JS (asm.js which is
> efficiently JIT-ted on FF) build/port as provided by:
>
> https://github.com/kripken/sql.js
>
> (It is possible to build with sqlite version different than currently
> bundled amalgamation version - 3.7.17)
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users