Subject | Re: only for numerics... |
---|---|
Author | Svein Erling Tysvær |
Post date | 2006-03-13T09:01:08Z |
Hi Rony!
I recommend that you fix the problem long before the SELECT. Start by
two tables:
CREATE TABLE Test(ID INTEGER, AFIELD VARCHAR(32), CONSTRAINT PK_Test
(ID) PRIMARY KEY);
CREATE TABLE Test_Integer(ID INTEGER, Test_ID INTEGER, AnInteger
INTEGER, CONSTRAINT PK_Test_Integer (ID) PRIMARY KEY);
(there may be spelling mistakes, and Test_ID should be a foreign key
to Test(ID))
Then write an AFTER INSERT OR UPDATE trigger on the Test table that
simply parses the string and inserts into Test_Integer any number that
it finds.
HTH,
Set
I recommend that you fix the problem long before the SELECT. Start by
two tables:
CREATE TABLE Test(ID INTEGER, AFIELD VARCHAR(32), CONSTRAINT PK_Test
(ID) PRIMARY KEY);
CREATE TABLE Test_Integer(ID INTEGER, Test_ID INTEGER, AnInteger
INTEGER, CONSTRAINT PK_Test_Integer (ID) PRIMARY KEY);
(there may be spelling mistakes, and Test_ID should be a foreign key
to Test(ID))
Then write an AFTER INSERT OR UPDATE trigger on the Test table that
simply parses the string and inserts into Test_Integer any number that
it finds.
HTH,
Set
--- In firebird-support@yahoogroups.com, "Rony Cesana" wrote:
> Hi everybody,
>
> I wondered whether there's any chance of filtering in a where clause
> all the numbers... even though I'm not sure they're numbers!!!
>
> Having
>
> CREATE TABLE Test(AFIELD VARCHAR(32));
>
> INSERT INTO Test(AFIELD) VALUES ('abc');
> INSERT INTO Test(AFIELD) VALUES ('15');
> INSERT INTO Test(AFIELD) VALUES ('30');
>
> I'd like to extract only the second record, saying something
> SELECT * FROM Test
> WHERE CAST(AFIELD AS INTEGER) < 20;
>
> The above example, obviously, doesn't work... otherwise would I be
> posting this? ;))
>
> Thanks in advance,
> Rony