DBAsupport.com Forums - Powered by vBulletin
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: sql statement

  1. #11
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142

    Re: sql statement

    I still think the IN can go and you still need the ; after the last )

    Will this work?

    Code:
     declare
     v_metatags tblworkingcontent.metatags%type;
     v_numerorighe int;
     begin
        delete from tblworkingcontent wc1
           where wc1.metatags=v_metatags
           and (select count(*)
                from tblworkingcontent wc2
                where wc2.idworkingcontent < wc1.idworkingcontent
                   and wc2.metatags=v_metatags) <
                   (select count(*)
                    from tblworkingcontent wc3
                    where wc3.metatags=v_metatags-v_numerorighe)
        ;
    end;
    /

  2. #12
    Join Date
    Jun 2003
    Posts
    47
    no it still doesn't.But I agree about the in clause.
    Here are the errors:


    ERROR at line 7:
    ORA-06550: line 7, column 13:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + mod not null others
    avg
    count current exists max min prior sql stddev sum variance
    execute forall time timestamp interval date


    ORA-06550: line 10, column 45:
    PLS-00103: Encountered the symbol "<" when expecting one of the following:
    ; return returning and or
    ORA-06550: line 15, column 1:
    PLS-00103: Encountered the symbol "END"

  3. #13
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Hmmm . . think I've seen something like this where the scalar sub-query had to go on a specific side of the > . . . but that was RDB ! ! !

    Last try. . .
    Code:
    declare
     v_metatags tblworkingcontent.metatags%type;
     v_numerorighe int;
     v_countr int;
    begin
    
        select count(*) into v_countr
           from tblworkingcontent wc3
           where wc3.metatags=v_metatags-v_numerorighe;
    
        delete from tblworkingcontent wc1
           where wc1.metatags=v_metatags
           and v_countr > 
               (select count(*)
                from tblworkingcontent wc2
                where wc2.idworkingcontent < wc1.idworkingcontent
                and wc2.metatags=v_metatags);
    end;
    /

  4. #14
    Join Date
    Jun 2003
    Posts
    47
    Perfect no errors now.
    So it's the side of the > that matters?
    Thanks a lot.

  5. #15
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Now, I haven't even looked at the actual SQL, but the very first response to this problem should have been to put the SQL in a string and run it as dynamic SQL inside the PL/SQL. There are two different SQL engines in 8i, and the one for straight SQL is well ahead of the one for PL/SQL. So anything that works in SQL*Plus but not in PL/SQL simply needs to be converted to dynamic SQL to work.

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  6. #16
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Originally posted by chrisrlong
    Now, I haven't even looked at the actual SQL, but the very first response to this problem should have been to put the SQL in a string and run it as dynamic SQL inside the PL/SQL. There are two different SQL engines in 8i, and the one for straight SQL is well ahead of the one for PL/SQL. So anything that works in SQL*Plus but not in PL/SQL simply needs to be converted to dynamic SQL to work.

    - Chris
    That's fine as a quick workaround, but there's overhead associated with repeatedly running it as dynamic SQL, no? A better approach is to rewrite it to a form that the PLSQL SQL engine can handle, I would think.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  7. #17
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Nope. There is virtually no overhead with Dynamic SQL. I personally find so many advantages to Dynamic SQL that it is pretty much my standard methodology.

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  8. #18
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    So do you use DBMS_SQL, or EXECUTE IMMEDIATE, or both?
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  9. #19
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    NDS (Native Dynamic SQL => EXECUTE IMMEDIATE, OPEN..FOR ) all the way. DBMS_SQL sucks, IMHO. I even created a solution to allow variable inputs for NDS SQL, so I wouldn't have to use DBMS_SQL. I further created another package that wraps DBMS_SQL so that it always does array fetching, which is the only thing that makes it use-able, since it's so bloody slow.

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  10. #20
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Doesn't NDS open you up to continual re-parsing of the query though? Even when you use bind variables, you are re-parsing every time the statement is executed.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

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