Query works but not in package

Hi,
I have this query that executes fine if I put it in a sql editor, I get a nice result set. However, when i put it in a procedure (in a package) I get the following error:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current ex
Why is this? The procedure uses querys from another schema, but since it works in sql editor?...
I have granted selects on all the tables in used by the SP.
Anyone?

They are quite big procedures. But if it works in the editor, wouldn't it work in a SP? Can someone explain that to me...
CREATE OR REPLACE PACKAGE BODY SP_PST AS
     PROCEDURE GetCountyList(rs out RecSet)
     IS
     BEGIN
     open rs for
                              select komm.1kod, laen.kod, laen.namn, komm.2kod, komm.namn, medi.kod, mp.namn_off, 'cut' utgiv, round(100*hh.upp/hhantal.antal, 2) hh2, round(100*hh.upp/hhantal.antal, 0) hh, (
                    /* breaks here*/     select max(anns_pris) pris
                         from ts.apls, ts.aprs
                         where apls.date_fom <= to_date('2006-01-01', 'yyyy-mm-dd') and apls.date_tom >= to_date('2006-01-01', 'yyyy-mm-dd')
                         and (apls.off is null or apls.off < sysdate) and apls.kod=aprs.kod
                              and apls.date_fom=aprs.date_fom
                              and aprs.frmt='mm' and prvarkod='-' and region='-' and infvdag='-'
                              and (plac='ETKU'
                              or (plac='ETKUM' and not exists (select 1 from ts.aprs a2 where aprs.kod=a2.kod and aprs.date_fom=a2.date_fom and aprs.frmt='mm' and prvarkod='-' and region='-' and infvdag='-' and plac='ETKU'))
                                   or (plac='FEKU' and not exists (select 1 from ts.aprs a2 where aprs.kod=a2.kod and aprs.date_fom=a2.date_fom and aprs.frmt='mm' and prvarkod='-' and region='-' and infvdag='-' and plac in ('ETKU', 'ETKUM'))))
                              and apls.kod=medi.kod
                         ) pris
               from ts.medi, ts.laen, ts.komm,
                    subquery     
                    ) ml,
                    another subquery
) mk,
                    yet another subquery                     ) mp,
                    subquery again
                    ) hh,
subquery...
                    ) hhantal
               where big whereclause
          EXCEPTION
     WHEN NO_DATA_FOUND THEN
     Null;
     WHEN OTHERS THEN
     -- Consider logging the error and then re-raise
     RAISE;
     END GetCountyList;
     PROCEDURE GetMunicipalityList(p_countyCode VARCHAR2, rs out RecSet)
     IS
     BEGIN
     open rs for
               select moreyadayada.... similar to the first one...
          EXCEPTION
     WHEN NO_DATA_FOUND THEN
     Null;
     WHEN OTHERS THEN
     -- Consider logging the error and then re-raise
     RAISE;
     END GetMunicipalityList;
END SP_PST;
Added code...

Similar Messages

  • Flashback query works, but not flashback versions query

    This is a test database (Oracle10g 10.1.0.5), not in archivelog mode. I deleted one row 2 hours ago. I can still use flashback query:
    select * from tm_instances as of timestamp to_timestamp('STARTTIME_HERE') to view this row. But I can't use the following flashback versions query:
    SELECT versions_startscn, versions_starttime,
    versions_endscn, versions_endtime,
    versions_xid, versions_operation from tm_instances VERSIONS BETWEEN TIMESTAMP to_timestamp('STARTTIME_HERE') and MAXVALUE
    It gave the following error:
    ORA-30052: invalid lower limit snapshot expression
    So I guess flashback query works better than flashback versions query?
    undo_retention is set to 900 by default here.
    Thanks,
    Hai

    currently function returns all mydate rows, i just want mydesired date rowsCheck if there is a column in the table with the same name as the function parameter. It's the most probable reason of such DML operations behaviour in PL/SQL procedures and function.
    Rgds.

  • Query works but not in a funtion

    i have this query... select sum(amount) from here and there where id=myid and mydate =desireddate... works flawlessly...
    but when i put this query in a function and pass on the parameters does not work... function looks like this.....
    create or replace function myfunction(myid varchar2, desired date) return number is
    amount number;
    begin
    here goes query...where id=myid and mydate=desireddate;
    return amount ;
    end;
    It seems something about the mydesireddate parameter, cause when i manually put the value works fine....currently function returns all mydate rows, i just want mydesired date rows.
    thanks in advance....

    currently function returns all mydate rows, i just want mydesired date rowsCheck if there is a column in the table with the same name as the function parameter. It's the most probable reason of such DML operations behaviour in PL/SQL procedures and function.
    Rgds.

  • HelpSet works but not when packaged in JAR

    I have been using the JavaHelp and it all works perfectly if I just compile and run it from Eclpise, but when I try packaging everything into a JAR it doesn't work. Can anyone help me please?
    public void loadHelpSet()
    InfoMsg.postError("loading help") ;
    try
    // Get the classloader of this class.
    ClassLoader cl = this.getClass().getClassLoader() ;
    URL url = HelpSet.findHelpSet(cl, "Irs") ;
    irsHS = new HelpSet(cl, url) ;
    HelpBroker hb = irsHS.createHelpBroker() ;
    hb.setDisplayed(true) ;
    catch (Exception e)
    InfoMsg.postError("Unable to load Help Set") ;
    } // end loadHelpSet
    it doesn't appear to get past the line irsHS = new HelpSet(cl, url) when run from the JAr, but it doesn't appear to throw an error either as no message box is shown (as it would if it couldn't find the helpset under normal circumstances when run from Eclipse)

    I tried that approach but it doesn't work either. I think maybe my directory structure is wrong.
    C:\IRS\IRS.jar
    C:\IRS\irs.hs
    referenced: jar:file://C:/IRS/IRS.jar!/irs.hs
    Am I doing this right?

  • Wake on Lan (works, but not always)

    Iam trying to get Wak on Lan working on my iMac. It works, but not always. When I put my mac to sleep en send the magic package, my mac turns back on. But when my mac turns to sleep and I wait a few hours (the next morning), my Mac doesn't respond to the same magic packag. When I wake up the Mac by hand, and put it back to sleep again, the magic package works again en turns the mac on.
    It almost looks like the mac goes into a deeper sleep mode after a few hours. Does anyone knows what could ben the reazon.

    mmm, It seems like my mac doesn't always turns to sleep mode. Most of the time it only turns off the screen (solid light). My energy settings are 10 minutes for the screen and 15 minutes for the mac. But after turning of the screen it never turns to sleepmode. Ecxept when I put it to sleep manualy.
    Strange thing is: when the screen is turned of, shouldn't I be able to get tot my files... (I can't actualy).

  • Problem with drivers for HP B109 a-m all-in-one, have printer working but not scanner in windows 8

    Still have a problem with the drivers in Windows 8 release preview, for my HP B109 a-m all-in-one, have printer working but not scanner, is there any chance of a fix before final release of Windows 8 ?.

    Review my post here:
    http://h30434.www3.hp.com/t5/Windows-8-Release-Preview/SOLUTION-Get-Win-7-Printer-Drivers-HP-Solutio...
    And see if something similar will work for you.

  • My Mac Mini doesn't recognize my Avengers DVD--it keeps saying "Supported disc not available." I've tried other DVD's which work, but not this one. itunes and everything else has been updated to the newest versions. Help?

    My Mac Mini doesn't recognize my Avengers DVD--it keeps saying "Supported disc not available." I've tried other DVD's which work, but not this one. itunes and everything else has been updated to the newest versions. Help? Also...It doesn't recognize the digital copy DVD.

    I have ALL the exact same symptoms as on my home computer.
    It sure sounds to me like something on the iPod is broken. If it's under warranty then I would send it back for repair. If not, check out some of the web repair services, such as iPodResQ etc.

  • Allt he links in the header of any websites are not working, I reinstalled fiorefix and it s the same. No problem in others browser. the tool bar is working but not the link sinside the web page located between the top 300px height

    all the links in the header of any websites are not working, the cursor is not changing into pointer and no way to click on any link located at the top of any website page. I reinstalled firefox and it s the same. No problem in others browser. the tool bar is working but not the links inside any web page located between the top 300px height.
    So I can t tlog into any website, i cant write an email as the compose button is located in the top of the page.. Please help, i have all my bookmarks into my firefox...

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Speakerphone problem - lost voice from speakerphone while playing music or gaming youtube, while call or voice recording playing - all works fine, so speakerphone is working but not on all apps. hard reset done - no changes

    or gaming youtube, while call or voice recording playing - all works fine, so speakerphone is working but not on all apps. hard reset done - no changes.
    iphone 4
    SOLVED plugin to charger solved it - so problem was with contacts -- no idea why - phone is new - no water - no havy dust - usual using  
    hope will never return. Thanks

    We checked it with an iPhone 5 in house multiple times and could not reproduce this Problem. Must be something specific to your device. Maybe your speakerphone volume is turned down completely?
    Follow the latest Skype Community News
    ↓ Did my reply answer your question? Accept it as a solution to help others, Thanks. ↓

  • Hi!My 6 month old MBP 13" has suddenly stop charging.Mac is working,but not charging

    Hi!My 6 month old MBP 13" has suddenly stop charging.Mac is working,but not charging

    Troubleshooting MagSafe adapters  http://support.apple.com/kb/ts1713
    If you need to pursue further you can do it on-line,  start here
    https://selfsolve.apple.com/agreementWarrantyDynamic.do

  • My iPad cannot connect to my internet.  the internet is working but not with my ipad.

    my iPad cannot connect to my internet.  the internet is working but not with my ipad.

    Call your ISP (Internet Service Provider) and explain them your issue, it could range from having your router configured incorrectly to having a wiring issue. Personally, I have Comcast and they are great, no issues, and awesome customer service.
    Hope you get up and running ASAP

  • HT4993 My volume down button is not working.  The UP button works, but not the down button.  I have tried to restart it and that didn't solve the problem.

    My volume down button doesn't work on my iPhone.  The UP buttown works, but not the down button.  I have tried a hard reset and that didn't fix it.

    Try this.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • ICloud keeps asking for password but will not take it. All other devices work but not my IMac???

    ICloud keeps asking for password but will not take it. All other devices work but not my IMac???

    Exactly which password are you inputting? iCloud looks for your AppleID password.

  • Sap xi SCENARIO source directory working ,but not working target directory

    sap xi SCENARIO source directory working ,but not working target directory..
    plz help me

    Hi,
    Be more specific on the problem you are facing so that the ppl here can help..
    looks like your are trying to file to file scenario and the file is not generating at the target folder ...
    then check the communication logs of the receiver adapter using RWB->CC logs..
    post the error you have received there..
    HTH
    Rajesh

  • Can't sync ical on my iphone and imac. email and note work but not ical.  can anyone help.

    can't sync ical on my iphone and imac. email and note work but not ical.  can anyone help.
    thanks
    bmoreimac

    So how can i make it work that way, i asked one of my friends, and she says it works like that...when she delete the email on her iphone it is deleted on the mac too, what do i do to change this?....my mail it's hotmail, i don't know if its relevant

Maybe you are looking for

  • Need help in using web service of UCM in C#

    I am trying to use the "Search" web service of UCM in C#. The code below is what I did, ucm_server.Search search = new ucm_server.Search(); search.Credentials = new NetworkCredential("sysadmin", "idc"); QuickSearchResult result = search.QuickSearch("

  • Anyone elses contacts not being recognized by the Phone and Message apps?

    Anyone elses contacts not being recognized by the Phone and Message apps? Updated to 5.0.1 on my 4S and this is what happened

  • Selling Powerbook G4 - Should I reintall OS 10.2?

    I am selling my Powerbook G4. I want to erase all my files and the login name and password. Do I have to re-install the OS in order to erase the username and login information? The computer originally came with OS 9 and I upgraded to OS 10.2.8. Can I

  • Single user mode, Lost Admin Account, and Disk Permissions

    Okay, so I have quite a few issues here. I will start from the beginning. About a week ago, I tried to install some updates and I could not get the Admin account to work. I went to the users profile and noticed my Admin account was not there. Did a q

  • How to install / use fonts in OS X?

    I've downloaded a bunch of .pcf fonts, two .NFNT fonts, and some .bdf fonts. I read a bit online, saw that fonts go in ~/Libary/Fonts, so I dumped 'em into ~/Library/Fonts, and OS X doesn't recognize or allow me to select any of them from within Term