On 11/24/15, James Hartley <jjhartley at gmail.com> wrote:
> I would like to add a check constraint which determines if a string
> contains all digits, ie.
>
> sqlite> select zip_code from zip_codes where regexp(zip_code,
> '^[[:digit:]]+$');
>
> However, this generates the error:
>
> Error: no such function: regexp

Maybe this instead:

   SELECT * FROM zip_codes WHERE zip_code NOT GLOB '[^0-9]';


>
> Searching through sqlite.org points that this function may not be included.
>
> So, is there any equivalent to this kind of functionality?  I can check at
> the application level beforehand, but there is some solace knowing that the
> database can check the condition at the time of insertion too.
>
> Thanks!
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
D. Richard Hipp
drh at sqlite.org

Reply via email to