Open cur for .. using

Hi,
my stmt does not give me any results and i don't how to find the error. It must have to do with the using clause as the statement works, if i call it directly.
  procedure p_get_unique_key
     p_owner varchar2
   , p_table_name varchar2
  IS
    v_count int;
    v_query varchar2(500);
    curid int;
    Type cols IS TABLE OF varchar2(2500);
    v_uk_columns cols;
    TYPE curtype IS REF CURSOR;
    cur      curtype;
  BEGIN
    v_query := '
    select cc.column_name
    from all_constraints c
    join all_cons_columns cc
       on cc.owner = c.owner
      and cc.constraint_name = c.constraint_name
    where c.constraint_type = ''U''
      and c.owner = :1
      and c.table_name = :2  
    dbms_output.put_line(v_query);
    open cur for v_query
    using p_owner, p_table_name;
    FETCH cur BULK COLLECT INTO v_uk_columns;
    DBMS_OUTPUT.PUT_LINE(v_uk_columns.COUNT);
    close cur;
  END;
  Who can help me?
Tobe

Why are you using a ref cursor? There is no need for it. Why are you even using a cursor at all in the 1st place when you doing a single (no-loop) fetch?
When you write code, you need to have justification for why you wrote what you did. To do that, you need to know exactly what each line of code you write does - and knowing that, you can make the call whether that line of code does what is required or not. And to be honest, your code is pretty messy as it uses superfluous concepts (why subtype a ref cursor when you can instead use the sys_refcursor type?) and incorrect and complex approaches (using an explicit ref cursor with manual binding when an implicit cursor is easier).
For example (and note the proper use of programming language syntax standards regarding pascalcase and camelcase):
create or replace procedure DoSomethingWithUniqueKey( keyOwner varchar2, tableName varchar2 ) is
  -- not sure why you call it GetUniqueKey as you parameter signature fails to return/get anything for the caller
  type TStrings is table of varchar2(4000);
  colList TStrings;
  ...  other stuff
begin
  .. other stuff
  select
        cc.column_name bulk collect into ColList
  from all_constraints c
  join all_cons_columns cc
     on cc.owner = c.owner
    and cc.constraint_name = c.constraint_name
  where c.constraint_type = 'U'
    and c.owner = upper(keyOwner)
    and c.table_name = upper(tableName);
    .. other stuff   
end;Compare the number of lines and readability and maintainability of your code with this.

Similar Messages

  • PDE-PLI038 Cannot open file for use as a PL/SQL library

    Hi,
    We are using oracle 12 .0.4 on RHAS 4
    I am trying to compile a .pll file with the following code
    frmcmp_batch module=$AP_TOP/patch/115/sql/apacrndb.pls userid=apps/apps module_type=LIBRARY;
    but it's returning the error
    PDE-PLI038 Cannot open file for use as a PL/SQL library
    Thanks
    Umair

    Umair,
    What is the issue about?
    Usually, it would be required to run the pls files to recreate certain objects (mainly packages) in the database, and you run the pls file from SQL*Plus as apps/applsys user.
    Please update the SR and confirm with Oracle Support what the action plan you need to follow to resolve the issue.
    Regards,
    Hussein

  • Problem on Windows 7 Home Premium cant open program for using codes like visual studio 2012

    I have problem my windows 7 Home Premium because of visual studio 2012..I can't open even in several times, I don't know what happen, and sometime it is so low to process whenksn it to open my laptop..Why is that pleas do reply..ASAP! tha

    Hi,
    According to your description, it seems like VS itself problem, you can try to repair this program through Control Panel for test. If no use, it would be better to post your question at VS forum for further assistance.
    Contact VS forum:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio%2Cvsarch%2Cvsdbg%2Cvstest%2Cvstfs%2Cvsdata%2Cvsappdev%2Cvisualbasic%2Cvisualcsharp%2Cvisualc
    Roger Lu
    TechNet Community Support

  • Why does the iTunes AppleID system refuse to work properly without the need to reset the password every time I open iTunes for use?

    Alright so here is the issue. When I first started using iTunes I created my AppleID. I locked it in to remember my password and authorize my computer so that I would NEVER HAVE TO ENTER IT AGAIN. So years pass, no problem. Then "ITUNES 11" come on everyone lets upgrade or you can't proper use the iTunes Store. Seriously it wouldn't let me access the store. Go Figure. So I upgrade simple right? No. It really isn't when iTunes 11 rolled out it was riddled with minor bugs that made the experience annoying so I did a rollback and live without the store for awhile.
    About a year passes and I try again this time upgrading iTunes through a COMPLETE fresh install, again I did what had done the first time I logged my AppleID and reauthorized my computer. Hurrah other than getting use to the new UI it ran perfectly. Yes Finally! Right? Again.... No. No more than 2 or 3 software updates later suddenly my password for my AppleID is incorrect I was like "Okay?" and re-entered it thinking the big update cleared my settings.
    Wrong Password please reset password to continue using the iTunes store.
    I was like okay maybe the user agreement change and we all need to reset passwords and re-accept the EUA. So I go through the process to create a new password successfully and reset my AppleID in iTunes with the new password. Come back a few weeks later it happens again this time I enter my new password and what do I get?
    Wrong Password please reset password to continue using the iTunes store.
    So I first do a repair install to my iTunes than reset my password this time NOT setting it to remember password. Great everything works fine again password even matched my Home CompID so that I could NEVER lose it well come a few days later I try to use the store and what happens?
    Wrong Password please reset password to continue using the iTunes store.
    to try to make my Long story a little shorter....
    This has been going on for the better part of 3 years I have almost completely dropped iTunes which has the better store library for Goggle Play Music who's store library isn't even a third the size iTunes has because their system works and my log-in is my e-mail. I repeatedly completely uninstalled iTunes and wiped it from my registry in hope a clean install would fix the problem but it never does.
    My OS is Vista Home Premium Edition 32-bit and no picking on my OS I been working to get a new computer but that isn't happening anytime soon so I work with what I got.

    Even removing the .xml files doesn't make a difference. Also, I now installed another update of iTunes, but still having the same problem, and this time there are no .xml files or preference files whatsoever in the Application Data and Local Settings\Application Data iTunes folders. It seems like for some reason iTunes is unable to create these. What should I do?

  • Why won't my Lightroom 4 open up for use after I successfully downloaded and installed it?

    I just followed all the instructions for downloading and installing Lightroom 4 on my comp. It said it was successful but the icon on my desktop hasn't changed and every time I try to open it to edit pictures it goes back to the installation pop up.
    Please Help!!

    you are clicking the installation icon again , that why this is happening , the icon doesn't get changed
    to open the application go to Mac HD-->Applications--->Adobe lightroom 4 , in this folder you will have the app file to launch the application.

  • Open cursor for string and select from partition (cannot bind)

    Hi,
    i don't manage to use a bind variable for a select ... from ... PARTITION(...).
    It doesn't work to use something like
    open cur for 'select ... from ... PARTITION(:1) where ...' using 'NDAY_20120301';So i have to create the cursor string with string functions each time i change the partition.
    But that means, that the string changes each time.
    Doesn't that prevent from re-use in library_cache?
    best regards,
    Frank

    >
    So i have to create the cursor string with string functions each time i change the partition.
    But that means, that the string changes each time.
    >
    Yes it does.
    Doesn't that prevent from re-use in library_cache?
    >
    Yes it does.
    So why do you care? Unless you have large numbers of partitions what difference does it make? Bind variables are useful to keep Oracle from doing hard parses of queries that are basically the same but use different filter values. Such as an INSERT statement that uses different values FOR EACH ROW rather
    You are just constructing the main (non-filter) part of the query one time and need a single value for the entire query regardless of how many rows - that isn't really a use case for bind variables and isn't going to provide any real benefit.
    So the real question is why do you even care about something that wouldn't provide any benefit to you even if you could do it?
    Looks like you just want to 'roll your own' parallel processing rather that use, and pay for, Oracle's parallel functionality.
    If each partition uses its own tablespace you could filter on the FILE Id of the ROWIDs since the file number will be different for each tablespace and datafile.
    1. Determine the list of file numbers for each partitions tablespace.
    2. Use a WHERE DBMS_ROWID.ROWID_RELATIVE_FNO (ROWID) = :n filter (or use IN (:n1, :n2))to filter rows based on file number(s) for the partition you want
    See DBMS_ROWID.ROWID_RELATIVE_FNO in the PL/SQL Packages and Types doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_rowid.htm#i1004259

  • Open field for customer line item

    Hi Guru
      I have some problem about open field for customer line item  post with posting key 09 and special GL , I open field at posting key 09 but the field still hidden  . How I can open field for used . Thank you

    Dear,
    Use transaction FBL5N and select Special G/L Transactions only and execute.....here bring posting key and filter the posting with 09.
    REgards,
    Chintan Joshi

  • Downloads from iTunes on my macbook air do not download on my desktop but remain in iTunes folder which refuse to open for use.

    I couldn't get downloads from iTunes to be on the desktop of my Macbook air but they remain in iTunes folder and refuse to open for use. What am I to do?

    Downloads of what?  Songs?  Apps?  Books?
    If you're talking about apps, then you have downloaded iOS apps which are intended to run on an iPhone or iPad, not a Mac.

  • I bought my iPhone 4 open line in Vancouver, Canada last week for use here in my home base in Bangkok, Thailand.  But when I tried using my Thai sim, I get a very weak signal, if not a weak signal, then a no service status.  What do I do?

    I bought my iPhone 4 open line in Vancouver, Canada last week for use here in my home base in Bangkok, Thailand.  But when I tried using my Thai sim, I get a very weak signal, if not a weak signal, then a no service status.  I also have very weak wifi reception.  What do I do?
    I already tried the following:
    a. Turned the phone off and then on.
    b. Checked all wifi connections – no problem given that all our laptops and desktops can connect seamlessly.
    c. I tried restoring the phone to original factory settings via itunes
    d. Tried resetting the phone.
    e.     Tried different microsims from all networks
    f. However, all methods failed given that the network reception is very weak and often reflects – “no service”.  And with regards to the wifi reception It has difficulty in reading even the signal right in front of the wifi router.
    I went to two Apple resellers here in Bangkok and requested that they please look at my Iphone and have it serviced.  I was frustrated when they said that given that I bought my phone in Canada, they are not able to support me and should instead try to contact the Apple store in Canada. 
    I went to apple.ca website and went to the expresslane support and I was said to register and callback.  Tried calling the 1800 number but given that I was in Thailand I had difficulty getting a connection.

    1st sentence, 4th page of the iPhone warranty found here:
    Apple may restrict service to the country where Apple or its
    Authorized Distributors originally sold the hardware product.
    From the Repair terms and conditions found here:
    9. Availability of Service.
    Apple may restrict service to the country where Apple or its authorized distributors originally sold the
    hardware product, and to the countries listed in the table below. A list of authorized distributors is
    available online at:
    http://images.apple.com/legal/warranty/docs/iPhoneAuthorizedDistributors.pdf
    If you do not believe that, then see these search results which confirm my statement.

  • "This drive is not ready for use; it's door may be open ..."

    Hi.
    I recently updated to itunes 7, and then had an issue with a corrupt file on the i-pod (which resulted in chkdsk hanging itself at 27%, always). So I restored the i-pod and that took care of that - chkdsk now says it's fine.
    However - it is also empty. My machine and i-tunes recognize it fine upon start-up; however, a short while into a full synch to get my library back on the i-pod, I invariably get the following error message:
    "The drive is not ready for use; it's door may be open. Please check drive \Device\Harddisk\DR 3 and make sure that a disk is inserted and that the drive door is closed." The message comes with the options "cancel, ignore and continue", yet the latter two don't make a difference, and even if I choose cancel, itunes keeps trying until it eventually crashes.
    This always happens after itunes has synchronized about 1.13 GB (out of 18.55 available).
    As far as I can tell, both my system and the iPod are up to date (itunes and windows update say so, anyway). E: is unequivocally and exclusively allocated to the i-pod; changing the settings from "optimize for quick removal" to "optimize for performance" has made no discernible difference.
    Any ideas would be very much appreciated.
    Thanks.
    DELL Inspiron 4150   Windows XP  

    Hullo ...
    let me follow up on this again. I've followed your advice, de-installed spybot, no change. I looked through the windows support help base, nothing. While trying out different things, I started getting a "delayed write failed" message, and I did some things they suggested (including adjusting the registry - me, adjusting the registry!)and it went away, and now all I get is the "open door" message again.
    That is: everything works absolutely fine, I plug in the i-pod (latest version i-tunes and i-pod is up to date), it's recognized instantly by the explorer as well as i-tunes. I've run all scans you can possibly run on it, and it is fine (no corrupt files, nothing). I've restored it twice through i-tunes, twice through the explorer. I've changed the drive letter.
    It starts the synch fine (it's still almost empty after the last restore), but at some point, I get the error message. Interestingly enough, *up to* that point, it'll synch fine - I can disconnect it and play on it whatever's been synched thus far. I can also modify my i-tunes settings and preferences, all of which i-tunes will recognize and adhere to. It is just unwilling to put more than 1GB of stuff onto my 20GB i-pod.
    Something I've noticed is that it is sometimes indicating apparently faulty charges in the beginning (though that is quickly corrected once the synch starts), as in, it'll recognize a certain amount of audio files, but also claim a random amount of "other" files, which should not be there (apart from the 30MB or so of genuine i-pod software).
    Anyhow. I haven't seen any solutions to this on the forums or in the apple help files, but people appear to be having this problem still. Any ideas or input would be very much appreciated ...
    Thanks.

  • "The drive is not ready for use; its door may be open. Please check drive \

    3G IPOD problems which are driving me mad and i can see others have had the same problem but i can't find any solution written down.
    Basically my IPOD either freezes after a couple of songs or it downloads about 6Gb (of 40) and the freezes with the following message:
    "The drive is not ready for use; its door may be open. Please check drive \Device\Harddisk2\DR6 and make sure that a disk is inserted and that the drive door is closed"
    I've tried re-setting, installing etc but no luck. Any suggestions/solutions?
    Laptop - Packard Bell Notebook   Windows XP  

    Hmmmm. I'm not sure how to explain this.
    You need to change the Drive Letter for your iPod.
    You should be able to connect your iPod then open Windows Explorer and right click on your iPod(which seems to be Drive E:) and change it to a different letter (like H).
    If you haven't enabled disk use for your iPod it probably won't appear in Windows Explorer.
    To enable disk use: connect iPod, open iTunes. Open Preferences and select the iPod tab. Choose "enable disk use."
    Once you've done all that, try resyncing.

  • HT2518 which program can I use to open a Word file that is formatted for use ONLY on a PC?

    I hve a word doc that is formatted only for use on a PC. I cannot change the file at the request of the sender. Is there a way to open and fill out the word document on a mac. I used to have Parrelles which allowed me to do so but no longer have this program. Specifically the word document has pre-programmed drop downs in the form. They do not function, nor allow me to type a word into the field.

    There is no such thing as a Word file formatted only for a PC.
    You need a copy of Word to open it (Word for Mac), it may also work with Open Office and Libre Office, these are free to download.

  • Open multiple PDFs in Photoshop at specific size for use with Actions

    I am having a bit of a roadblock with batch Automate in Photoshop. I'd like to open multiple PDFs at 630p x 630p, 72 dpi in greyscale. I have 2000 files to do this on. If files are already open, the rest of my action works, does a few things, then saves for web as PNG. It is just the open which is not working. It tries to give all files the same filename. Taking the filename out of the Action is not an option. Scan of msg boards say that this feature stopped working around CS3. Any ideas? Much appreciated.

    Open opens images the same size and resolution they are saved. If you want the images to be a particular size you need to do that in the action.
    If you download my crafting actions package.  You will find the there are over a dozen scripts I wrote to be used with in action.  One is a plugin script that would be particularly helpful to you to do the resize you want to do.  The first three steps would be Step 1 menu File>Automate>AspectRatioSelection....  You would set in a 1 to  1   Aspect ratio. Centered, rectangle. replace, selection and 0 feather. In its dialog.  Those settings will be recorded into the Actions step. Step 2 menu Image Crop. that will make you image square. Step 3 menu File>Automate>Fit Image...  In the Fit image dialog you would set 630 in the width and height fields.  These settings will be recorded into the actions step.    When the action is played no dialog will be displayed. The recorded settings will be used.
    Crafting Actions Package UPDATED Aug 10, 2014 Added Conditional Action steps to Action Palette Tips.
    Contains
    Action Actions Palette Tips.txt
    Action Creation Guidelines.txt
    Action Dealing with Image Size.txt
    Action Enhanced via Scripted Photoshop Functions.txt
    CraftedActions.atn Sample Action set includes an example Watermarking action
    Sample Actions.txt Photoshop CraftedActions set saved as a text file.
    More then a dozen Scripts for use in actions
    Example
    Download

  • Hi I am in travel and I use from Iran operator. but my iphone is locked for it. please open it for me

    hi I am in travel and I use from Iran operator. but my iphone is locked for it. please open it for me or help me anyway can please

    Since the iPhone is not officially sold in Iran, & there are no supported carriers there, you couldn't have an iPhone locked to a carrier in Iran.
    At any rate, if you do have a carrier locked iPhone, you need to contact the carrier the phone is locked to to get it officially unlocked. No one here can help you, nor can/will Apple.

  • Open cursor for ...using...

    Hi all
    1 general question- can someone explain me how 'using keyword in 'open cursor for ...' statement works.
    Does it replace where clause and how?
    open cur_xx for qry_xxx using text_xxx
    where 'text_xxx' is going to be my codition in select statement
    Tahnks everyone

    http://oraclesvca2.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems35.htm

Maybe you are looking for