Cursor does not sort..

Hi,
I'm working with a package that has a cursor defined in it. the issue I'm having is the 'order by' does not see to be working and I cannot figure out why.
I'm hoping some smarter coders here will spot why it fails and tell me what I'm missing. I know the parameter is being passed, but it seems to just ignore the sort clause like it is not there at all.
here is the cursor:
cursor c1 is
select f.forecast_type,f.bus_area,f.prod_line,f.project_family_id,f.contract_type,f.program_type,f.project_number,f.order_type,f.profile_name,f.level_code,f.organization_id,
f.site_code, f.freeze_site_flag, f.proj_mgr_name, f.fin_lead_name, f.ms_empno, f.opm_empno, f.notes, trim(to_char(nvl(fv.y1_q1_sales,0),'L999,999')) y1_q1_sales, trim(to_char(nvl(fv.y2_q1_sales,0),'L999,999')) y2_q1_sales,
trim(to_char(nvl(fv.y3_q1_sales,0),'L999,999')) y3_q1_sales, trim(to_char(nvl(fv.y1_sales,0),'L999,999')) y1_sales, trim(to_char(nvl(fv.tot_funding,0),'L999,999')) tot_funding,
trim(to_char(nvl(fv.y1_q2_sales,0),'L999,999')) y1_q2_sales, trim(to_char(nvl(fv.y2_q2_sales,0),'L999,999')) y2_q2_sales, trim(to_char(nvl(fv.y3_q2_sales,0),'L999,999')) y3_q2_sales, trim(to_char(nvl(fv.y2_sales,0),'L999,999')) y2_sales,
trim(to_char(nvl(fv.tot_sales,0),'L999,999')) tot_sales, trim(to_char(nvl(fv.y1_q3_sales,0),'L999,999')) y1_q3_sales, trim(to_char(nvl(fv.y2_q3_sales,0),'L999,999')) y2_q3_sales, trim(to_char(nvl(fv.y3_q3_sales,0),'L999,999')) y3_q3_sales,
trim(to_char(nvl(fv.y3_sales,0),'L999,999')) y3_sales, trim(to_char(nvl(fv.tot_mfg_base,0),'L999,999')) tot_mfg_base, trim(to_char(nvl(fv.y1_q4_sales,0),'L999,999')) y1_q4_sales,
trim(to_char(nvl(fv.y2_q4_sales,0),'L999,999')) y2_q4_sales, trim(to_char(nvl(fv.y3_q4_sales,0),'L999,999')) y3_q4_sales, trim(to_char(nvl(fv.y4_sales,0),'L999,999')) y4_sales, trim(to_char(nvl(fv.tot_mtl_base,0),'L999,999')) tot_mtl_base,
trim(to_char(nvl(fv.y5_sales,0),'L999,999')) y5_sales, f.status_code, f.process_step, f.schedule_designator, null, f.status_date, f.date_in_step,
nvl(f.ready_to_proceed,'N') rdy_proceed_val, f.change_flags, fv.change_flags values_change_flags, rownum, f.freeze_site_flag freezeSite,
DECODE(f.freeze_site_flag,'Y','CHECKED onClick=javascript:site_freeze(this);','onClick=javascript:site_freeze(this);') freezeFlag,
DECODE(f.ready_to_proceed, 'Y', 'CHECKED onClick="javascript:set_proceed(this)";','onClick="javascript:set_proceed(this)";') ready_to_proceed
from bae_alm_forecast_values fv,
bae_alm_forecasts f
where f.rec_type = fv.rec_type(+)
and f.project_number = fv.project_number(+)
and decode(p_frcst_type,null,'1','A','1',f.forecast_type) = decode(p_frcst_type,null,'1','A','1',p_frcst_type)
and decode(p_bus_area,null,'3',instr(p_bus_area,f.bus_area)) > 0
and decode(p_prod_line,null,'4',instr(p_prod_line,f.prod_line)) > 0
and decode(p_prod_fam,null,'5',instr(p_prod_fam,to_char(f.project_family_id))) > 0
and (upper(f.contract_type) like decode(p_cont_type,null,'%',upper(p_cont_type)) or f.contract_type is null)
and (upper(f.program_type) like decode(p_pgm_type,null,'%',upper(p_pgm_type)) or f.program_type is null)
and (upper(f.project_number) like decode(p_prg_num,null,'%',upper(p_prg_num)) or f.project_number is null)
and decode(p_odr_type,null,'2',upper(f.order_type)) = decode(p_odr_type,null,'2',upper(p_odr_type))
and (upper(f.profile_name) like decode(p_desc,null,'%',upper(p_desc)) or f.profile_name is null)
and decode(p_level,null,'1','ALL','1',f.level_code) = decode(p_level,null,'1','ALL','1',p_level)
and f.rec_type = 'C'
order by p_sort_order;
the p_sort_order does contain valid data like either project_number, or program_type. yet when we run the package from the application it never sorts it by the passed value.. I don't understand why. the cursor is called with a for c1_row in c1 loop call...
could it be the for loop or the cursor that is the issue in this?

Nothing wrong with Oracle here, just your understanding of how this works.
You're not ordering by a column name the way you are going about this now, you're ordering by a literal value.
select * from all_objects order by 'TUBBY';Is basically what you're doing. In order to make this work you need dynamic SQL ... i'll caution you now though that this isn't a good approach to take. Dynamic SQL is a cruel mistress and imposes many penalties on you for using it (performance, security, etc...).
If you are forced to do something like below, please check out the DBMS_ASSERT package to ensure that you don't get hit with any SQL Injection possibilities.
The first block below is what you are doing now ... the second is what you'd need to do.
ME_XE?variable rc refcursor;
ME_XE?
ME_XE?declare
  2     l_sort_column   varchar2(30) := 'OBJECT_NAME';
  3  begin
  4     open :rc for
  5     select
  6             object_name
  7     from
  8     (
  9             select *
10             from all_objects
11             order by l_sort_column
12     )
13     where rownum <= 2;
14  end;
15  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
ME_XE?
ME_XE?print :rc;
OBJECT_NAME
ICOL$
I_USER1
2 rows selected.
Elapsed: 00:00:00.01
ME_XE?variable rc refcursor;
ME_XE?
ME_XE?declare
  2     l_sort_column   varchar2(30) := 'OBJECT_NAME';
  3  begin
  4     open :rc for
  5             'select
  6                     object_name
  7             from
  8             (
  9                     select *
10                     from all_objects
11                     order by ' || l_sort_column || '
12             )
13             where rownum <= 2';
14  end;
15  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.02
ME_XE?
ME_XE?print :rc;
OBJECT_NAME
A1
A2
2 rows selected.
Elapsed: 00:00:01.67Edited by: Tubby on Feb 8, 2012 4:21 PM
I actually found a better resource for you, please give this a read
http://www.oracle.com/technetwork/issue-archive/o44asktom-089519.html
starting at "Order Anything"

Similar Messages

  • Creative ZEN, Albums fused, does not sort albums correctly!

    ;Creative ZEN, Albums fused, does not sort albums correctly! http://nl.creative.com/products/prod...t=6999&listby=
    Creative ZEN, Albums fused, does not sort albums correctly!
    I attach my Creative Zen to my computer true USB,
    I manually copy Albums to my creative zen.
    If i view my (ZEN) folder in Windows XP, everything looks great and sorted!
    I safely remove my ZEN player from my computer,.
    The ZEN rebuilds his data.
    I go and view albums, and what do i see each time! over and over again!
    Albums fused together, albums scattered true each other, MOST albums got different names then in windows XP!
    I get really frustrated from this! how can i make this right!
    I want the ZEN to show the albums like in WINDOWS XP! how hard can this be!!!
    Thanks for the help in advance!
    Greetz!
    Support4u

    Hi,
    The Creative ZEN organizes songs according to the ID3tag of the music file, not by folders. If you want to arrange the music files in the order you want, please check and make sure that the music files are tagged properly. You may need a third-party tag editor to do this.

  • HT1347 I have an mp3 DVD with episodes of Gunsmoke.  iTunes imports them, but does not sort them correctly by date or episode.  One file name is GS 52-04-26 001 Billy the Kid.mp3

    I have an mp3 DVD with episodes of Gunsmoke.  iTunes imports them, but does not sort them correctly by date or episode.  One file name is GS 52-04-26 001 Billy the Kid.mp3.  iTunes sorts them by month/day/year.  How can I fix that?

    The weird thing is, it worked before. I encoded all the videos previously and had them all listed and didn't encounter this problem, but I noticed I'd forgotten to decomb/detelecine the videos so I deleted everything and re-encoded it all. AFter filling the tags out and setting poster frames again I was thinking of making life easier by just pasting the same artwork for every episode, so I did, but didn't like the results so I deleted it again (I selected every video, used Get Info and pasted the artwork that way).
    I think it was after this that the problem started to occur. In any case I've been through every episode and made sure the name, series, episode and episode id fields are all filled in with incremental values and they are. I even made sure the Sort Name field was filled in on every video. But this didn't work either.
    So, thinking another restart was needed I deleted every video again. Re-encoded them all, again. Set the tags for every video and poster frame again. Finished it all off nicely, checked cover flow and was highly annoyed to find it was STILL showing the same two pieces of art work for every video as shown in that image I posted.
    Ultimately, I wouldn't care so much that cover flow is screwing up like this as I always intended to sort by program anyway so it would only ever display one piece of artwork for an entire series of videos, however where-as when it was working it picked the artwork for the first episode of a series to display, its instead picking one of the latter episodes. I can't seem to find any way of choosing what artwork I want displayed.

  • Entering values in TableMaintenance,cursor does not stop at error record ?

    Hello,
    Very Good Morning!
    When creating new entries in Table Maintenance, Cursor does not stop at the error record. It display's an error where the error is. But, cursor will skip to the first field of the record.
    Ex : Sales Org, Mater, Sales Obj %, Frist arr date.
    Suppose these are the fields available and I want to create a new entry.
    When i enter incorrect value in Sales Obj %, it is displaying error message saying that i need to enter correct value. But the Cursor is skipping away to the first field Sales Org.
    PLease help what to do...I tried using set cursor. But, I am not sure how to excatly use it and it was not working. 
    Any help will be appreciated.....
    Thanks & Regards,
    Krishna Chaitanya

    Hello,
    This question is not answered.
    I want to close this question.

  • Cursor does not change when hovering over pop-up window link

    I created a text link for a pop-up window. The link does work, but the cursor does not change to a pointy finger, the standard link icon.
    I don't know a lot of javascript, but can figure it out if it's just adding some code.This was done in CS3. Any help would be appreciated! Here's the code:
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    Thanks in advance.
    Todd

    A link would be nice but I suspect that you are not gettign the finger (you knwo what I mean) when you roll over the link because your href is  not set to anything.
    <a href="" onclick=MM_openBrWindow('images/image.jpg','largeDisplay','scrollbars=yes,resizable=yes,width=100,height=120')
    Set your href to "#" or "javascript:;" - the latter is preferred.

  • HT4113 My daughters iPod touch asks for her pass code but when she types it in the cursor does not move or input any characters so,she cannot get into the iPod. This has suddenly happened for no apparent reason

    My daughters iPod touch asks for her pass code but when she types it in the cursor does not move or input any characters so,she cannot get into the iPod. This has suddenly happened for no apparent reason, what can we do? Can anyone help please?

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try on another computer
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar       

  • Cursor does not click the sign-out button in yahoo, rediff etc pages ?

    cursor does not click the sign-out button in yahoo, rediff etc pages. E.G once I open my yahoo page, the cursor pointer will not change it's appearance to the finger type when I try to click the sign-out or inbox button. This does not happen with chrome or explorer.

    That problem can be caused by the Yahoo! Toolbar or the Babylon extension that extents too much downwards and covers the top part of the browser window and thus makes links and buttons in that part of the screen not clickable.
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    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

  • Cursor does not move, Cursor does not move

    Cursor does not move, can not be controlled by wireless mouse and normal mouse, Are there any solution for this problem? Thank!

    in selecting the word, it is very difficult to just place a cursor in the word to make any correction, because it wants to highlight it and it is near impossible to deselect
    The standard mouse/text selection action should only select a word when you double-click it. Therefore you should be able to position the cursor within a word by just single-clicking it.
    when I do finally get a cursor to appear instead of a highlighted word, the arrow keys don't move the cursor to where I need it
    That certainly sounds amiss. I don't think I've ever seen a case where the cursor keys don't move.
    So I'm thinking Leopard must have some preference / key preference thing going on?
    There is a Keyboard & Mouse preference pane in System Preferences which is clearly the place to start, but off-hand I can't think which options there would cause this kind of setup.

  • Tool cursor does not change or does not show up

    If you change tools in Photoshop but the cursor does not change (or disappears entirely), this indicates a bug in your video card driver. To fix it, you need to update your video card driver.
    Sometimes you can fix it temporarily by turning down the hardware or driver acceleration in the properties panel for the video card.

    Chris Cox 11/23/02 4:59pm

  • Cursor does not change during the editing of clips

    Hi. I am new to iMovie and am looking for some help. I have imported my clips, put them in my timeline and I want to shorten the clips. According to the movie that is on the Apple web site, when moving my cursor over the line separating my clips, my cursor is to 'change' allowing me to shorten the clip. Well, my cursor does not change. Is there a setting that needs to be corrected. Thanks for any help that can be offered.

    Hi konrad - the View Menu DOES have a 'Show Clip Volume Levels" IF you are using iMovie HD!
    But according to your Profile you have iMovie 4. Volume control in that version is at the bottom beneath the Timeline Audio tracks.
    Hope this helps clear up your confusion.
    Better to use the iMovie 4 forum in your case!:-)

  • Cursor does not change for pop-up window

    I created a link for a pop-up window. The link does work, but the cursor does not change to a pointy finger, the standard link icon.
    I don't know a lot of javascript, but can figure it out if it's just adding some code. Any help would be appreciated! Here's the code:
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    Thanks in advance.
    Todd

    Hi Todd,
    i got the same problem.(cursor not change for pop-up windows) and because i m not an expert in internal html code i did try several solutions to fix it.
    The easiest (but also even longer if u need to do severals) is to create a button (withs 2 overflight changing pics) with "inserer", "image survolée"
    the "image survolée" can be linked to a pop-up window with the correct effect.  To do so highlight the "expected new link to" and on right side task bar ad a "comportement" named "ouvrir la fenetre du navigateur" and optionally choose the size and windows available function of the pop-up. It works even if u need to proceed first with an overflight changing button.
    The result is longer to obtain and not absolutely perfect. So I guess it s only an help solution for a single mateer. i would be glad to get another solution with a text link rather than using the overflight button system. Technically it should be better, more efficient and faster to proceed with applying an html code that really makes the text appearing as a classic link to a new windows whatever pop up or full size window. Please let me know if u get further answer to fix this problem.
    Many thx and excuse my technical english translation about DreamCs4

  • Cursor does not follow in garage band

    I click on record and the cursor does not move so I can not follow in what part of the timeline I'm, how can I solve this?

    Well, I closed Garage Band and reopen it and it solved the issue, go figure!!

  • Cursor does not move.

    On my IMAC the cursor does not move, but show connected and the click works. just will not move cursor on the screen. I doen the following.
    - replaced batteries
    - restarted computer
    - unplugged computer and restart
    - restart while hold command+options+P+R
    oh ya, I did notice my picture for my log on changed.
    Please help.
    thanks

    Bootup holding CMD+r, or the Option/alt key to boot from the Restore partition & use Disk Utility from there to Repair the Disk, then Repair Permissions.
    Does the mouse move booted from that partition?
    Do you have a USB Mouse to try?

  • Cursor does not change to a circle when using eraser

    Cursor does not change to a circle when using the eraser.
    I'm sure it must be a tick box somewhere.
    Its always been ok previously.

    I had this same problem and was searching for answers. I also prefer using a circle instead of crosshairs. I hope you've figured it out by now, but, if you haven't, here is the answer (I am using Elements 9, but, it should work for other versions I think):
    1. Open up Elements Editor, Click on Edit, Click on Preferences, Click on Display & Cursors.
    2. Under Painting Cursors, select Full Size Brush Tip
    3. (optional) - if you want crosshairs within your circle, then also select Show Crosshair in Brush Tip.
    4. Click ok.
    Now use the brush, and it should have a circle to use.
    P.S. Sometimes if you have your Caps Lock key on, that removes the circle as well.

  • Cursor does not appear on Facebook page load. Spacebar shifts page down.

    Cursor does not appear anywhere on Facebook page load. It used to land in the first text box, and as I was used to this I would open an FB page and start typing. Nothing was entered into the text box, and when I hit Spacebar it shifts the page down.
    Couple of things:
    It acts this way both in normal and in "safe mode".
    It acts correctly on Google - it is my home page and when I open it the cursor is always in the search box. It also acts correctly on YouTube.
    The cursor DOES NOT appear in the URL bar (thankfully)
    The cursor DOES NOT appear in any text boxes on any other pages I open >> The Weather Channel, TED.com, Amazon.com
    The Spacebar scrolls the screen down one frame at a time.
    It has the same behavior with the "Always use the cursor keys to navigate within pages
    I am using FF 18.0.1 on Windows XP
    I have tried a lot of the weird tips and tricks suggested on this support forum, but none of them address specifically this issue.
    Thanks in advance.

    If I'm not logged on then the cursor is in the login form at the top.<br />
    Once logged in the main body has focus and not a specific element, so you have to click in an input filed to set focus to it.
    If it worked before then they have changed the code of that page recently and it is just a coincidence that it happened around the time that Firefox updated.

Maybe you are looking for