Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Posts
    2

    Unanswered: "IF" Expression in Adaptive Server Anywhere

    Hello everyone,

    I´m very new to working with Sybase (only worked with mySQL so far), so please don´t hurt me if I ask stupid questions

    Situation is as follows:
    We are using the software "Lexware Financial Office", which uses a Sybase Adaptive Server Anywhere 9.0 Database.

    We do have access to this database via ODBC.

    Now I want to create a view which is supposed to check if a certain field in a table is empty, and depending on this return the content of one or another field.

    My problem is that I don´t seem to be able to include an "if" or "case" expression in any query. The database should support them (at least the manual from sybase´s homepage says it does).

    Can somebody take a look at this code and tell me what the error might be?

    Code:
    SELECT
    *,
    IF Anschrift_Vorname = 'Erika'
    THEN 'Test Value 1'
    ELSE 'Test Value 2'
    ENDIF
    FROM F1.FK_Kunde
    (Anschrift_Vorname is a field in the FK_Kunde table.)


    I would be very grateful for any help you can offer.
    Is there maybe a syntax error in this code?
    Are "if" expressios simply not supported in a certain version?

    Best Regards
    Sebastian

  2. #2
    Join Date
    Jan 2009
    Posts
    2
    Solved it.

    Database is case sensitive, but doesn´t recognize capital letters if they are not between quotation marks.

    So, doesn´t work:
    Code:
    SELECT
    *,
    IF Anschrift_Vorname = 'Erika'
    THEN 'Test Value 1'
    ELSE 'Test Value 2'
    ENDIF
    FROM F1.FK_Kunde
    Does work:
    Code:
    SELECT
    *,
    IF "Anschrift_Vorname" = 'Erika'
    THEN 'Test Value 1'
    ELSE 'Test Value 2'
    ENDIF
    FROM "F1"."FK_Kunde"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •