ESQL/C: Difficulties with DECLARE CURSOR  and nested FROM CLAUSE

Hello @All,
i am trying to migrate an old esql-c-Application to Oracle 11g (on 64-Bit-AIX 7.1 - Platform)
PreCompiling is OK, but during runtime the following DECLARE - Statement returns ORA-01001: invalid cursor :
EXEC SQL
DECLARE cur_xyz CURSOR FOR
SELECT vPE, mPE, mZW, COUNT (*)
FROM ( SELECT v.K_PE AS vPE, m.K_PE AS mPE, m.ZW AS mZW, v.VKG
FROM ( SELECT K_NR, K_PE, u3.VKG, POS
FROM u3, r
WHERE u3.K_NR = '999999'
AND     u3.LANG = 'F'
AND SUBSTR (PRTCTRL, 5, 1) > '0'
AND u3.VKG = r.VKG ( + )
) v, m
WHERE
v.K_NR = m.K_NR ( + )
AND v.K_PE = m.K_PE ( + )
AND POS is Null
) X
WHERE not EXISTS (SELECT VKG FROM NP WHERE X.VKG = NP.VKG )
GROUP BY vPE, mPE, mZW
ORDER BY vPE
When I run this statement without "EXEC SQL DECLARE cur_xyz CURSOR FOR" in SQL-Developer, there is no problem.
What is my fault? I hope, that I don't have to redesign this.
Thx in advance for anyonce help.

Hey Billy,
I work in a C/C++-Environment under AIX. I allready build a library with with more than x.000 Functions with ESQL-Statements.
Most of them are running.
If I need a CURSOR, I allways use constructs like this:
EXEC SQL DECLARE CursorName [SCROLL]CURSOR FOR
SELECT ...
if (SQLC == 0) {
EXEC SQL OPEN CursorName;
while (SQLC == 0) {
EXEC SQL FETCH ... CursorName INTO :<Structure or Fieldlist>;
EXEC SQL CLOSE CursorName;
At the Moment, I don't work with a cursor-variable in the DECLARE-Section.
In the case i discribed above, it is the first, where the ORA-01001 occurs.
Is it necessary to work with SQL_CURSOR - Variable in all or in special cases?
Thx 4 answers.

Similar Messages

  • OCI doc says Cursor and Nested table have the same bind type SQLT_RSET but they don't

    5 Binding and Defining in OCI
    PL/SQL REF CURSORs and Nested Tables in OCI
    says SQLT_RSET is passed for the dty parameter.
    If I use SQLT_RSET for the return value of a function that returns a table and pass a statement handle's address for the OCI parameter data pointer, I expected that the statement handle will be instantiated as a result of executing the function on which I can further perform fetch, similar to a cursor. But it throws exception PLS-00382: expression is of wrong type ORA-06550: line 2, column 3. Is the above documentation wrong?
    From the OCI header file I see that for varray and nested table it mentions to use SQLT_NCO. I could find no example in the OCI documentation on how to pass or receive as return value a nested value when using SQLT_NCO.
    Please help before I shoot myself.

    So the Nested table I quoted in the doc is not actually used to mean a table type below?
    create type t_resultsetdata as object (
    i int, d decimal, c varchar(10)
    create type t_nested_resultsetdata as table of t_resultsetdata;
    create function Blah return t_nested_resultsetdata  is . . .
    For this you are saying to use SQL_NTY and not SQL_NCO. Can you tell where this usage is documented, because ocidfn.h says
    #define SQLT_NTY  108                              
    /* named object type */
    #define SQLT_NCO  122 
    /* named collection type (varray or nested table) */
    Another question - Because of the original document I said I followed, I thought I could treat cursor and nested table similarly in the calling application, i.e. I could repeatedly do a fetch on the OCIStmt* which will be bound for nested table. Now from what you say I understand I can't really bind a OCIStmt* for nested table but have an object type. That means it will get all the data of that collection in one go, right? LIke I said, lack of examples is making this tough. I don't want to look into OCI source code, as that will be too much.

  • I want to make a textfield non editable with blinking cursor,and the text is input from a custom keypad

    I want to make a textfield non editable with blinking cursor,and the text is input from a custom keypad....
    Please Help me.
    I want to make a numpad of my own from which i can set the text but i want the user to tap in between the text..

    You seem to stop the while loop to run the following code, then the program ends. Are you running this using the "continuous run" button????
    You need one big while loop containing the acquisition, then you build up the history data in a shift register. Clicking "save" will save the data, but not stop the loop.
    Why did you place a time-control in the FOR loop??? This is just post-processing so it should just do it without any delays. I don't understand the logic in the FOR loop. You are appending arrays, but then you delete the first element at each iteraction constantly trimming data from the beginning of the appended array. Then you autoindex at the output tunnel heavily duplicating all data. Ths make s no sense!
    Can you explain how you want you data saved?
    Message Edited by altenbach on 12-16-2005 11:20 AM
    LabVIEW Champion . Do more with less code and in less time .

  • I hate it i am fed up it so diffiuclt Why they make it so difficult with transferring photos contacts data from iphone 5s to pc .!!!!!!!!!!!!!!!!!!!!!!!!!!!

    i hate it i am fed up it so diffiuclt Why they make it so difficult with transferring photos contacts data from iphone 5s to pc .!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Hook the phone to the computer, open the Computer icon and look for the iPhone folder. Copy the images. Not difficult at all. Sync your contacts with Outlook through iTunes. Not really so difficult.

  • Is there a way to recover deleted pictures taken with my iPhone and deleted from PhotoStream

    is there a way to recover deleted pictures taken with my iPhone and deleted from PhotoStream on the same iPhone?

    Here's general advice:
    You should be importing all pics taken with the iphone to your computer regularly as you would with any digital camera. 
    iOS: Importing personal photos and videos from iOS devices to your computer

  • Results for my browser has prob with 1st inch and harf from new babbilon crap will not hipolink i can not sign in or register on any thing please help

    results for my browser has prob with 1st inch and harf from new babbilon crap will not hipolink i can not sign in or register on any thing please help

    has anyone solve this problem? i upgraded my iphone 4 to 5.1.1 and now i can see only ""We're sorry, we are unable to continue with your activation at this time.  Please try again later, or contact customer care."
    i tried mani sim card, laptops, wifi. but for 7 days the problem is still exist....
    Please help me!!!

  • Problem with generating xml and nested cursor (ora-600)

    I have a problem with generating xml (with dbms_xmlquery or xmlgen) and nested cursors.
    When I execute the following command, I get a ORA-600 error:
    select dbms_xmlquery.getxml('select mst_id
    , mst_source
    , cursor(select per.*
    , cursor(select ftm_fdf_number
    , ftm_value
    from t_feature_master
    where ftm_mstr_id = pers_master_id ) as features
    from t_person per
    where pers_master_id = mst_id ) as persons
    from f_master
    where mst_id = 3059435')
    from dual;
    <?xml version = '1.0'?>
    <ERROR>oracle.xml.sql.OracleXMLSQLException: ORA-00600: internal error code, arguments: [kokbnp2], [1731], [], [], [], [], [], []
    </ERROR>
    The problem is the second cursor (t_feature_master).
    I want to generate this:
    <master>
    <..>
    <persons>
    <..>
    <features>
    <..>
    </features>
    </persons>
    <persons>
    <..>
    <features>
    <..>
    </features>
    </persons>
    </master>
    If i execute the select-statement in sql-plus, then I get the next result.
    MST_ID MST_SOURCE PERSONS
    3059435 GG CURSOR STATEMENT : 3
    CURSOR STATEMENT : 3
    PERS_MASTER_ID PERS_TITLE PERS_INITI PERS_FIRSTNAME PERS_MIDDL PERS_LASTNAME
    3059435 W. Name
    CURSOR STATEMENT : 15
    FTM_FDF_NUMBER FTM_VALUE
    1 [email protected]
    10 ....
    I use Oracle 8.1.7.4 with Oracle XDK v9.2.0.5.0.
    Is this a bug and do somebody know a workaround?

    Very simple...Drop all type objects and nested tables and create them again. You will get no error. I'll explain the reason later.

  • SQL Loader Constraints with Column Objects and Nested Tables

    I am working on loading a Table that (god forbid) contains columns, column objects, and nested tables (which contains several depth of column objects). My question is does SQL Loader have a hidding undocumented feature where it states how the column objects must be grouped in refereneced to the nested tables within the loader file? I can load the various column objects, and nested tables fine right now, however, I am loading them all in strange and insane order. Can anyone answer this question? Thanks.
    Peter

    I just noticed that my email is wrong. If you can help, plese send email to [email protected]
    thanks.

  • Difficulties with movie clips and frames

    This is really irking me.
    I am extremely new to Flash so please bear with me. I am assuming that this is a simple, easy to fix problem that I am having. I have Adobe Flash Professional CS5.5.
    What I am trying to do is display a sequence of images after other movie clips stop playing.
    The image sequence itself does what it is supposed to and works properly, and the other movie clips also are successful. However, whenever I try to put the movie clips for the images in frames or keyframes, the beginning movie clips only play part of the way before the images show up. This happens even though the images' movie clips are on frames/keyframes (I've tried both) after the other movie clips.
    The movie clips that are supposed to play first are each on a separate layer and there are two of them.
    The first layer is called "tree" and the second is called "text"
    The tree layer has a 45-frame gif animation that I have turned into a movie clip. I have created a motion tween and changed its alpha so that the gif has a fading in and out effect. I also have it so that it stops replaying once it reaches the last frame. I am using stop(); for this.
    The text layer has a 40-frame gif animation that I have also turned into a gif. This gif is also a movie clip and also has motion tween. Its alpha has also been changed.
    Both tree and text play together successfully and how I want them to.
    The sequence of images is three separate images, each a different layer, that fade into eachother. These images are pngs, therefore they aren't gifs nor do they have their own frames.
    The bottom layer is called floor1 and has frames 1 through 50 of motion tween and alpha adjustments fading the png image. The image is a movie clip.
    The layer on top is called floor2 and has frames 51-100 of a different png image fading.
    The very top layer is called floor3 and has frames 101-150 of yet another png fading.
    The images are successful in doing what they are supposed to.
    Layers tree and text are one fla file, and layers floor1, floor2, and floor3 are a separate fla file.
    When I copy the frames from layers floor1, floor2, and floor3 into a keyframe after layers text and tree, they transfer properly, but when I test the animation, the image sequence shows up a lot sooner than it is supposed to, interrupting the movie clips on the layers text and tree. I have tried moving the floor# layers' keyframes farther down the timeline, but then the other movie clips just stop.
    In the fla file with layers text and tree, I've imported the gifs into the library and then put them onto the stage.
    In the fla file with the floor# layers, I've imported the pngs into the stage.
    Here's what the text and tree layers look like:
    Here's what the floor# layers look like:
    The rest of the frames for the floor#s...
    So, I thought that the problem was that I needed to delay the image squence. I looked around and found no code or anything for that..
    Afterwards, I thought that it was because I had imported the tree and text gifs to the library before putting them on the stage.
    I opened a new fla and imported the "tree" gif straight to the stage.
    I figured that this should work because then it would show each of the individual frames in the movie clips, which it doesn't do in the above pictures. By importing the gif like this, it does show the individual frames. I've tested this with the image sequence and it works fine. But I have a problem with this method too..
    I select all of the frames for the gif to convert into a symbol, so I can add a motion tween and mess with the alpha. However, only the last frame is converted into a movie clip. Well actually no... Only the circled frames below are turned into the movie clip. Even when all of the frames are selected.  This isn't very helpful because then I can't change the alpha for the entire gif nor can I create a motion tween without getting a message saying that the motion tween could not be applied to all of the frames.
    Here's what this version of "tree" looks like.
    And the frames continue like so until 135.
    The frames that are turned into the movie clip are circled below.
    If I can solve the issue that I'm having with the tree shown in the two pictures above this sentence, then I can display the movie clips and image sequence without a problem. It wouldn't be quite how I had intended it to be, but it would be successful and would still work.
    If I can fix the problem with the image sequence showing up to early, and of the tree and text movie clips being cut off, then this project would also be successful and it would be how I had wanted it to be.
    If you need clarification, let me know and I'll explain something better.
    I am not willing to provide a download link in this forum for my fla files, but I can email them to you if you would like a look. I just don't want someone to be able to find them and take them by doing a google search.
    I have uploaded two swfs though.
    The first is of the tree and text layers/movie clips working as they are supposed to. The second is of the image sequence (floor1, floor2, floor3) doing what it is supposed to.
    Text and tree: http://glassoliverdesigns.weebly.com/uploads/1/0/6/5/10653451/tfg1.swf
    Floor1, floor2, floor3: http://glassoliverdesigns.weebly.com/uploads/1/0/6/5/10653451/tfg2.swf
    Notice how at the end of the text and tree swf, when the text stops the thing in the background keeps flashing. If that can keep flashing WHILE the images appear, then that would be great.
    TL;DR: I want the floor# flash to show up after the text and tree flash but I keep having problems and nothing I try is working properly.

    Very concise question, appreciate the screenshots. One thing that motion tweens don't always show very well is keyframes. Let me clear a few things up and see if it helps.
    Go back to what you wanted to do originally, which is copying the frames from one document to another. This is perfectly fine and to clear it up, it will also copy any library elements (images, clips, etc) that are required to copy those frames for you, so you do not need to import them yourself.
    To successfully copy frames (not symbols), select the first frame of the frames you want to copy, hold shift and select the last frame (alternatively double clicking anywhere in the blue motion tween should select it all as well). Now right-click and "Copy Frames". Now go into your new document, select a frame, right-click and select Paste Frames. You will see the same frames copied over, the blue representing the tween and keyframes came with it and you finally will notice all your images/etc were copied into your library.
    Now is a good time to manage the library clutter that was just copied in, if you're a clean freak like me.
    This process is the same, as you tried, for the other documents you want to copy in. If any resources match in name then Flash will ask you if you want to "overwrite" that library item. If you do that,  you will break one of your previous animations. Make sure that's not the case.
    The common gotcha here is not knowing how to slide frames over properly. If overwriting isn't the issue, this is what I suspect your problem is and as you expand/contract the timeline the keyframes aren't going with you.
    For example if I import 2 clips with fade in/out and move keyframes as you did I'll get something like this:
    Now moving them over I would be very careful to select all of the frames I want to move via the methods above. Click the first frame, hold shift and select the last frame, or double-click anywhere in the middle of the blue. The selection of frames:
    Now I simply drag my selected frames to the right, notice the keyframes stay as they should (the black dots):
    The animation plays as expected.
    Lastly I'm not sure if you've ever used the panel but you should really get used to the Motion Editor. This gives you control over easing as well as shows you an in-depth view of the keyframes that exist in a selected motion tween.
    At first this panel may look complex but it simply represents the basic properties you can animate. Any more properties you animate can be added in here. I moved the X, Y and Alpha properties of my object. So you can see over the frames 30-60 what I did. You can also adjust basic easing here.
    If your animations don't look correct you can select a motion tween, open the motion editor and verify the keyframes look correct. Scrub the timeline and look at the values you're interested in. Alpha for example, for you.
    If you don't see any keyframes when you scrub the timeline, you moved your frames over incorrectly and the keyframes probably exist in a different place and therefore it appears incorrect.

  • Gradient Tool difficulties with the mask and banner, CS4

    Hi everyone,
    I know this is quite basic, but I'm experiencing a mind block.
    I'm trying to make a banner image fade out to the left into a white background (which has text, this is the rest of the banner) losing as little as the image as possible, it has to be done with a mask as I don't want to edit the original image.
    I don't think feathering works
    At the moment I try this, I put a mask over the banner image, the mask is longer to the left than the banner image. But then when I try and apply the gradient tool to the mask it just slaps it on the image itself making it go all white.
    I've been using photoshop for a while now, just my brain isn't working properly today. Any help appreciated. Thanks

    Try this. First make sure your text is on a layer or background and the image that will be transparent is on another layer above the background with the text. If you already have a mask showing in the layer that will be transparent, just right click on it and choose Delete Layer mask. Then create a new one by clicking on the "Add Layer Mask" button at the bottom of the layer's palette (resting mouse on button shows the name). Press the g key on your keyboard to get the Gradient tool, and to make sure it is working as expected right click on its icon in the the tool options' bar that is at the top left under the main menu and choose Reset Tool. Then make sure that the foreground color swatch at the bottom of the Tools palette is black (to ensure that press d key and if necessary x to get that). Next hold Shift and drag from left edge of the image that will be transparent all the way to the right edge. Now you should have the fading transparency, for additional control while at that step press Crtl + L on your keyboard and drag the arrows of the Input levels there to adjust the gradient as you like.
    Hope this helps

  • Connection difficulties with Lumia 800 and CK 100

    I have a Nokia Lumia 800 and an installed CK-100 car kit, the kit has been professionally installed and works as it should do ie it is switched on with the car ignition and can be paired with both my Lumia and my partners Samsung via bluetooth.
    The problem I am having is the car kit keeps connecting with the phone resulting in two beeps through the speakers as it confirms it has connected both the phone and player function.  This repeats every 1 minute and is very frustrating.  It does this almost non stop although some times after about 10 -15 connects it suddenly disconnects.
    I have found a way to stop this happening, but it is not ideal and certainly not how a hands free kit should be, as follows;
    Set the Lock function to its max setting (5 minutes) and tile to the Bluetooth screen, then by constantly touching the screen every 5 mins to keep the Bluetooth settings screen open it works.
    I have sent two emails to the Nokia help centre (both times it is clear that they do not understand the questions) and have phoned the help desk twice, on one of the occasions the help desk person told me to reset the phone (which clears all your setting, Apps etc) and it worked fine for 4 days then started as above.
    Anybody got any ideas? to me it looks like the bluetooth setting is doing something when it is in sleep mode.
    Regards
    martyn

    Check whether you may have use your Lumia 800 on another PC initially so it has it's primary sync relationship with that PC.
    When you connect your Lumia with your PC and Zune starts select 'phone' and verify the sync relationship which is shown below the phone image. If this says 'guest' you will have to click 'Change Sync Relationship' to move it to the PC you are using.
    On any other PC you can remove the phone from the list of know devices through Settings>phone>sync options and click 'forget this phone for each phone you wish to remove. If multiple phone are known to this install of Zune you will see left and right arrows besides the phone image with which you can select the phone to change settings for.
    Press the 'Accept As Solution' icon if I have solved your problem, click on the Star Icon below if my advice has helped you!

  • High bill with unusual calls and texts from non-functioning numbers?

    We have a family share plan with 3 phones, one phone for my husband and two phones for our employees.  Our usual phone bill runs around $150.  Our last bill was over $600, the majority charges being on one of our employee's lines.  This particular employee has been with us for over 10 years, and has always been extremely trustworthy and very frugal in his usage of his phone to make personal calls (very infrequent and always less than 5 minutes in duration, unless made during the free nights and weekends timeframe).  Our latest bill showed over 1,000 texts to/from his phone, as well as over 3,000 peak calling minutes (both to/from his phone) alone.  Many of the peak calls are lengthy in duration (30+ minutes, up to 120 minutes).  I realize this post is long, so will divide it into headings so that it makes more sense:
    Information on usage:
    Our employee insists that he did not make these calls and texts (he does not even know how to text), and what is odd about the numbers that appear on the detail (both text and voice) is that they fit into one of two categories:
    1.  There are calls to two particular non-local area code numbers (and possibly bogus, as they have area codes 523 and 352(?)).  When I call the two numbers, I get the following messages:
    From my landline:  When called from my landline, adding a "1" before the 10 digit number, I get the recording stating that "your number cannot be completed as dialed, please check the number and dial again"
    From a cell number- When calling from my own VZW phone (on separate account from husband's), I get a VZW message that the number "has been changed, disconnected or is no longer in service"
    2. They are local area code numbers, but when I call the number, I get a recording asking me to enter my pin number (in other words, they are numbers that cannot receive incoming calls, but according to our bill, have not only made calls to our employee's phone, but also received calls.  I have done an online lookup on these numbers and they are all cell phones.
    3.  When I have tried to text the non-local numbers from my VZW phone, I get messages back stating that these are landline numbers and cannot be texted; when I text the local numbers, I have texted a generic message along the lines of "I can't reach you on the phone.  Please call me as soon as you can" but I do not receive a call back.
    We cannot speak directly with our employee right now (he is in Mexico to pick up his elderly grandmother),  nor can we access our employee's phone to check the log, call history, etc. because he has the phone with him.  Due to this, when we discovered the high usage, we immediately "suspended" the phone line so that no calls could be made or received.  Subsequent to suspending the line, we have talked to his family a couple of times -- one time he happened to call them on another line, so we talked to him "indirectly" through a family member on another line with him.  He was alarmed about the calls and insists he did not make them. 
    He does have children but they are forbidden (by him) from using the phone, and he states that he always keeps the phone in a case on his hip, thus no one else has access to the phone.  To go even further, it seems that most all of the calls to these unusual numbers are made on weekdays, during school hours, so I feel sure the calls were not made by his kids.
    Calls to Verizon:  When we first called Verizon, they suggested we suspend the phone until we could speak to our employee.  Subsequent to our indirect conversation with him mentioned above, we called them back and told them he stated that he did not make the calls nor send the texts, and that we believed the phone might have been compromised, cloned, hijacked or whatever.  First, the customer svc rep looked at our account and suggested that we put an unlimited text on the phone for the current unbilled usage (there were a lot of texts, and we have no text plan on the employee's phone), and then remove that plan once we get to the bottom of this matter. 
    Due to our concern about fraudulent usage, the customer svc. rep called the fraud dept. while my husband was holding on the line.  She came back on the line and told my husband that the fraud dept. said that "it cannot be fraud because if it was, there would be thousands of dollars in international long distance to countries like Pakistan and India." (WTH?)  Also, she said that it couldn't be fraud "because texts were sent to and from the telephone number so we know it was your phone."  (another WTH?)
    She then went on to say that it looks like texts were sent to international numbers (???) recently (these same 523 and 352 area code numbers I referred to above).  Number one, if these were international texts, it seems odd to me that these texts show up on our billed and unbilled activity as "domestic text" and there is no premium charge assessed to our account for international texts.  Number two, if these numbers were international numbers, I imagine that we would be charged for outgoing international calls, which we were not.  Further, I imagine that the numbers would be displayed on our bill in other than a ten digit format, but am not sure, as no one has ever made an international call or text on our phone.
    Next steps:
    Does anyone have advice for the next steps we should take and how we can get to someone in customer service who can actually help us with this problem, instead of what we experienced on our previous call?  Can we demand that Verizon launch an investigation through its fraud department on the activity on this phone, or is this at the discretion of VZW to launch an investigation?  I am unsure, since this was not given as an option by the customer service rep... 
    If we can get Verizon to launch an investigation, is payment of the portion of the bill with the unusual and disputed usage (namely, that which is over and above the usual usage) waived pending the investigation results, or will we have to pay the entire bill to both avoid having the phones turned off, as well as any detrimental effects to our credit?  We've been hit hard by the economy, both personally (I am out of work right now) and business wise (my husband's business has been doing only about 25% of its usual business), and we don't have the extra $$ for the bill unless we take it out of our grocery budget. 
    If anyone has any insight, suggestions or otherwise, I sure would appreciate it.  Sorry for the lengthy first post, but I thought it would be helpful to outline as much about the situation as I could in order that people could respond.  Thanks in advance!

    kbinga,
    I know this is a confusing and frustrating situation for you. I would be happy to review the account in detail to see what is happening with the usage and charges to ensure it does not continue to be a problem for you. Please send me a direct message for further support assistance.
    Thank you!
    AdamE_VZW
    Follow us at @VZWSupport

  • Can only print with manual feed and NOT from the paper tray from websites

    When I try to print something from a website, I must manually feed the paper in the manual feed slot. It will not print from the tray. This problem does not happen when I print something from an email with no downloads or something from MSword or Excel. So, it's most likely a browser printer setting issue. Any ideas?
    Thanks

    Probably related to printer preferences and how they relate to Firefox. If you did the complete reset all the printer setting that Firefox would saved would have been cleared and gone back to the default settings. Without familiarity with that specific printer ''(or even knowing which printer you are using)'' the best advice I can offer is to seek help from a support forum for that brand printer, or for you to reinstall the printer software to get back to the defaults.

  • Difference between Replacement with a query and Replacement from Variable

    Hi Gurus
    Would explain the difference between the Replacement Path: Replacement with a query and Replacement Path: Replacement from Variable with scenarios.
    Thanks in advance,
    Aravind.S

    Hi,
    If you are using Replacement with query, the given query output will be used as input your variable. For example if you want to display the product details, which can be find our from a query.
    And Replacement with Variable will be used  when you want to give the same input  in two different fields. for example if you want to see the records from sending location and not the records from recived location at the same time. Here once you give the sending location id, it will be taken as the same input for received location.
    Regards,
    Vishnu

  • ORA-01008 with ref cursor and dynamic sql

    When I run the follwing procedure:
    variable x refcursor
    set autoprint on
    begin
      Crosstab.pivot(p_max_cols => 4,
       p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by job order by deptno) rn from scott.emp group by job, deptno',
       p_anchor => Crosstab.array('JOB'),
       p_pivot  => Crosstab.array('DEPTNO', 'CNT'),
       p_cursor => :x );
    end;I get the following error:
    ^----------------
    Statement Ignored
    set autoprint on
    begin
    adsmgr.Crosstab.pivot(p_max_cols => 4,
    p_query => 'select job, count(*) cnt, deptno, row_number() over (partition by
    p_anchor => adsmgr.Crosstab.array('JOB'),
    p_pivot => adsmgr.Crosstab.array('DEPTNO', 'CNT'),
    p_cursor => :x );
    end;
    ORA-01008: not all variables bound
    I am running this on a stored procedure as follows:
    create or replace package Crosstab
    as
        type refcursor is ref cursor;
        type array is table of varchar2(30);
        procedure pivot( p_max_cols       in number   default null,
                         p_max_cols_query in varchar2 default null,
                         p_query          in varchar2,
                         p_anchor         in array,
                         p_pivot          in array,
                         p_cursor in out refcursor );
    end;
    create or replace package body Crosstab
    as
    procedure pivot( p_max_cols          in number   default null,
                     p_max_cols_query in varchar2 default null,
                     p_query          in varchar2,
                     p_anchor         in array,
                     p_pivot          in array,
                     p_cursor in out refcursor )
    as
        l_max_cols number;
        l_query    long;
        l_cnames   array;
    begin
        -- figure out the number of columns we must support
        -- we either KNOW this or we have a query that can tell us
        if ( p_max_cols is not null )
        then
            l_max_cols := p_max_cols;
        elsif ( p_max_cols_query is not null )
        then
            execute immediate p_max_cols_query into l_max_cols;
        else
            RAISE_APPLICATION_ERROR(-20001, 'Cannot figure out max cols');
        end if;
        -- Now, construct the query that can answer the question for us...
        -- start with the C1, C2, ... CX columns:
        l_query := 'select ';
        for i in 1 .. p_anchor.count
        loop
            l_query := l_query || p_anchor(i) || ',';
        end loop;
        -- Now add in the C{x+1}... CN columns to be pivoted:
        -- the format is "max(decode(rn,1,C{X+1},null)) cx+1_1"
        for i in 1 .. l_max_cols
        loop
            for j in 1 .. p_pivot.count
            loop
                l_query := l_query ||
                    'max(decode(rn,'||i||','||
                               p_pivot(j)||',null)) ' ||
                                p_pivot(j) || '_' || i || ',';
            end loop;
        end loop;
        -- Now just add in the original query
        l_query := rtrim(l_query,',')||' from ( '||p_query||') group by ';
        -- and then the group by columns...
        for i in 1 .. p_anchor.count
        loop
            l_query := l_query || p_anchor(i) || ',';
        end loop;
        l_query := rtrim(l_query,',');
        -- and return it
        execute immediate 'alter session set cursor_sharing=force';
        open p_cursor for l_query;
        execute immediate 'alter session set cursor_sharing=exact';
    end;
    end;
    /I can see from the error message that it is ignoring the x declaration, I assume it is because it does not recognise the type refcursor from the procedure.
    How do I get it to recognise this?
    Thank you in advance

    Thank you for your help
    This is the version of Oracle I am running, so this may have something to do with that.
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    I found this on Ask Tom (http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3027089372477)
    Hello, Tom.
    I have one bind variable in a dynamic SQL expression.
    When I open cursor for this sql, it gets me to ora-01008.
    Please consider:
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.1 - Production
    JServer Release 8.1.7.4.1 - Production
    SQL> declare
      2    type cur is ref cursor;
      3    res cur;
      4  begin
      5    open res for
      6    'select * from (select * from dual where :p = 1) connect by 1 = 1'
      7    using 1;
      8  end;
      9  /
    declare
    ERROR at line 1:
    ORA-01008: not all variables bound
    ORA-06512: at line 5
    SQL> declare
      2    type cur is ref cursor;
      3    res cur;
      4  begin
      5    open res for
      6    'select * from (select * from dual where :p = 1) connect by 1 = 1'
      7    using 1, 2;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    And if I run the same thing on 10g -- all goes conversely. The first part runs ok, and the second
    part reports "ORA-01006: bind variable does not exist" (as it should be, I think). Remember, there
    is ONE bind variable in sql, not two. Is it a bug in 8i?
    What should we do to avoid this error running the same plsql program code on different Oracle
    versions?
    P.S. Thank you for your invaluable work on this site.
    Followup   June 9, 2005 - 6pm US/Eastern:
    what is the purpose of this query really?
    but it would appear to be a bug in 8i (since it should need but one).  You will have to work that
    via support. I changed the type to tarray to see if the reserved word was causing a problem.
    variable v_refcursor refcursor;
    set autoprint on;
    begin 
         crosstab.pivot (p_max_cols => 4,
                 p_query => 
                   'SELECT job, COUNT (*) cnt, deptno, ' || 
                   '       ROW_NUMBER () OVER ( ' || 
                   '          PARTITION BY job ' || 
                   '          ORDER BY deptno) rn ' || 
                   'FROM   emp ' ||
                   'GROUP BY job, deptno',
                   p_anchor => crosstab.tarray ('JOB'),
                   p_pivot => crosstab.tarray ('DEPTNO', 'CNT'),
                   p_cursor => :v_refcursor);
    end;
    /Was going to use this package as a stored procedure in forms but I not sure it's going to work now.

Maybe you are looking for

  • How to find the table in which data from a structure sits

    Hi, I want to know how to find the exact table where data sitting in various structures during runtime are stored. For instance,in ME23N we have various tabs and data in those are held in various structures. This we can see by checking the technical

  • Data not loading from PSA to infocube

    Hi, I'm facing a problem while extracting the data from PSA to infocube (On APO SIDE). we are using 3 infocubes and we extracting data in such a way that each infocube has only one unit of measure, so with the help of abaper, we have written a start

  • BW Report to Graph

    Hi,    How can i transform the BW Report value into Graph (Line) Thanks

  • How do I import my library from an external disk to my new MBP hard drive?

    My old MBP was running out of space so I exported my Aperture library (250GB) to an external drive.  I just replaced my old computer with a new MBP with a 1TB flash drive.  Now that I have the space, I want to put my library back on my computer but I

  • Select List beside Interactive report

    Hi All, I am not able to place a SELECT LIST item beside an Interactive Report. What is happening: <selecting columns to search> Go Action SELECT LIST* I n t e r a c t i v e  R e p o r t Even though I am able to place a button beside the Interactive