Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Question Unanswered: Subqueries in Sybase Views?

    Hey Everyone -

    I have an Oracle database that I am working migrating to Sybase. However, many of the Oracle views contain subqueries which I have found that Sybase doesn't support. Does Sybase support any kind of subqueries in views? If not, what is the best workaround?

    Thanks so much,
    Alan

  2. #2
    Join Date
    Dec 2004
    Location
    Broomfield, Colorado
    Posts
    16

    subqueries in views

    Subqueries will still need to return a single value. If you can live with that, try the case statement. This works in my dev system ( 12.0) :

    drop view jd_view
    go
    create view jd_view as
    select
    p.family_id,
    p.parent_id,
    case
    when p.parent_id = p.parent_id
    then (select count(*) from children c where c.parent_id = p.parent_id )
    end as ChildCount,

    case
    when p.parent_id = p.parent_id
    then (select max(c.age) from children c where c.parent_id = p.parent_id )
    end as OldestChild

    from parents p
    go

    -- now try it:
    select * from jd_view where family_id = 2
    go

    Hope that helps.

    johndz

  3. #3
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    What do you mean, subqueries? Also, what version of ASE are you on?
    Thanks,

    Matt

Posting Permissions

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