Menu

uCanAccess - cStr in join not working , but Val does work - Possible bug

Help
2016-03-29
2016-03-30
  • Derek Visch

    Derek Visch - 2016-03-29

    Using ucanaccess-3.0.4.jar and jackess-2.1.3.jar

    Returns Null for the Application Type Name due to the CStr conversion on the Customer Card ID field in the second join.

    SELECT DISTINCT
    Customer.[Customer Card Id],
    Customer.[Account Balance],
    [Eligibility Group].[EligibilityGrou],
    [Application Type].[Application Type Name]
    FROM Customer
    INNER JOIN [Eligibility Group] on [Eligibility Group].[Eligibility Group Id] = Customer.[Eligibility Group Id]
    LEFT JOIN Applicant ON Applicant.[Student Id] = CStr(Customer.[Customer Card Id])
    LEFT JOIN Application ON Application.[Application Id] = Applicant.[Application Id]
    LEFT JOIN [Application Type] ON [Application Type].[Application Type Id] = Application.[Application Type Id]
    WHERE ((Customer.[Customer Card Id]) Is Not Null AND (Customer.Status=0) AND Customer.[Customer Card ID]=someNumber);

    This sql statement below does not return null and returns the correct value for the Application Type Name field for this user. The pervious sql comand returns null for the Application Type Name column

    SELECT DISTINCT
    Customer.[Customer Card Id],
    Customer.[Account Balance],
    [Eligibility Group].[Eligibility Group Name],
    [Application Type].[Application Type Name]
    FROM Customer
    INNER JOIN [Eligibility Group] on [Eligibility Group].[Eligibility Group Id] = Customer.[Eligibility Group Id]
    LEFT JOIN Applicant ON Val(Applicant.[Student Id]) = Customer.[Customer Card Id]
    LEFT JOIN Application ON Application.[Application Id] = Applicant.[Application Id]
    LEFT JOIN [Application Type] ON [Application Type].[Application Type Id] = Application.[Application Type Id]
    WHERE ((Customer.[Customer Card Id]) Is Not Null AND (Customer.Status=0) AND Customer.[Customer Card ID]=someNumber );

    Also this database does return this when running

    WARNING:Detected Unique constraint breach, table App Activity,
    WARNING:Error in the metadata of the table App Activity: table's row count in the metadata is xxxx but (about 30% less) records have been found and loaded by UCanAccess. All will work fine, but it's better to repair your database.

    I'm not sure why this happens.

    Thanks in advance!

     

    Last edit: Derek Visch 2016-03-29
  • Marco Amadei

    Marco Amadei - 2016-03-29

    Hi Derek, it's not a best practice to compare strings whose the format may depend on the jvm current locale, so the second query is correct, whilest the first one is, ehm..., challenging. It may give something like a decimal rappresentation.
    What if you print out the result of
    select CStr([Customer Card Id]) from customer?

     
  • Derek Visch

    Derek Visch - 2016-03-29

    Select [Student Id] from Applicant returns results like
    (All made up numbers of course)
    8965215
    6431253

    Meta Data for the column returned


    ColumnIndexgetColumnNamegetColumnTypeNamegetPrecisiongetScaleisNullablegetTableNamegetSchemaNamegetCatalogNamegetColumnClassNamegetColumnDisplaySizegetColumnLabelgetColumnTypeisAutoIncrementisCaseSensitiveisCurrencyisDefinitelyWritableisReadOnlyisSearchableisSignedisWritable
    1Student IdVARCHAR3001ApplicantPUBLICPUBLICjava.lang.String30Student Id12falsefalsefalsefalsefalsetruefalsefalse

    And Select CStr([Customer Card ID]) from Customer

    returns things like
    8,965,215
    6,431,253

    Meta Data for returned column


    ColumnIndexgetColumnNamegetColumnTypeNamegetPrecisiongetScaleisNullablegetTableNamegetSchemaNamegetCatalogNamegetColumnClassNamegetColumnDisplaySizegetColumnLabelgetColumnTypeisAutoIncrementisCaseSensitiveisCurrencyisDefinitelyWritableisReadOnlyisSearchableisSignedisWritable
    1C1VARCHAR1677721602<null>  java.lang.String16777216C112falsefalsefalsefalsetruefalsefalsefalse

    Looks like you're onto something

     

    Last edit: Derek Visch 2016-03-29
  • Derek Visch

    Derek Visch - 2016-03-29

    Seems odd that both the types get returned as VARCHARs but had different String outputs from the jdbc driver. The addition of the commas is throwing me off a bit as a conversation to VARChar should only add the commas if you specefically ask right?

     
  • Marco Amadei

    Marco Amadei - 2016-03-30

    Your first statement doesn't make sense but we'll check again for numeric rappresentation consistency within functions.

     
  • Derek Visch

    Derek Visch - 2016-03-30

    Let me know if I can provide anything, sorry I didn't make sense in my previous comment.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.