Statement works as a straight insert statement but not in a procedure

I can run the folloiwing statement as a straight insert
INSERT INTO MYTEMP
SELECT CASE WHEN line_num < 10 THEN NULL ELSE AVG( close) OVER (ORDER BY trade_date ROWS between 9 preceding and current row) END AVG_10
FROM stocks_hold
WHERE symbol = 'DIA';
but when I try to compile it within a procedure I get the following error
PL/SQL: ORA-00905: missing keyword
The only difference is that I loop through a cursor and do the insert using a variable for symbol
I'm done banging my head against the wall, any help would be appreciated.
Thanks
D

Good point, newbie mistake
Here is the entire procedure
CREATE OR REPLACE PROCEDURE sp_doAll IS
lc_SYMBOL VARCHAR2(50);
CURSOR lCur IS
SELECT DISTINCT SYMBOL
FROM STOCKS_HOLD;
lRec lCur%ROWTYPE;
BEGIN
DELETE
FROM stocks;
COMMIT;
FOR lRec IN lCur LOOP
lc_SYMBOL := lRec.SYMBOL;
INSERT INTO STOCKS
(symbol, trade_date, open, high, low, close, volume, LINE_NUM, avg_10, avg_20, avg_50, avg_100, avg_200)
SELECT symbol, trade_date, open, high, low, close, volume, LINE_NUM,
-- CASE WHEN line_num < 10 THEN NULL ELSE AVG( close) OVER (ORDER BY trade_date ROWS between 9 preceding and current row) END AVG_10,
CASE WHEN line_num < 10 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 10 preceding) END avg_10,
CASE WHEN line_num < 20 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 20 preceding) END avg_20,
CASE WHEN line_num < 50 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 50 preceding) END avg_50,
CASE WHEN line_num < 100 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 100 preceding) END avg_100,
CASE WHEN line_num < 200 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 200 preceding) END avg_200
FROM STOCKS_HOLD
WHERE SYMBOL = lc_symbol
ORDER BY TRADE_DATE;
END LOOP;
COMMIT;
END sp_doAll;
This compiles and runs, but, when I try the alternate way (that gives me the accurate results)
Uncomment this statement:
-- CASE WHEN line_num < 10 THEN NULL ELSE AVG( close) OVER (ORDER BY trade_date ROWS between 9 preceding and current row) END AVG_10,
comment this statement:
CASE WHEN line_num < 10 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 10 preceding) END avg_10,
I still get the same error
Thnx
Dan

Similar Messages

  • Works fine in JDK 6.0 but not in jdk 1.5.???????

    Hi all,
    This code converts english date to japanese date but it is working fine in english only. can any body answer why it is so.
    Note : No Comiplation problem in jdk 1.5
    This code works fine in JDK 6.0 but not in JDK 1.5, Why.....?
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            Locale locale = new Locale("ja", "JP", "JP");//locale for Japanese
            Calendar cal = Calendar.getInstance(locale);  //japanese calender object
            DateFormat df = DateFormat.getDateInstance(DateFormat.LONG,locale);
            try{
            Date date = sdf.parse("1930/09/27");
                System.out.println(df.format(date));
            }catch(Exception e){
                System.out.println(e.getMessage());
            }

    Hi,
    If I give the Input date 1930/10/27 (in english), then program must display the date as S5.10.27 (it's japanese date with 'S' indicating ERA)
    But this will happpen only when i run the program in JDK 6.0.
    In JDK 1.5, for the above input, the output is 1930/10/27 (which is wrong)
    Still I don't have compilation and running problems in both. Can anybody expalin why it is so?
    I think i tried my best to restate the question.
    Thanx
    Aris

  • My transparency does not work on my iPhone and I was wondering how I fix that? It worked when I first downloaded ios7 but not now.

    My transparency does not work on my iPhone and I was wondering how I fix that? It worked when I first downloaded ios7 but not now.

    Hello wilsontot_too,
    Thank you for the details of the issue you are experiencing on your iPhone.  It sounds like you are not noticing transparency on your iPhone.  It may be that you have "Increase Contrast" turned on in your iPhone settings.
    I recommend verifying that Increase Contrast is turned off in Settings>General>Accessibility.
    iPhone User Guide - Large, bold, and high-contrast text
    http://help.apple.com/iphone/7/#/iph73b89c6
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • I cannot get GPS Only to work on my ipad3 (4g version, but not on an active cell plan, and wifi off).  Is there some new requirement in 7.1 or 7.1.1 to have cell and/or wifi enabled for GPS to work? I am testing with MotionX

    It seems like I cannot get GPS only to work on my ipad3 (4g version, but not on an active cell plan, and wifi off).  Is there some new requirement in 7.1 or 7.1.1 to have cell and/or wifi enabled for GPS to work? I am testing with MotionX, garmin blueChart mobile, and a GPS monitoring tool. All show no signal. If I turn on cell and wifi,  it says I get gps signal, but can't tell if that is from the GPS chip, or just from cell and wifi only (maybe with some gps mixed in)?  Any ideas on how to get iPad working with GPS only??

    Roger that.  Thanks for your time.
    System:
    Windows 7 64bit
    Processor: AMD phenom IIX4 965
    RAM:  Gskill Ripsaw F3-12800CL7D-4GBRM (2-2GB sticks)
    GPU:EVGA Classified Nvidia GeForce GTX 560 Ti 448 core
    PSU: Kingwin 1000W laser gold (LZG-1000)
    Yes. tried the one ram stick, no go.  I have been trying to boot off/install the windows 7 disk but am unable to get to the point where windows starts installing after its gathering information portion of the install.  I can get to the disk selection screen of the install with the WD HD on SATA port 2 but then get the "cant install messages" when I try to select the Vertex 3.  Yes I can see the Vertex 3 Drive as well as the WD drive at this point.  some times I have to hit "scan" a couple of times.

  • Is there a way to separate raw files from jpegs that are in one folder after downloading from camera when you shoot both together. I tried arrange or sort  by kind but that does not work. It arranges all folders but not the files in the folder., Is there

    Is there a way to separate raw files from jpegs that are in one folder after downloading from camera when you shoot both together. I tried arrange or sort  by kind but that does not work. It arranges all folders but not the files in the folder., Is there a way to separate raw files from jpegs that are in one folder after downloading from camera when you shoot both together. I tried arrange or sort  by kind but that does not work. It arranges all folders but not the files in the folder.

    Bridge will do the job. View > Sort > ByType. Then you can choose a group of one type and put the files in a separate folder.

  • I can not get Firefox to play music backgrounds on pages in browsers it works in IE and other browsers but not firefox, what HTML or Jave script do I need too use to make them work?

    I'm having a problem with firefox playing background music on some sites, it works with IE and other browsers but not with fire fox, what html or java script do I need to add to the pages so that they play the music?
    I develop my pages in Front Page and I know that the music only works in IE, so if someone can tell me how to correct this problem as it is important as I use fire fox as my main browser.
    I thank you in advance

    If a website uses BGSOUND then it will only work in IE.
    BGSOUND is not compatible with other browsers like Firefox.
    * http://kb.mozillazine.org/Background_music_does_not_play

  • I am unable to get Lightroom Mobile to work on my home network. The Ipad says "There are no collections to sync, enable lightroom mobile on your computer", but it is enabled.  I got it to work one time on another network but not at home where I use Lightr

    I am unable to get Lightroom Mobile to work on my home network. The Ipad says "There are no collections to sync, enable lightroom mobile on your computer", but it is enabled.  I got it to work one time on another network but not at home where I use Lightroom.

    Hi,
    could you please give us some info on what kind of network you have?
    Can other application communicate with the web?
    Thanks,
    Ignacio

  • A Work book is visible in MDR but not in BEX

    Hi Pioneers
                I am able to see a Work book in Meta Data Repository but not in BEX(RRMX)in Quality System.What would be the reason??
    Could u plz let me know..
    BR
    Sekhar.D.R

    Did u saved the workbook under some role?

  • Page is working ok in chrome and IE but not working in firefox. jquery problem i guess

    http://184.170.251.149/raschet-shkafa-kupe
    this page is working correctly in chrome and IE but not working in firefox, i cant click and of the dropdown menus(ДСП, доличество дверей). it was working perfectly prior firefox 18. can you please fix the compatibility problem ?

    I was referring to the second page in my above post.
    I disabled JavaScript as a test after loading the page with JavaScript enabled and that worked.<br />
    I also get the selects to open if I right-click instead of left-click the select.<br />
    That way the select get selected (shows a focus ring) and after that left-clicking works as well .
    This assumes that JavaScript is monitoring the left-click, but that script no longer works properly.
    A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.
    *http://forums.mozillazine.org/viewforum.php?f=25
    The helpers at that forum are more knowledgeable about web development issues.<br>
    You need to register at the MozillaZine forum site in order to post at that forum.

  • Code is working fine with OIM9102 BP14 patch but not in OIM9102 BP20.

    Using OIM API calls, I am able to fetch usr_key and ugp_key succesfully when utilityFactory is initialized with system admin login.
    When utilityFactory is intialized with non system admin ID, usr_key and ugp_key is returning as "0".
    This code is working fine with OIM9102 BP14 patch but not in OIM9102 BP20. Do user need any access right to invoke API calls ? Any thing related to this is changed in this patch?
    Environment details:
    OIM 9102BP20
    Websphere 6.1

    No, no more rights are needed. If it is working fine into BP older than this one, raise a SR and ask support guys to file a bug. But you have to show them step-by-step working into the older one and not working on newer. It is quite difficult happen, but maybe this feature broken on new business patch 20.
    I hope this helps,
    THiago Leoncio.

  • Ftp works for start() but not for custom procedure sendFile()

    Hello,
    i'm busy building an ftp upload applet by using sun's ftp class sun.net.ftp.FtpClient and by including my applet in a signed jar.
    Now here's my problem. The code i have to ftp works fine when i put it into the applet's start() or init() procedures, but when i put the code into public void sendFile() and i call this procedure from javascript, it does call the procedure fine (i can check this by incrementing my progress bar - just for debug purposes), but seems to hang at a specific point when i try and get the length of the file (see the code). Here is the code that works in the start() procedure but not my sendFile procedure.
        public void sendFile() {
             try {
                ftpclient = new FtpClient(server);
                ftpclient.login(user, password);
                ftpclient.cd(dir);
                ftpclient.binary();
                progress.setPercentOn(true);
                byte abyte0[] = new byte[1024];
                File file1 = new File(file);
                // Applet seems to be hanging here?
                long l = file1.length();
                in = new FileInputStream(file);
                out = ftpclient.put(filename);
                long l1 = 0L;
                while(blncheck == true)
                    int i = in.read(abyte0);
                    if(i < 0) break;
                    out.write(abyte0, 0, i);
                    l1 += i;
                    long l2 = l1 * 100L;
                    long l3 = l2 / l;
                    progress.setValue(l3);
                out.close();
                in.close();
            } catch(Exception e) {
                e.printStackTrace();
    }Any idea why this code would only work in the applets start() and init() procedures?
    Help would be much appreciated
    Hagen

    Ok, the problem is with security. As soon as the html button accesses the applet, the following exception is thrown
    java.security.AccessControllException: access denied(java.io.FilePermission C:\blah.txt read)So my plan is to try and not use html but JButtons, then the signed applet shouldn't have a problem anymore

  • Hi, I have a Indesign user who inherited a PC with Indesign installed. Indesign works with old PC user profile but not the new user. Any ideas how I can resolve this?

    Hi, I have a Indesign user who inherited a PC with Indesign installed. Indesign works with old PC user profile but not the new user. Any ideas how I can resolve this?

    Question # 1 is what do you mean by "inherited"? Is this a case where the computer belonged to someone else? Your user would not be entitled to use a program licensed to someone else.

  • I have tried to download 5.0.1 on MAC X 10.6.8. Clicking download, I get a question from MAC --save or name application to open. Saving to desktop doesn't work. It appears in download, but not in desktop. What now? in English

    # Question
    I have tried to download 5.0.1 on MAC X 10.6.8. Clicking download, I get a question from MAC --save or name application to open. Saving to desktop doesn't work. It appears in download, but not in desktop. What now?

    On Mac OS, plugins are installed to a common location, usually ''' /Library/Internet Plugins''' for system-wide availability or to '''~/Library/Internet Plugins''' for a specific user. Ref: http://kb.mozillazine.org/Issues_related_to_plugins#Background
    Does Java 1.6.0_31 work on Safari or another browser?
    I also found the following, in case it helps:
    *http://reviews.cnet.com/8301-13727_7-57414869-263/how-to-use-java-applets-in-os-x-after-java-2012-003-update/
    *http://stackoverflow.com/questions/6411909/how-to-downgrade-jre-jdk-on-mac-osx

  • Home sharing is working fine for musics and videos but not for apps. What is wrong?

    Home sharing is working fine for musics and videos but not for apps. What is wrong?

    i had the same issue as everyone here after upgrading to itunes 10.x.  vista could see xp home share.  ipod touch could see xp home share.
    neither could see vista home share.
    after several hours of authorizing de-authorizing, rebooting router etc, i knew it had to be a firewall thingy with vista as xp was working fine
    i went to this article http://support.apple.com/kb/ht2553 and followed the instructions.  itunes was already in my vista exception list.  on a hunch i deleted the itunes exception and followed the steps to add it again and boom it worked!! i could now see my vista machine from my ipod touch immediately.
    something must have screwed up the firewall exception on the upgrade to itunes 10.x
    it worked for me, i hope this helps others

  • After update 7.1.0. my sound only works for phone calls,emails etc, but not for music or games

    after update 7.1.0. my sound only works for phone calls,emails etc, but not for music or games

    Maybe I understood your problem. Get to Settings > Sounds > Ringers and Alerts >Turn Change With Buttons to Off. And if your Side Switch is assigned to 'Mute', turn it back on, else, use the control center to turn off mute.
        P/s: And your name is...

Maybe you are looking for

  • S_ALR_87012249 report

    We are using transaction S_ALR_87012249 in order to generate financial reports for certain country , for certain company code. But since 5th period there are no new data. forexampe  if we view the report we get the following output but the issue is s

  • Icloud password issue

    Sorry this is very long but I feel I need to go into detail so there is a full understanding Hi I have a problem with an iPhone 4s this is a weird situation. To try and explain the best way I can took a phone out on contract about 2 years ago from or

  • Aggregates  (Levels)

    Hi, Somebody know if exist a Table where I can get the level of an aggregate? I have many Cubes with many aggregates (e.g. Aggregate 100100 Parent / 100101 Child / 100102 Grandson, etc..) I need to separate all aggregates Parents, and childs. **I kno

  • Safari won't open windows from JavaScript

    On my iMac running 10.6.3, direct links which use JavaScript to properly open up a small window in all other browsers, instead opens up a new full-sized tab in Safari. Some points: - This is not a JavaScript function calling window.open() indirectly,

  • I can't format a usb, it says it has no write permissions.

    When I open disk utilities the erase button is in grey and can't be clicked... I've tried using terminal and disk utilities, I also triede in a pc but it still says that the problem is I don't have write permission. How can I erase everything for goo