2017-02-15 5:40 GMT+01:00 Darko Volaric <li...@darko.org>:

> The problem is that you're giving your column a type when you don't want it
> to have. If the second last line was "message NOT NULL" you'd get exactly
> what you're asking for.
>

​When the table was designed (many years ago) it was logical to make it a
TEXT field, but a little over a month ago I began also storing data that is
a count. I will convert the table and look what happens to the data.

The view is still handy, but I could drop the cast.

​Thank you for the idea.

​


> On Wed, Feb 15, 2017 at 1:22 AM, Cecil Westerhof <cldwester...@gmail.com>
> wrote:
>
> > I have the following table:
> > CREATE  TABLE messages(
> >     messageID   INTEGER PRIMARY KEY AUTOINCREMENT,
> >     date        TEXT NOT NULL DEFAULT CURRENT_DATE,
> >     time        TEXT NOT NULL DEFAULT CURRENT_TIME,
> >     type        TEXT NOT NULL,
> >     message     TEXT NOT NULL
> > );
> >
> > But for some data the field message is filled with an integer. An integer
> > takes less room as its text representation and it sorts differently also.
> > Is there a way to store an INTEGER in a TEXT field? Not very important,
> > more nice to have.
> >
> > I just created the following view:
> > CREATE VIEW downloadCount AS
> > SELECT   date                     AS Date
> > ,        time                     AS Time
> > ,        CAST(message AS INTEGER) AS DownloadCount
> > FROM     messages
> > WHERE    type = 'download-count'
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to