Error in the proc which has dynamic query in it.

I have a proc as below
create or replace procedure dynamic_Sql
(id in number,
obj_id in number,
id2);
is
xxxx varchar2(30);
sql_stmt1 VARCHAR2(10000);
cusor c is select distinct dep from department where dept_id = 10;
Beign
select table_name into xxxx from tableq;
for cur in c loop
sql_stmt1:= 'insert into node(NODE_ID,pID,dep,tnode,PNODE)
select id,pid2,cur.dep,null,null)
from tablex h
where h.hid = id2
and h.dep = cur.dep)';
end loop;
execute immediate sql_stmt1;
end;
Here when i execute it is giving the error in 'id2' which is paased as the parameter in this proc and "cur.dep" which is comming from the cursor. It giving n error 'id2' and "cur.dep" is an invalid identifier
Edited by: user10285699 on May 1, 2009 1:09 AM

Your code is faulty.
First of all you set up multiple statements in a cursor for loop, and you execute that statement outside the cursor for loop. So only 1 statement is executed.
Secondly, you can't refer to pl/sql variables in a dynamic sql statement or you must use them as bind variables (preferred) or concatenate them.
1 bind variables.
sql_stmt1:= 'insert into node(NODE_ID,pID,dep,tnode,PNODE)
select id,pid2,cur.dep,null,null)
from tablex h
where h.hid = :id2
and h.dep = :dep';
execute immediate sql_stmt1 using id2, cur.dep;
end loop;
2 concatenation.
sql_stmt1:= 'insert into node(NODE_ID,pID,dep,tnode,PNODE)
select id,pid2,cur.dep,null,null)
from tablex h
where h.hid = '||id2
and h.dep = '||cur.dep||')';
execute immediate sql_stmt1 using id2, cur.dep;
end loop;
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • ORA-2001:The approver group Process MFG Approvals has dynamic query in wron

    ERROR ORA-2001:The approver group Process MFG Approvals has dynamic query in
    wrong format in 11i
    We are setting up the Approver Group 'Process MFG
    Approvals" using a dynamic query, like:
    SELECT PAPF.EMPLOYEE_NUMBER
    FROM PER_ALL_PEOPLE_F PAPF,
    fnd_lookup_values FLV
    WHERE FLV.MEANING=PAPF.EMPLOYEE_NUMBER
    AND lookup_type='SUG_SAMPLE_NOTIFICATION'
    AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND FLV.LOOKUP_CODE= (SELECT GME.PLANT_CODE FROM GME_BATCH_HEADER GME WHERE
    GME.BATCH_ID=:transactionId)
    - Above query is passing the validation action from within the setup screen.
    - However, when this approver group is being invoked via Sample Creation
    workflow, there is following error raised:
    ORA-20001:The approver group Process MFG Approvals has dynamic query in
    wrong format
    More, if user is trying to use a more simple query like:
    select distinct person_id from PER_ALL_PEOPLE_F where full_name = 'Mr.
    Oliverking G' we are getting same error
    Any idea, plse, would be gretaly apprciated.
    txs
    Peter

    Hi,
    You need to prefix the value with a text string which indicates what kind of value you are returning.
    E.g. if you are returning a user ID, prefix the value with 'user_id:'; if you are returning a person ID, then prefix it with 'person_id:'
    There is an article on my blog about creating a dynamic approval group in AME as part 5 in the series on AME: http://www.workflowfaq.com/ame-part-five-defining-a-dynamic-approval-group
    HTH,
    Matt
    WorkflowFAQ.com - the ONLY independent resource for Oracle Workflow development
    Alpha review chapters from my book "Developing With Oracle Workflow" are available via my website http://www.workflowfaq.com
    Have you read the blog at http://www.workflowfaq.com/blog ?
    WorkflowFAQ support forum: http://forum.workflowfaq.com

  • After answering the three security questions on itunes connect the submit button is still grayed out. It looks like it could be an error on the website. Has anyone encountered this issue?

    After answering the three security questions to update an app on itunes connect the submit button is grayed out. It looks like an error on the website. Has anyone ran into this problem before? Any help would be greatly appreciated.

    Hi evanVIT, 
    Welcome to the Apple Support Communities!
    I understand that issues like the one you are experiencing can be very frustrating. For this situation however, for update errors in the range of 3000-3020, I would recommend the troubleshooting steps located in the attached article. Please use the steps and information as a reference. 
    Error 3194, Error 17, or "This device isn't eligible for the requested build"
    Cheers, 
    Joe

  • How to set the view, which has to be shown at runtime?

    Hi,
    in my application i have more than one view, but at runtime only one of these views has to be shown. I want to decide this via a parameter that I get from the url.
    How can i set the right view to be showing at runtime?
    I tried it with a StartView which fires the right Outbound Plug in his wdDoInit-Method. This is working fine, but the problem is, that the method OnPlugDefault() of ComponentInterfaceViewController isn't called already at this time. So in the Init-Method of the StartView I don't have the given URL Parameter, so I can't decide which Plug I want to fire. The method OnPlugDefault() is called only after the init-method of the StartView.
    Is there any other possibilty to set the view, which has to be shown, at runtime?
    Thanks and Best Regards
    Katharina

    Hi,
    One way is you can pass the parameter in the URL , read the parameter and then fire the outbound plug depending upon that.
    You can read the parameters as follows
    HttpServletRequest request =Task.getCurrentTask()
         .getWebContextAdapter()
         .getHttpServletRequest();
    String[] param1 = request.getParameterValues("<<PARAMETRNAME");
    if(param1.equals("VALUE"))
      fire outbound plug1;
    Regards, Anilkumar

  • HT1981 I will use my 110V MacBook in the Philippines which has 220V sockets. Will the World Travel Adapter Kit help me?

    I will use my 110V MacBook in the Philippines which has 220V sockets. Will the World Travel Adapter Kit help me?

    Assuming you're in North America now, you probably won't need any sort of plug adaptor there; most sockets in the Philippines are the same as those in North America. In case you do, it doesn't contain the correct adaptor.
    Voltage conversion is handled by the MacBook without any additional components.
    (66079)

  • Getting an error prompt "the facebook server has returned an unknown error and is not able to fulfill your request. (2001)"

    Hi. I need help regarding facebook for blackberry. I cannot post any status update, i keep on receiving an error prompt "the facebook server has returned an unknown error and is not able to fulfill your request. (2001)".  it has been like this for the past 3 days. I already did the hard reboot many times, re-send service book though i do'nt think it's needed, and tried uninstalling and reinstalling the facebook application too but still getting the same error everytime i try to post a status update. I can comment to messages on my wall and other profiles, the news feed is updating in time too, i can also log-in and out to facebook with no problem, as well as other applications on my phone like foursquare, BBm, ubersocial, BB protect, BB app world, etc, are all working perfectly fine. And now I don't know what seems to be the problem.
    I've already contacted my network provider and told me that the error i'm getting is beyond their scope.
    Is anybody having the same problem as mine? 
    Can someone in BB support team help me regarding this issue and tell me what should I do?
    Thank you in advance. 

    I got the same issue !! Since I've updated my Facebook app 2 or 3 week ago !
    I can not  update my status and check-in ! It gives me "the facebook server has returned an unknown error and is not able to fulfill your request. (2001) "
    I can upload photo, put comment on people, like people status/picture. The news feed update perfectly !
    I also  tryied to uninstall reinstall the app, reboot etc etc ! I still can't update my status !!!! I've installed 3.0.0.17 this morning and the issue is still there...
    I've remarked one thing... On my facebook under "privacy setting/the Apps, Games and Websites" I used to have a "blackberry app" installed. It's not there anymore and I didn't remove it.
    I don't know how to reinstall it...

  • How to find out the columns which has 16 digit credit card number

    Hi All,
    I have a requirement where in i need to find out the columns which has 16 digit credit number in it and create a report with owner, table name and column name.
    The issue is that the credit card number can be entered in any columns of any table of any schema. For example the credit card number can be entered in any description field(eg: The number is 4001412134642881), in that case i need to filter only the numbers and do the LUHN check to validate the credit card number.
    Please provide me a suggestion on how to scanl the values of all the columns to know the column which has credit card number.
    Regards,
    Raj.

    Tell me this - how the hell do you have a database with credit card number data and NOT know which columns of which tables contain credit card numbers? (and how on earth is this data NOT encrypted!?)
    How is what you want to do, NOT a fishing expedition to hack a database that may or may not be storing credit card details?
    And do you honestly think that we should simply trust that once you have extracted these numbers, performed a Luhn algorithm to verify these as credit card numbers, you are not going to fraudulently use these credit card numbers!?
    I have marked your posting as an attempt to hack an Oracle database for fraudulent use of credit card data. I hope that your OTN account is terminated soon and trust that your too much of a coding idiot to actually succeed in this endevour.

  • When I take my phone off charge in the morning I get an info box on the front which has the sound trumpet icon with a line through it and the word Mute.  The only way to get rid of it is to reboot the phone any ideas as to how I can stop this happening?

    When I take my phone off charge in the morning I get an info box on the front which has the sound trumpet icon with a line through it and the word Mute.  The only way to get rid of it is to reboot the phone any ideas as to how I can stop this happening?

    Hello cor-el, thanks for your reply. I changed my settings for downloads to desktop and it has appeared on there. When I double click I am asked which program I want to open file. I click firefox and another box "opening install" says I have chosen to open the file which is an application and do I want to save it. This is the only real option so I press save file. I get a box saying this is an executable file which may contain viruses - do you want to run. I press ok and the final box showing C drive file name and desktop appears stating application not found.
    This happens the same whenever I try to install.
    To my untrained eye the application is not being recognised as an application and I cannot work out how to get it to do that.
    My plugin is still showing as out of date.
    Is there anything you could suggest. Thanks for your time.

  • The toolbar which has the go back button, refresh button, etc. is gone. How do I get it back?

    The tool bar which has the url of the page I am on, go back button, refresh button, etc. is gone. How do I get it back?
    == This happened ==
    Just once or twice
    == a couple weeks ago.

    The toolbar which has the view button is also missing.

  • Hi, i have inserted a dvd in the drive, which has data in it but its showing blank and asking toburn

    Hi, i have inserted a dvd in the drive, which has data in it but its showing blank and asking to burn. Along with that its also showing the capacity of the dvd. Its ready to write the disk but not exploring the data on the disk. Please help..

    See if this fixit tool can repair it
    http://support.microsoft.com/mats/cd_dvd_drive_problems/en-us

  • How can i distill the invoice which has not verified?

    hello evryone:
       my problem is I want to distill the invoice which has not 
       verified through the tcode MIRO.
       thanks in advance!

    Hello,
    Have you tried breaking your structure into 255 chunks? I don't know what the structure you are moving from looks like, but you should be able break it back up into the SOLI structure. The end of a line in SOLI doesn't create a Carriage Return/Line Break. You have to insert these yourself like in the following:
    * Create document
          clear mail_line.
          move 'This is a test E-Mail'(d01) to mail_line.
          concatenate mail_line
                      cl_abap_char_utilities=>newline
                      into mail_line.
          append mail_line to l_mailtext.
    What kind of attachment are you wanting to create - a text tab delimited file for reading in a spreadsheet application such as excel? You might try reassembling your data table into a single string with newlines where you need them. Then use function module SCMS_STRING_TO_FTEXT to turn it back into SOLI. This is what I have done in the past. I'm afraid without knowing more about your source structure and attachment type, this is about all I can tell you.
    Vasanth

  • I get the error message: The System Administrator has set Policies to prevent this installation. What do I do?

    I get the error message: The System Administrator has set Policies to prevent this installation. What do I do?

    Have you read for possible solutions over in the "More Like This" thread over here?-----------------------> 

  • I created a photo album on my iPhone 4s - edited photos etc. but I cannot figure out how to transfer it to my pc (using Windows 8).  The only folder in the iphone drive is the one which has the Camera roll photos :( Help please - I really need the photos!

    I created a photo album on my iPhone 4s - edited photos etc. but I cannot figure out how to transfer it to my pc (using Windows 8).  The only folder in the iphone drive is the one which has the Camera roll photos Help please - I really need the photos!

    The camera roll is not part of the sync process at all.
    You should be importing these photos to your computer regularly as you would with any digital camera.  Youc an organize them on your computer and sync the to the iphone if you wish.
    The photos sync from the computer to the iphone is one way.
    The iphone mirrors the selected content of the computer to which it is synced.

  • A window doesn't know the window which has createdit.

     

    you can also look at client-side SO , or passing parameters to child win.
    Cordialement.
    Patrice Bourdon
    Alliance Sante France
    Tel : (33) 02.54.60.26.27
    Fax : (33) 02.54.60.25.00
    e-mail: mailto:patrice.bourdonalliance-sante.fr
    <mailto:patrice.bourdonalliance-sante.fr>
    web : http://www.alliance-sante.fr <<a
    href=
    "http://www.alliance-sante.fr/">http://www.alliance-sante.fr/</a>>
    -----Message d'origine-----
    De: Olivier Andrieux [mailto:oandrieuxaxialog.fr]
    Date: vendredi 9 juin 2000 14:34
    &Agrave;: forte-userslists.xpedior.com
    Objet: (forte-users) a window doesn't know the window which has created it.
    Hi,
    I have created a window win_a and a second window win_b whis is instancied
    in win_a(new+display) when a button is clicked
    but i want to use the datas of win_a in win_b. For it, i have made a class
    'main' which instanciate win_a.
    The problem is that win_b does'nt know win_b....
    Thanks
    Olivier Andrieux
    Axialog Lille
    France

  • There is no entry for this function in Table 168F (system table). An error involving the screen control has probably occurred.

    Hi All,
    i created one  enchancement to ME21n screen,
    i added one screen at header
    When i running the the transaction ME41 it shows the following error.
    This function not defined
    Message no. 06006
    Diagnosis
    There is no entry for this function in Table 168F (system table). An error involving the screen control has probably occurred.
    Procedure
    Contact your system administrator.
    Am i need to add this functionalty to any  sap table.
    plz guide me on this.

    Hi Krishna
    Have you added any buttons in the custom screen if yes then you will have to maintain configuration data for Function code processing.
    Please search on SCN for the same
    Nabheet

Maybe you are looking for

  • Hanging start up and other oddities

    Hanging Startup and other oddities I'm not especially proficient with the upkeep and terminology that comes with the programming aspect of Macs, so, if you do help, if you could please put whatever advice you have in lay terms, it would really help m

  • Help with printing text to Text Edit

    -- Here is a applescript that generates prime numbers up to a certain number. I tried to get the script to print out every number up to the number defined in a text edit document. I got a -1700 error that says (error "Can't make result of 3 into type

  • About the content tab

    Hi All, Can anyone telll me what is the function of where filed in Content tab with example. It will be great help for me. Thanks a lot in advance.

  • Having problems with Logitech Vision Pro and AIM and I chat

    Can't believe it can be this hard I'm trying to install a Logitech Vension Pro web cam and make with work with AIM via Ichat. I've got the camera to work in some applications so it does work. After many hours on line I decided that I needed to down l

  • Indesign RGB printing

    Hi we have Indesin CS3 and we have great problems printing to our Inkjet printers getting wild variations on colour we have an eye one calibrator and have no problems calibrating and get great results we need to use indesign to print several photogra