Difference between static & dynamic sql

Hello

It is my first question in OTN.

I have a pl/sql procedure with no insert statements.

Insert into table values...

If I turn all these insert statements in dynamic sql, my procedure will give more effective? (execution)

Please help me.

Thanks in adv

Friend

Hello

8b00c42d-7716-467e-BCEF-c756fd9599e2 wrote:

Hello

It is my first question in OTN.

Welcome to the Forum!

To get the most out of this Forum, see the FAQ in the Forum: Re: 2. How can I ask a question on the forums?

For all performance issues, see also this Forum FAQ page: Re: 3. how to improve the performance of my query? / my query is slow.

I have a pl/sql procedure with no insert statements.

Insert into table values...

If I turn all these insert statements in dynamic sql, my procedure will give more effective? (execution)

Probably not.  Dynamic SQL is generally less effective than static SQL, as well as being more difficult to code, debug and maintain.

Is there a reason why you think that the dynamic SQL would be preferable in this case?  If so, what is it?

Tags: Database

Similar Questions

  • Difference between static and dynamic encryption card

    Anyone tell me the difference between static and dynamic encryption card?

    Hi Rodrigo,

    Public static crypto map - identifies by the peers and traffic to encrypt explicitly. Generally used to host some tunnels with different profiles and characteristics (different partners, sites, location)

    So, when you have the information of the two peers than what policies we're going to use, what is the IP on both devices we normally use static VPN.

    Crypto dynamic map - is one of the ways to accommodate peer sharing the same characteristics (for example, several offices of branches share the same configuration) or peers with dynamic IP addressing (DHCP, etc.)

    For more information, please visit:

    https://supportforums.Cisco.com/document/12013476/crypto-map-based-IPSec...

    Kind regards

    Aditya

    Please evaluate the useful messages and mark the correct answers.

  • Difference between standard edition SQL and SQL workgroup edition

    I'm buying the processor SQL License. I'm looking for the standard edition of SQL, but the SQL workgroup edition is less expensive. I wonder what the difference is in two versions

    Hi DBBurns,

    This document compares the editions of SQL and should answer your question. If you need help, your questions there will be better answered in the Forums of SQL.

  • What is the difference between regular dynamic cache AWT and AWT group?

    Hi Chris, on the dynamic cache of AWT group, you said that:
    ------------------------------------------------------------------------------------
    A group of dynamic cache is where, for some types of access (key equality) in SELECT/UPDATE/DELETE and for certain types of iNSERT as a "cache miss" (no corresponding line found in TimesTen) will cause a dynamic extraction of the files required from Oracle to be loaded into the cache, and also returned to the application (in SOME cases).
    ------------------------------------------------------------------------------------
    So I guess that for the regular cache AWT group, it will not have any dynamic fetches files required from Oracle to be loaded into the cache
    because the cache AWT regular group, we load the data into RAM first, right?


    Thank you

    SuoNayi

    That is right. For a group of AWT regular cache it is load you explicitly any required data explicitly using LOAD CACHE GROUP. To cache DYNAMIC groups you can "Prime" group cache using CACHE of LOADING GROUP if you wish, but it will also make dynamic extraction for the types of the SQL operation supported. They each have their uses depending on your use case.

    Chris

    Published by: ChrisJenkins on November 28, 2012 13:15

  • Difference between the Expression SQL and PL/SQL Expression

    Hello

    I use the value of the Pnn_ACTIVE_SECTION variable type to show and hide regions.

    Based on similar logic, I also filter or put on condition of validations of fire based on same Pnn_ACTIVE_SECTION and a few other conditions as element value is null or not null.

    What is the best way to filter.

    I used [item = value] option earlier and after a few lights, now I use SQL EXPRESSION that according to me is not otherwise effective than PL/SQL EXPRESSION.

    Is this correct? Or who make no difference on the performance of application? I have at least 7 forms and about 100 postings by form (especially the function that returns the error text for the club of multiple postings on the same point in a validation)

    Based on the reviews of the forum, I'll turn in my application.

    Does not say that at all. It says that they are different and use another language (SQL or PL/SQL). It is not about performance.

    My first post is yet - maybe you should reread.

    See you soon

    Ben
    http://www.munkyben.WordPress.com
    Don't forget to mark the answers useful or correct ;)

  • Sort of the differences between Oracle and SQL Server

    Hi all

    This question is linked by both Oracle and SQL Server

    I have a requirement where I want to compare 2 tables line by line. A table is in Oracle and other table in SQL Server

    And suppose that both tables do not have a primary key. Now when I sort records by using the order by clause for a column, then-

    Rows with null values in that column of Oracle are placed in the background.
    When that rows with null values in the same column in SQL Server are placed right at the top.

    How can I make one of them to behave like any other.

    My only goal is to have same order of lines in Oracle and SQL Server tables so that I can compare line by line.

    YADQ: Yet another Doc Question

    Can you please avoid them?

    Take your SQL reference manual, search for the ORDER BY clause and notice that it has
    NULL FIRST or LAST values NULL values.

    ------------
    Sybrand Bakker
    Senior Oracle DBA

  • Difference between the static SQL query and dynamic SQL query.

    Hello

    Please explain the fundamental difference between static and dynamic sql queries. Please explain for example.

    Static: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/static.htm
    Dynamics: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/dynamic.htm

  • Difference between standard java bean and dynamic bean?

    Hi all
    Can does anyone of you tell me the difference between the dynamic standard java bean and bean?

    Thanks in advance...
    Sudhakar.

    DynamicBean

  • Tables created in a stored procedure cannot be used with dynamic SQL? The impact?

    There is a thread on the forum which explains how to create tables within a stored procedure (How to create a table in a stored procedure , however, it does create a table as such, but not how to use it (insert, select, update, etc.) the table in the stored procedure.) Looking around and in the light of the tests, it seems that you need to use dynamic SQL statements to execute ddl in a stored procedure in Oracle DB. In addition, it also seems that you cannot use dynamic SQL statements for reuse (insert, select, update, etc.) the table that was created in the stored procedure? Is this really the case?

    If this is the case, I am afraid that if tables cannot be 'created and used"in a stored procedure using the dynamic SQL, as is the case with most of the servers of DB dynamic SQL is not a part of the implementation plan and, therefore, is quite expensive (slow). This is the case with Oracle, and if yes what is the performance impact? (Apparently, with Informix, yield loss is about 3 - 4 times, MS SQL - 4 - 5 times and so on).

    In summary, tables created within a stored procedure cannot be 'used' with dynamic SQL, and if so, what is the impact of performance as such?

    Thank you and best regards,
    Amedeo.

    Published by: AGF on March 17, 2009 10:51

    AGF says:
    Hi, Frank.

    Thank you for your response. I understand that the dynamic SQL is required in this context.

    Unfortunately, I am yet to discover "that seeks to" using temporary tables inside stored procedures. I'm helping a migration from MySQL to Oracle DB, and this was one of the dilemmas encountered. I'll post what is the attempt, when more.

    In Oracle, we use [global temporary Tables | http://www.psoug.org/reference/OLD/gtt.html?PHPSESSID=67b3adaeaf970906c5e037b23ed380c2] aka TWG these tables need only be created once everything like a normal table, but they act differently when they are used. The data inserted in TWG will be visible at the session that inserted data, allowing you to use the table for their own temporary needs while not collide with them of all sessions. The data of the TWG will be automatically deleted (if not deleted programmatically) when a) a commit is issued or b) the session ends according to the parameter that is used during the creation of the TWG. There is no real need in Oracle to create tables dynamically in code.

    I noticed that many people say that the "Creation of the tables within a stored procedure" is not a good idea, but nobody seems necessarily explain why? Think you could elaborate a little bit? Would be appreciated.

    The main reason is that when you come to compile PL/SQL code on the database, all explicit references to tables in the code must correspond to an existing table, otherwise a djab error will occur. This is necessary so that Oracle can validate the columns that are referenced, the data types of those columns etc.. These compilation controls are an important element to ensure that the compiled code is as error free as possible (there is no accounting for the logic of programmers though ;)).

    If you start to create tables dynamically in your PL/SQL code, so any time you want to reference this table you must ensure that you write your SQL queries dynamically too. Once you start doing this, then Oracle will not be able to validate your SQL syntax, check the types of data or SQL logic. This makes your code more difficult to write and harder to debug, because inevitably it contains errors. It also means that for example if you want to write a simple query to get that one out in a variable value (which would take a single line of SQL with static tables), you end up writing a dynamic slider all for her. Very heavy and very messy. You also get the situation in which, if you create tables dynamically in the code, you are also likely to drop tables dynamically in code. If it is a fixed table name, then in an environment multi-user, you get in a mess well when different user sessions are trying to determine if the table exists already or is the last one to use so they can drop etc. What headache! If you create tables with table names, then variable Dynamics not only make you a lot end up creating (and falling) of objects on the database, which can cause an overload on the update of the data dictionary, but how can ensure you that you clean the tables, if your code has an exception any. Indeed, you'll find yourself with redundant tables lying around on your database, may contain sensitive data that should be removed.

    With the TWG, you have none of these issues.

    Also, what is the impact on the performance of the dynamic SQL statements in Oracle? I read some contrasting opinions, some indicating that it is not a lot of difference between static SQL and SQL dynamic in more recent versions of Oracle DB (Re: why dynamic sql is slower than static sql is this true?)

    When the query runs on the database, there will be no difference in performance because it is just a request for enforcement in the SQL engine. Performance problems may occur if your dynamic query is not binding variable in the query correctly (because this would cause difficult analysis of the query rather than sweet), and also the extra time, to dynamically write the query running.

    Another risk of dynamic query is SQL injection which may result in a security risk on the database.

    Good programming will have little need for the tables of dynamically created dynamically or SQL.

  • The difference between the admin directory and directory patch?

    What is the difference between $< PRODUCT_TOP >/admin/sql and $< PRODUCT_TOP > / 115/patch/sql

    I looked at a number of packages on my system, and they seem to be constructed from its location *.pls in my $< PRODUCT_TOP > / patch/115/directory sql

    However it is normally also have a file with the same name in $< PRODUCT_TOP >/admin/sql, but it generally has a different version number (in my case, I found some files in it that have a version number that is greater than what is in the directory of 115/patch/sql)

    Thank you
    Jim

    My understanding is that the product admin directory using automatic upgrade as part of an upgrade?

    Fix.

    Q. Since Auto Upgrade is involved, I guess that means say 11i upgrade for R12 (what was once a migration) rather than what would be a Pack of updates to version (which is formerly a Maintenance release) for example 11.5.10.2?

    I would say that it is applicable to all the patches that update APPL_TOP, so it applies to the outermost Regions and the Maintenance Pack patches but not an 11i to R12 as a new APPL_TOP upgrade is created in this case (unless you are referring to the new APPL_TOP).

    Q. the patch product_top directory holds transferred files in to adpatch?

    Yes.

    If he holds only the latest version provided by the various patches that have been applied to this top product?

    Yes.

    Q: why would the product_top directory admin hold files with version numbers higher than that which is in the product_top patch?

    Can you give an example for this?

    Thank you
    Hussein

  • Difference between dynamic and static converters

    Hi, I am looking to understand the difference between a static and a dynamic DAC. I will work on a project that has a very high number of analog outputs 30 IO. I need a Board of 16-bit resolution. I intend to update outputs at a low frequency in the order of 1 Hz (on user deand). I have suggested to use the NI PXI-6704 card with 32 outputs. In order to future-proof our equipment, we plan to buy a few boards that are capable of fast output update rate (a few hundred Hz). I want to know what I'm lost and win with static and dynamic converters. What advice (which are quite fast) would work better for this high number of IO? I'm looking at the 6733, but I am not quite convinced that it is the best alternative.

    Hello

    If you get all PXI/SMU modules, you'll either buy a controller MXI to connect to the desktop computer or to spend more money and get a controller embedded to the SMU chassis. If you want to run applications in real time in the future, you can spend more money upfront and get the controller shipped instead of the connection of MXI. MXI connection allows flexibility of system more than the on-board controller because it allows you to run additional devices that may not be available in PXI format. The two methods are the same in terms of future evidence, they just offer different possibilities (flexibility or real-time).

    Eric

  • Difference between dynamic and dynamic routing issue

    Hello

    Can someone let me know the difference between dynamic routing and dynamic publishing in the oracle service bus

    Thank you
    Barro

    Hello

    If the outgoing end point is not static or Exchange with the incoming request again for dynamic actions...

    Routing is used for calls for installation (who have asked and answer) that is routing action awaits the response before going to the pipeline of response
    Publish is used for asynchronous calls (which does not hv any answer).

    See you soon,.
    Afonso Gupta

  • difference between the incremental update of the IKM oracle and incremental update IKM oracle (PL - SQL)

    Hello

    What is the difference between the incremental update of the IKM oracle and updated incremental IKM oracle (PL - SQL) and incremental update IKM oracle (line by line).

    Thank you

    Papai

    The only difference is that the second using plsql for incremental update. He also to manage clob issues well enough.

    If you need to know more you can read the description of each KM section.

    Incremental update IKM Oracle (PL-SQL)

    -------

    Description:

    -Knowledge integration module

    -Integrates data into an Oracle table from target in incremental update mode using PL/SQL.

    -Non-existent rows are inserted. already existing lines are updated.

    -Data can be controlled. Data invalid are isolated in the error Table and can be recycled.

    -This KM uses PL/SQL to perform the inserts and updates until and blob columns are supported. Please see the restrictions.

    -When you use this module with a source table logged, it is possible to synchronize the deletions.

    Restrictions:

    -When working with the logged data, if the "synchronize destruction of the newspaper" are executed, the lines deleted on the target are engaged

    -The data are updated even if not changed (upgrade from any (e)

    -The number of lines (number of inserts/changes) is not available because the transactions are performed using PL/SQL

    -Comparison of the data is performed using the key to update defined in the interface. It must be set.

    -L'option TRUNCATE does not work if the target table is referenced by another table (foreign key)

    -Options FLOW_CONTROL, and STATIC_CONTROL call the Module knowledge check to isolate invalid data (if no CKM is defined, an error occurs). These two options should be set to NO in the case where an integration Interface meets a TEMPORARY target data store.

    -L' FLOW_TABLE_OPTION option is set by default to NOLOGGING. Set it to a space if the interface is running on an Oracle 7 database

    -Deletions are committed regardless of the VALIDATION option

    Incremental update of the IKM Oracle

    -------------

    DESCRIPTION:

    -Integrates data into an Oracle table from target in incremental update mode.

    -Non-existent rows are inserted. already existing lines are updated.

    -Data can be controlled. Data invalid are isolated in the error Table and can be recycled.

    -When you use this module with a source table logged, it is possible to synchronize the deletions.

    REQUIREMENTS:

    -The update key defined in the interface is required.

    RESTRICTIONS:

    -When working with the logged data, if the "synchronize destruction of the newspaper" are executed, the lines deleted on the target are engaged

    -L'option TRUNCATE does not work if the target table is referenced by another table (foreign key)

    -Options FLOW_CONTROL, and STATIC_CONTROL call the Module knowledge check to isolate invalid data (if no CKM is defined, an error occurs).

    These two options should be set to NO in the case where an integration Interface meets a TEMPORARY target data store.

    -L' FLOW_TABLE_OPTION option is set by default to NOLOGGING. Set it to a space if the interface is running on an Oracle 7 database

    -Deletions are committed regardless of the VALIDATION option

    -L' ANALYZE_TARGET option will allow to assess correct statistics only if the VALIDATION is set to Yes. Otherwise, the IKM gather statistics based on old data.

    -Default UPDATE option is TRUE, which means by default it is assumed that there is at least one column nonkey specified in a target data store.

  • What is the difference between the sql statement

    What is the difference between below sql statements, get the output of these statements

    In the test table will have 55 columns

    Select count (*) from test_table

    Select count (1) into test_table

    Select count (10) into test_table

    Select count (100) in test_table

    Select count (100000) into test_table

    Thank you

    Published by: Balajiraam on December 28, 2011 20:51

    Published by: Balajiraam on December 28, 2011 21:02

    Hello
    This will be useful for you

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1156151916789 #25335122556076

    Kind regards
    Fame

  • Is it possible to keep all static?   (vs dynamic SQL)?

    Hi all

    I have existing MS who after db Exchange should work with newly partitioned table partition name = date of entry both inside AND date_param, something like:

    sql_string: =' select * tt partition (P_'| date_param |') the problem of configuration required, I can't use any dynamic SQL and it really put me in the corner, do you think it is at all possible? I was thinking about a lot of things that may work, but date_param is just date < 12 - 7.-10. > and partition is preceded with PRT_?

    I can to with str_part: = ('(P_'|| date_param ||'') ') "), but it is already dynamic...

    Even after I create the temporary table and for sure, I know that the DDL inside the procedure should be ONLY dynamic?
    What is the dead end? There is a way to CREATE static? or simply to use kind of temp table created outside MS and clean it before use? or...

    I actually try to see why customer site cannot manage NDS or they just don't want it, but can't argue with that for now.
    I've got enough new to Oracle and couldn't do bad things on the SQL dynamic (NDS)?

    Thank you all
    TR

    Trento wrote:
    Hi all

    I have existing MS who after db Exchange should work with newly partitioned table partition name = date of entry both inside AND date_param, something like:

    sql_string: =' select * tt partition (P_'| date_param |') the problem of configuration required, I can't use any dynamic SQL and it really put me in the corner, do you think it is at all possible? I was thinking about a lot of things that may work, but date_param is just <12-Sep-10>and partition is preceded with PRT_?

    I can to with tmp_part: = ('(PRT_'|| date_param ||'') ') "), but it is already dynamic...

    Even after I create the temporary table and for sure, I know that the DDL inside the procedure should be ONLY dynamic?
    What is the dead end? There is a way to CREATE static?

    I actually try to see why customer site cannot manage NDS or they do not want, cannot buy with that for now. I'm pretty new to Oracle and could not do bad things on dynamic SQL?

    Thank you all
    TR

    Why the hell wouldn't you just query the table and apply the predicate? Oracle would then partition elimination for you.

    No need for anything either dynamics based on what you posted.

Maybe you are looking for

  • Firefox broken 39.0.3 GM location Hack how can I fall back to 39.0 FF?

    I have Greasemonkey scripts that use this type of code Location.href = "JavaScript: void (tpzDrillTable ("var/L.tab.1 ', , ' 5')); "; Since "redevelopment" of FF 39.03 this code stopped working https://bugzilla.mozilla.org/show_bug.cgi?id=1192821 I w

  • Cannot post - get void popup alert

    I tried to post a question on a problem with Mac Mail and SMIME. However, I just can't post anything on the communities site. When I fill in the details and the hit 'post', it scrolls up to a blank error box. See the image as an attachment - note the

  • Replace merge with ssd drive, cannot be done?

    My hard drive of my iMac 27 ", end 2012, is running out. It has a fusion of 1 TB drive. I asked the service guy how much it would cost to replace the 1 TB with a 512 GB SSD drive. He said that one cannot do. He claims that the only thing that can be

  • Select icon workstation: so, 'aid', so: "Help and Support Center" - &#62; does not work.

    When I select "Help and Support Center" with Microsoft, I get the error message: "Windows cannot find helpctr.exe. Can I reinstall anything from Application or system recovery disks - or download the Microsoft HELP?  - Or can only be re-established b

  • New EA4500 router slow?

    Just bought a new router EA4500 and expecting to have better performance (speed/signal strength) than my old router Cisco/Linksys E2500, but it is significantly slower than my old router. How can I raise the router by changing some aspects of it (lik