DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: union+order by

  1. #1
    Join Date
    Jun 2003
    Posts
    47

    union+order by

    hi,

    I had this code :

    create or replace procedure
    proc_name( v_idfolder tblfolder.idfolder%type,
    v_target tblhtmlfile.idcustomergroup%type,
    v_recordset out types.cursor_type)
    is
    begin
    open v_recordset for
    select tf.idfolder,tf.name as Item,tf.orderlist,1 as isfolder,
    0 as isroot,thf.idhtmlfile
    from tblfolder tf,tblhtmlfile thf
    where tf.idfolder=thf.idfolder
    and tf.idparent=v_idfolder
    and tf.deleted=0
    and tf.published=1
    and thf.isroot=1
    and thf.idcustomergroup=v_target
    and thf.deleted=0
    UNION ALL
    select thf.idfolder,thf.htmltitle as Item,thf.orderlist,
    0 as isfolder,thf.isroot,thf.idhtmlfile
    from tblhtmlfile thf
    where thf.isroot=0
    and thf.idfolder=v_idfolder
    and thf.published=1
    and thf.deleted=0
    and thf.isoverthemenu=1
    and thf.idcustomergroup=v_target
    order by t1.orderlist;
    end;

    and It gives the following error:
    ERROR at line 27:
    ORA-06550: line 27, column 14:
    PLS-00201: identifier 'THF.IDFOLDER' must be declared
    ORA-06550: line 7, column 2:
    PL/SQL: SQL Statement ignored


    the alternative solution I found was
    select * from
    ( ) t1
    order by t1.orderlist;

    But Can anyone explain why it doesn't work directly with the order by???
    Thanks in advance

  2. #2
    Join Date
    Jul 2001
    Location
    Slovenia
    Posts
    422

    Re: union+order by

    Originally posted by edli
    PLS-00201: identifier 'THF.IDFOLDER' must be declared
    desc tblhtmlfile
    Tomaž
    "A common mistake that people make when trying to design something completely
    foolproof is to underestimate the ingenuity of complete fools" - Douglas Adams

  3. #3
    Join Date
    Jun 2003
    Posts
    47
    well I really have written it wrong but its not that the problem because the field belongs to the table.

    create or replace procedure
    proc_name( v_idfolder tblfolder.idfolder%type,
    v_target tblhtmlfile.idcustomergroup%type,
    v_recordset out types.cursor_type)
    is
    begin
    open v_recordset for
    select tf.idfolder,tf.name as Item,tf.orderlist,1 as isfolder,
    0 as isroot,thf.idhtmlfile
    from tblfolder tf,tblhtmlfile thf
    where tf.idfolder=thf.idfolder
    and tf.idparent=v_idfolder
    and tf.deleted=0
    and tf.published=1
    and thf.isroot=1
    and thf.idcustomergroup=v_target
    and thf.deleted=0
    UNION ALL
    select thf.idfolder,thf.htmltitle as Item,thf.orderlist,
    0 as isfolder,thf.isroot,thf.idhtmlfile
    from tblhtmlfile thf
    where thf.isroot=0
    and thf.idfolder=v_idfolder
    and thf.published=1
    and thf.deleted=0
    and thf.isoverthemenu=1
    and thf.idcustomergroup=v_target
    order by tf.orderlist;
    end;

    and It gives the following error:
    ERROR at line 27:
    ORA-06550: line 27, column 14:
    PLS-00201: identifier 'TF.IDFOLDER' must be declared
    ORA-06550: line 7, column 2:
    PL/SQL: SQL Statement ignored

  4. #4
    Join Date
    Jun 2003
    Posts
    47
    TF.ORDERLIST must be declared

  5. #5
    Join Date
    Oct 2002
    Location
    Ljubljana,Slovenia
    Posts
    28
    Try this

    create or replace procedure
    proc_name( v_idfolder tblfolder.idfolder%type,
    v_target tblhtmlfile.idcustomergroup%type,
    v_recordset out types.cursor_type)
    is
    begin
    open v_recordset for
    select tf.idfolder,tf.name as Item,tf.orderlist,1 as isfolder,
    0 as isroot,thf.idhtmlfile
    from tblfolder tf,tblhtmlfile thf
    where tf.idfolder=thf.idfolder
    and tf.idparent=v_idfolder
    and tf.deleted=0
    and tf.published=1
    and thf.isroot=1
    and thf.idcustomergroup=v_target
    and thf.deleted=0
    UNION ALL
    select thf.idfolder,thf.htmltitle as Item,thf.orderlist,
    0 as isfolder,thf.isroot,thf.idhtmlfile
    from tblhtmlfile thf
    where thf.isroot=0
    and thf.idfolder=v_idfolder
    and thf.published=1
    and thf.deleted=0
    and thf.isoverthemenu=1
    and thf.idcustomergroup=v_target
    order by orderlist;
    end;
    Aleš Orehek

  6. #6
    Join Date
    Jun 2003
    Posts
    47
    Aready tried that, it wants it to specifie to which table it belongs.

Posting Permissions

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


Click Here to Expand Forum to Full Width