Does Labkey SQL allow TEXT-to-INT conversion/CAST-ing?

LabKey Support Forum (Inactive)
Does Labkey SQL allow TEXT-to-INT conversion/CAST-ing? Leo Dashevskiy  2013-09-04 16:43
Status: Closed
 
If so, what is the proper syntax?

SELECT DISTINCT
 CAST( projections.name AS INT ) AS Index
...

does not seem to work...

Thanks.
-Leo
 
 
Matthew Bellew responded:  2013-09-04 17:23
INTEGER should work. This should be documented better on the SQL reference page. I see the types documented in the PARAMETERS section but not in the CAST description.

Here are the other types

    BIGINT
    BINARY
    BIT
    CHAR
    DECIMAL
    DOUBLE
    FLOAT
    LONGVARBINARY
    LONGVARCHAR
    NUMERIC
    REAL
    SMALLINT,
    DATE
    TIME
    TIMESTAMP
    TINYINT
    VARBINARY
    VARCHAR
 
Leo Dashevskiy responded:  2013-09-04 18:30
Matt, could you, please, share the link with the resources you are talking about?
 
Leo Dashevskiy responded:  2013-09-04 19:12
I'm assuming, you were referring to this: https://help.labkey.org/wiki/home/Documentation/page.view?name=labkeySql

Using INTEGER like you suggested does not produce an error, while parsing the query.
(I used INT in my schema declaration and it worked fine, so was not expecting that I should use INTEGER here.)

BUT, the LABKEY.ext.Store is behaving really weird in this case: it only gets populated with one last row of the query result, whereas in the schema browser one can see that the result of the query is correct -- can someone reproduce this behavior and if yes, then this is definitely a bug, no?
 
Leo Dashevskiy responded:  2013-09-12 14:48
Changed the schema to use proper INT
 
Matthew Bellew responded:  2013-09-12 16:09
As to why these are inconsistent. The schema files use names that are consistent with xml schema conventions

  http://www.w3.org/TR/xmlschema-2/

and SQL uses names consistent with JDBC/ODBC conventions

  http://docs.oracle.com/cd/E17952_01/refman-5.0-en/connector-odbc-reference-datatypes.html

Matt