0

We have recently migrated our database from Sybase 10 to Sybase 15.

When I execute the below query in Sybase 10 (SYC Sybase System 10) it gives me a single row as output.

SELECT 
        'x'
    FROM
        employee
    WHERE
        EXISTS 
        (
            SELECT 
                    employee.emp_id 
                FROM 
                    employee 
                WHERE 
                    employee.branch_id = 3013 
                AND employee.emp_id = 20 
                AND employee.object_id > 1
        )

Output:

x
(1 row(s) affected)

When I execute the same query in Sybase 15 (SYC Adaptive Server Enterprise) the query output generates 1653 rows, which is the total row count of the employee table.

Output:

x
x
x
x
x
x
x
.....
(1653 row(s) affected)

Can you please help me as our application expects only one row as output and getting multiple rows is creating an issue. (We do not have code for the application to change the query).

6
  • Please share the table structure, sample input data, and the expected output data such that others could reproduce your problem
    – Nico Haase
    Feb 10, 2020 at 18:26
  • how many rows does the employee table have in each of the 2x databases?
    – markp-fuso
    Feb 10, 2020 at 19:35
  • Why upgrading to Sybase ASE 15, the latest release is already over 8 years old and not Sybase ASE 16 which is newer, but not at the bleeding edge being 3 years old? Feb 10, 2020 at 23:28
  • If you don't have the source code, is this a vendor application or has the source code gone missing over the years? Feb 10, 2020 at 23:28
  • @markp Both the tables have 1653 rows of data. Feb 11, 2020 at 10:59

2 Answers 2

0

Somewhere in the dim and distant past, probably about Sybase ASE 11, sub query processing was changed. Prior to ASE 11 an "IN" would return one row for each matching row returned from a subquery; even if the values were the same. ASE 11 upwards corrected this, so that only distinct values would be returned. I can't recall if this affects the EXISTS function or not, since it's 25 years since Sybase ASE 11 was released.

I don't think this is something that can be configured through an option. It may require a code change and you state you don't have the source code.

0

System 10 is a very, very long time ago. I do indeed remember there were upgrade issues related to subqueries, but the details are fuzzy now. When you look at the query however, the result by ASE 15 is correct. That would match with Richard Crossley's recollection of the issue, meaning that the result in version 10 was in fact not correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.