When the dbms_sql.bind_variable is used?

DB version: 11.2

I'm new kind of PL/SQL and I've never worked with DBMS_SQL. BIND_VARIABLE. Currently, I am going through some codes that we have that a lot of DBMS_SQL. BIND_VARIABLE.

Googling, I got to know the basic of its operation mechanism.

I have 2 questions.

1. Why do people use dbms_sql.bind_variable?


2. in our firm, it is being implemented to make many insertions as below.

The code is displayed as below (Snipped to show only the relevant parts)

No idea why the INSERT is in like that?

 
begin
--- At first a CURSOR is formed .

cursor YCURS select column1, 
              column2,
              .
              .
              .
          from manh_parcel_hdr
          where ..
          ;

        
          
typ_1 varchar2(35);
typ_2 varchar2(35);
 
 --| Then a variable is created like below
 
 manh_parcel_hdr_item number;  
 
 manh_parcel_hdr_item := dbms_sql.open_cursor;
 
 -- Then this INSERT is constructed 
 
 dbms_sql.parse( manh_parcel_hdr_item, 'insert into manh_parcel_hdr_item ( sku_id, sku_type, .......) values (  :sku_id, :sku_type, );


typ_1 := ' ';
typ_2 := ' ';



for rec IN YCURS 
loop
    pltChanged_1 := 0;
    pltChanged_2 := 0;
     
     typ_1 := rec.ACCOUNTNO_2||rec.CURRENCYCODE_2;
     
     IF typ_1 != typ_2 THEN
     
         IF rec.ACCTTYPE_1 != rec.ACCTTYPE_2  ... some more conditions...
             rec.ACCTTYPE_1 := rec.ACCTTYPE_2;
             pltChanged_1 := 1;
             
             END IF; 
             
             dbms_sql.bind_variable( manh_parcel_hdr_item,':ACCTTYPE', rec.ACCTTYPE_2 ); --- What is happening here ?
             
             
         ELSE
             dbms_sql.bind_variable( manh_parcel_hdr_item,':ACCTTYPE', '');  ---------> and here ?
         END IF;
     
...
..

Greeny wrote:

No idea why the INSERT is in like that?

My guess is to re - use the cursor INSERT handle - which is something that the PL/SQL optimizer will be done automatically.

A slider is like a program. Bind variable are as input data for this program. It works essentially as follows. You send the source SQL (with bind variable) to the SQL engine. For example

insert into footab values( :1, :2 )

This code is analyzed and a cursor is created. You return a SQL engine cursor handle. The integration program is ready to run.

You can now assign values to variables +: 1 + and +: 2 + this program. This is what we call liaison.

Once you have assigned to them, you can now run this program - and it inserts these values into the table.

Without releasing the program (closing the cursor), you can assign new values (bind) and run the program again to insert another line. And repeat this operation until you have all the data processed and inserted the required lines.

Last step is of course the release program.

And it is essentially in a few words what a slider is and how a cursor is used.

My guess is that your developer (s) did not want to encode an implicit cursor Insert in a loop - possibly think that each iteration of the loop will need to PL/SQL to create a cursor insert program, linking values to it, run it and close it. Then repeat the loop.

Thus, the developer manaually created the cursor using DBMS_SQL before the loop. And inside the loop, bind variables and run the slider. Providing this code reuses the same cursor insert again and again.

It is almost * correct approach in customer languages like C/C++, Java, PHP, Perl and so on.

However, it is not necessary in PL/SQL, as well as the optimizer recognizes what is done and how to make it optimally - create a cursor to the Insert SQL in this loop and re - use the handle to the cursor for each iteration of the loop.

The only real reason to use cursor DBMS_SQL in PL/SQL interface, is to treat dynamic SQL, a dynamic binding statements and dynamic recovery.

* The comment almost. The code is not really ideal. This bind-data and run cursor per loop iteration, it requires a 100 dregs and a cursor of 100 runs to insert a 100 lines. Sliders have a binding interface in bulk. This means that the code can bind a table - in other words, assign an array of 100 values of variable +: 1 + and a picture of a 100 variable values +: 2 +. The code then performs the cursor. Times. And cursor processes these bind tables and inserts a 100 lines.

For customers Java/Perl/etc., which reduced the number of round trips to the database. In PL/SQL, this is done using the FORALL statement and reduced the number of switches in context of the PL/SQL engine to the SQL engine.

Tags: Database

Similar Questions

  • Satellite Pro M70 freezes everytime when the USB port is used

    Satellite Pro M70 (SPM76) crashes every time when the USB port is used.
    The mouse works, but external HD/Extarnal card sound/Memory stick causing the laptop to freeze. All the drivers are installed right, they are the most recent and have no trouble with other users.

    The devices are all compatible. Service pack 2 is installed, and all the hardware drivers on the toshiba have been updated... again, same problem.
    The toshiba is about 2 months old and have had this problem since I got it. First I thought it was the drvers, but I cleared of all (?) other options but the USB ports.

    Hello

    Believe me, that's not easy to say what the problem may be. It is important to see if the problem occurs because of hardware or software may be. I recommend you to backup all your data and reinstall the unit using rescue media. On this way the unit will be factory settings and will be clean preinstalled. Test your USB devices and see what happens.

    Try to use some standard like USB stick or external HARD disk parts, because in this case, you must not install any drivers please. If you use other devices like USB webcam with own software and drivers, it is possible that something goes wrong, but what. On this path, it is not possible to say.

  • When I insert an image in the body of my email, it is replaced with an attachment when the recipient gets (also using OE).

    I use outlook express 6 on windows xp pro.

    When I Insert an image in the body of my email, it is replaced with an attachment when the recipient gets (also using OE).
    I did use the option of fixing , I used to Insert.  The reverse also occurs.  When someone using OE sends me an email with
    a peak inside the body of the email, it appears in the box and not in the body of the email. This happens only when they concern the
    my program.  Others using OE does this experience between them.

    My mail sending format is HTML and in its settings, I checked "send pictures with messages. In addition, in the tools of internet explorer, advanced, multimedia.
    I 'send photos' checked also, in the email window, under 'format', ' Rich Text (HTML) "checked.

    I have recently reinstalled cleanly win xp to address a system idle in general.  All updates are in place and tested it with antivirus and anti-malware programs.

    That is what it is?

    [Transferred from Internet Explorer]

    Original title: outlook express

    Tools | Options | Read. Read all messages in plain text it is checked? This it will make become an attachment.

  • How to control automatic shutdown when the battery is discharged using Windows

    The laptop stops right in the Middle something without notice.

    Even after that I formatted the system, he still stops automatically when the battery is low, without advising me of either the low battery status or the judgment.

    I don't think that the cause of the problem is the power management because it is set to balanced.

    How can I control when the pc stops?

    Hello

    Usually, you can change these settings within the Windows power management.
    Using Win 7 or Win 8/8.1?

    Here is the Nice technical document about the features of Windows 7 power management
    http://APS2.toshiba-tro.de/KB0/HTD12017W0001R01.htm

    Check the last option called: battery.
    It provides many useful features such as low battery, critical battery level, low battery action or critical battery action

  • Out of the blow of sleep when the HARD drive password used on Portege R700

    Hello
    I just got a DLI R700 with Win 7 Pro 64-bit
    I have a very annoying problem because it must be plus 1 minute to accept the password after the resumption of the mode standby. It would be faster out of the hibernation!
    So he wakes up from his sleep in a second, then you can enter the password without any problem but you just can't click on the arrow or press on enter up to what more than one minute. Similarly, it will accept even fingerprints directly at the exit (you get the green check mark) after wake but then expects just over one minute to move in the opening session on the desktop screen.

    Through a process of account, I worked on what was going on...
    Only, it crashes when you have the password on resume from sleep. CV password sleep turn out and he throws back in Office windows in seconds of wake
    This does not happen to resume from hibernation or reboot - scan of fingerprints or password is entered, then goes right into the office in a few seconds
    I started uninstalling software fingerpint, vap, power, toshiba - nothing always security management the same. Then I realized the password HARD drive - which was defined using the security of Toshiba and deleted using the same, has been still enabled in the bios. I have this off and everything works fine. I reinstalled the vap, power management and fingerprint software and everything is always very well, so it was defnitely the HARD drive password.
    Now it's really fake I want to have a RESUME from sleep password and HDD password protection - I have to choose between one or the other, unless I want to wait more than a minute each time he wakes from sleep which is a real pain! So it's clearly a bug in HARD drive password settings, probably in the bios? I have the latest BIOS installed.
    Any ideas on how to get this sort?

    Does anyone else have this problem with be either 32-bit or 64-bit. Or everyone doesn't have this problem, that is to say that they hear HARD drive password AND he wakes with password ok in a few seconds?
    Thank you

    Post edited by: bullerd

    Hey Buddy,

    It's really hard to say something about what I can only say that I can t noticed this problem on my Windows installation.

    By the way: you are using the version Windows from Toshiba or your own installation of Windows?

    Theoretically, it could be a problem to install Windows or disc itself are you able to test another installation of HARD drive or windows that you can make sure it is not a software problem?

  • Qosmio X 500-058: no recovery after plugging screen down when the HDMI port is used

    When I connect my new Qosimo X 500 - 058 to monitor external (with the help of an HDMI to DVI converter cable), everything works well until the power of Windows application options off the monitor.

    Once this has happened, the screens don't wake up and stays black.
    The PC were not crushed, and if you press Ctrl-Alt-Delete, you get the normal menu options.

    But if you press Cancel, or lock, and then enter the password, the screens go black again.
    This problem does not occur if I remove the HDMI cable and use only the laptop screen.

    I found that if you select the option change user after pressing Ctrl-Alt-Del monitors come back to life after a lot of glitter, if at least I don't have to re-boot each time. Does anyone have any suggestions on how I trouble shoot this?

    Cheers, Alun

    Hello alum

    Have never heard about this but anything is possible. It will be interesting to see if the same problem persists without DVI converter cable.

    When this happens can you use FN + F5 key combination to turn on the transparent back of laptop?

  • When the CBO would not use bitmap indexes available?

    I have a large data warehouse table in a star schema classic, with an index number of bitmap for the dimension tables. When you run queries that contain parameters for multiple indexes, the CBO will only use generally one or rarely two bitmap index.

    It seems to me that if the indexes are valid, statistics, the values of the parameters are present, etc and the CBO uses a bitmap index in an AND condition, he would like to use all those she could.

    there all the parameters that affect or bitmap how indexes him CBO will use? I'm looking for some advice on what to look for or research.

    Database is 11.2.0.3 base with no patch.

    Thanks in advance,

    Sean

    rp0428 - who has been deliberate because my question is not "how to solve this problem", that's exactly what I pointed out in my post. Just trying to see if there are all the controls to weight the decision-making community organizations in this area.

    OK - then let me simply state it.

    No - there are NO these parameters. But most of the posters are not really looking for a simple yes/no answer even if of many word of questions like that.

    See my response as of March 18, 2012 19:21 in this thread: https://community.oracle.com/message/10219613?

    Here I provide a simple table with SIX bitmap index, a query that uses predicates that combine values since the execution plan and the six columns indicating the different INDEX of BITMAP UNIQUE BITMAP, BITMAP or operations and BITMAP CONVERSION to ROWID.

    I won't repeat everything here, but this example should show you that Oracle will limit itself the way you suggest.

  • Legend when the "back" button is used

    Hello

    I have a problem, I opened a modal of legend, up here, everything is beautiful. But when the user types the button "return" (the return of the Android device button) the application for return should another view (OK), but the legend is on the screen.

    Any suggestions?

    I found a solution:

    1 earphone is not the component itself, but systemManager.stage

    2 listening test phase of capture as systemManager.stage.addEventListener (KeyboardEvent.KEY_DOWN, backKeyHandler, true)

    3. in the handler if (e.keyCode == Keyboard.BACK) e.preventDefault ();

    Ty

  • How to play a sound through computer speakers when the HDMI cable is used as I can't get the audio content

    I have a desktop monitor and an Alienware Alpha I bought recently, which of course is not a speaker. I use a HDMI cable to get the video of the Alpha on the screen, but when I plug the HDMI on my monitor I can not any audio to the fate of the computer speakers. In the Alpha settings, when I try to switch the audio in HDMI mode, it is said that the HDMI is not connected or incorrectly connected. Any help is appreciated. Thank you.

    I'm not quite familiar with the Alpha console, so I can only suggest to visit their support page where you can chat with an expert.

    I hope that you can solve your problem.

  • How can I cancel my Windows Live ID account when the e-mail account used to open it is closed?

    When I closed my account "comcast.net", I didn't know Windows Live ID he always used as my username. I tried to cancel, but insturctions are sent to the e-mail address that was cancelled and there is no way to change my email address. Windows Live ID Solutions does not provide a way to contact someone directly, at least as far as I could see. At anyone who will meet thiis situation?

    How does this relate to the features of Windows Update?

    See...

    HOW to close a Hotmail account
    http://liveunplugged.WordPress.com/2011/05/23/Windows-Live-Hotmail-how-to-close-a-Hotmail-account/

    And maybe http://windowslivehelp.com/solution.aspx?solutionid=d18cf147-9867-49de-a60c-aae81982a54e

    Post questions in this forum-online http://windowslivehelp.com/forums.aspx?forumid=d3fda415-1e53-4007-8e0c-2a77180ffb1d

  • Impossible to resume when the screensaver is active, using TrackPoint or TouchPad

    I can't take back Saver screen, or using TrackPoint, TouchPad, no UltraNav button as an external mouse BT.

    The one and the only way uses the Ctrl + Alt + Delete, to resume.

    How can I solve this problem?

    Kind regards

    Harel

    Hello

    Maybe it s a problem with BOINC, if the problem won´t occur with the windows screen saver.

    Maybe there is an option in the BOINC preferences or somewhat, which may, in the end

    sreensaver, when you use your mouse and perhaps other BOINC users have had this problem also.

  • LR CC 2015.3 version still crashes when the GPU acceleration is used!

    Today, I had installed Version 2015.3 and was hopeful that all the bugs have been fixed and all the problems of recent months have disappeared.

    Wishful thinking? When I turn on the GPU acceleration, it freezes again! When I disable it, everything seems to work well.

    I use a series of 380 MSI AMD Radeon R9 with 4 GB of GDDR5 memory on a Windows 7 computer.

    There is other users with similar experiences?

    Hi Suneye,

    With the new update of Lightroom, the feature GPU causing Lightroom to freeze is always a problem.

    Please read the article for a list of the Bug is fixed in the new update: Lightroom CC 2015.3 / 6.3 now available

    Kind regards

    Tanuj

  • How to make thumbnails enlarge when the effects of navigation using grid with jquery

    I used an effect of navigation grid with jquery to display several thumbnails but I would like to than images to enlarge to a larger size when they are clicked on, I don't want another window to open it, but the image should appear on the same page as the album, except that I don't need to a gallery, just the function is expanded. Please see code below my page and the link to see the demonstration of the net asset value of grid with jquery that I used (effect-"lines move", example 9).

    http://tympanus.NET/Codrops/2011/06/09/grid-navigation-effects/comment-page-2/#comments

    < ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > ""

    " < html xmlns =" http://www.w3.org/1999/xhtml ">

    < head >

    < meta http-equiv = "Content-Type" content = text/html"; Charset = UTF-8 "/ >"

    < title > my < /title > Gallery

    < link href = "stylesheet.css" rel = "stylesheet" type = "text/css" / > "

    < link href = "gridNavigation.css" rel = "stylesheet" type = "text/css" / > "

    < link href = "reset.css" rel = "stylesheet" type = "text/css" / > "

    < style type = "text/css" >

    {body

    background-color: #000000;

    }

    a: link {}

    text-decoration: none;

    color: #f1d379;

    }

    a: visited {}

    text-decoration: none;

    color: #f1d379;

    }

    a: hover {}

    text-decoration: none;

    color: #9d6f1b;

    }

    a: active {}

    text-decoration: none;

    color: #f1d379;

    }

    < / style >

    "< script type =" text/javascript"src="scripts/jquery-1.6.1.min.js "> < / script >

    "< script type =" text/javascript"src="scripts/jquery.easing.1.3.js "> < / script >

    "< script type =" text/javascript"src="scripts/jquery.mousewheel.js "> < / script >

    "< script type =" text/javascript"src="scripts/jquery.gridnav.js "> < / script >

    < script type = "text/javascript" >

    {$(function()}

    $('#tj_container').gridnav ({}

    type: {}

    lines: 2.

    mode                    : 'rows',                               // use def | fade | seqfade | UpDown | sequpdown | showHide | Scatters | lines

    Speed: 1000, / / for fade, updown, sequpdown, seqfade, showhide, disperse, lines

    easing: "easeInOutBack", / / for fade, updown, sequpdown, seqfade, showhide, disperse, lines

    factor: 150, / / seqfade, sequpdown, lines

    reverse: "/ / for sequpdown

    }

    });

    });

    < /script >

    < / head >

    < body >

    < div class = 'container' id = "container" >

    < div id = "navbar_gallery" class = "#navbar_gallery" >

    < ul >

    < li > < a href = "index.html" > homepage < /a > < /li > ""

    < li > < a href = "about_me.html" > about me < /a > < /li > ""

    < li > < a href = "gallery.html" > Gallery < /a > < /li > ""

    < li > < a href = "contact.html" > Contact < /a > < /li > ""

    < /ul >

    < / div >

    < div class = "maintext" id = "page_maintext" >

    < class p = "page_heading" > my < /p > Gallery

    < / div >

    < div class = "content Exemple5" >

    < div id = "tj_container" class = "tj_container" >

    < div class = "tj_nav" >

    < span id = "tj_prev" class = "tj_prev" > </span > previous

    < span id = "tj_next" class = "tj_next" > next </span >

    < / div >

    < div class = "tj_wrapper" >

    < ul class = "tj_gallery" >

    < li > < a href = "#" > < img src = "images/1.jpg" alt = "image01" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/2.jpg" alt = "image02" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/3.jpg" alt = "image03" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/4.jpg" alt = "image04" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/5.jpg" alt = "image05" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/6.jpg" alt = "image06" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/7.jpg" alt = "image07" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/8.jpg" alt = "image08" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/9.jpg" alt = "image09" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/10.jpg" alt = "image10" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/11.jpg" alt = "image11" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/12.jpg' alt = 'image12' / > < / a > < /li >"

    < li > < a href = "#" > < img src = "images/13.jpg" alt = "image13" / > < / has > < /li > "

    < li > < a href = "#" > < img src = "images/14.jpg" alt = "image14" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/15.jpg" alt = "image15" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/16.jpg" alt = "image16" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/17.jpg" alt = "image17" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/18.jpg" alt = "image18" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/19.jpg" alt = "image19" / > < / a > < /li > "

    < li > < a href = "#" > < img src = "images/20.jpg" alt = "image20" / > < / a > < /li > "

    < /ul >

    < / div >

    < / div >

    < / div >

    < / body >

    < / html >

    Remove the first slash in front of the call to the jquery and style sheet:

  • Error when the concatenation of CLOB using conversion implicit to_char

    Hello

    Please look at the code below (Oracle 11.1.0.7.0):
    DECLARE
      c CLOB;
    BEGIN
      FOR i IN 1..10
      LOOP
        -- Please uncomment ONE of the lines below
        c := c ||  LPAD('x', 8000, 'z') || i; -- raises error ora-06502
        --c := c || (LPAD('x', 8000, 'z') || i);  -- works
        --c := c ||  LPAD('x', 8000, 'z') || to_char(i);  -- works
      END LOOP;
    END;
    OK, making use of implicit type conversion may not be the best thing to do, but just out of curiosity, is there any explanation for this error to occur?

    It seems that, when an implicit conversion is involved without the help of hooks, Oracle tries to convert all in varchar2 before concatenate in the clob, which causes the error.

    Thank you
    Luis

    Hello
    >
    # 6.1, we have a clob and a varchar2, as in #2; Why Oracle has decided to convert the clob in varchar2 as you say, and not vice versa as in #3?
    >

    # 5, we have clob and number at the beginning. In order to evaluate the expression oracle requires that two variables was of the same type.
    As the implicit conversion there is no number-> clob
    but there are several-> varchar2 and clob-> varchar2 oracle choose this one.

  • Satego X 200-no sound when the HDMI connection is used

    Hello

    I got my Satego X 200 a year ago and since yesterday I try to use the HDMI interface to connect to an LCD TV. I get a brilliant picture, but no sound at all. Is there anything that I do not take into account? I googled everything I could think of, but appropriat answers found.

    I'd appreciate any help.

    Thanks in advance

    So I'm back again with the solution that has helped so I hope it will help other users. I did an update of the BIOS, graphics card and HD Audio. The only thing that really helped was the driver / software update, I did it on the sound by updating the drivers and s/w them have downloaded directly from the Realtek Site. SO I hope this hepls someone else in the same situation.

Maybe you are looking for

  • iPad 2 will not activate after installing 9.3

    My ipad2 activate after installing the latest update, ios 9.3.  The only option is to return a page to select the wifi.  He let me try again, but the result is always that your ipad could not be activated because the activation server is temporarily

  • stopped printing, the error message saying there is not connected

    do you have a reboot once (power supply is to unplug for 15 seconds) who worked for impressions of 1-2, then the same error again. bought the machine three days ago I need detailed help. Tried to get it from online contact, but made a mistake by ente

  • Tony

    How to upgrade my laptop Win Vista Home Premium to Win 7 or 8 using my DVDs MS licensed? I recently inherited a laptop Sony Vaio PCG - 7143M 32 Bit with a MS Win Vista Home Premium license installed and I want to upgrade the operating system.I bought

  • Vista Data Execution Prevention does not let me play tractor simulator 2013

    Vista Data Execution Prevention does not let me play tractor simulator 2013 Moved from feedback

  • How to cancel the menu "always open with this program" option

    Original title: open with problem Hello... I have a .uif file and my OS does not recognize the file. So open it with window popped up with a list of applications and I accidentally clicked on the notebook and I forgot to uncheck the always use this p