Using XQuery with PL/SQL, link the Variable

I am only able to find an example of use of xquery with pl/sql.

[http://www.comp.dit.ie/btierney/oracle11gdoc/appdev.111/b28369/xdb_xquery.htm#CBAEEJDE]

Why is what they show only using bind variables? It's the only way it should be used, it provides a performance gain more simply by using the crossing clause and a passing beam a PL/SQL variable? I'm looking to implement a solution for my company using Xquery in PL/SQL. I am concerned that these procedures will be called during a flow of the user interface and performance it must be as soon as possible.

A PL/SQL variable, column, or the output of another operation would be all be equivalent to a connection variable that PL/SQL compilation is concerned. Which would be bad practice would be to build in XQuery with the predicate hardcoded in the XQuery operation whenever the XQuery query has been run.

Tags: Database

Similar Questions

  • 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.

  • List of values when using xquery with links?

    Hello

    What is the best way to build something like:
    collection('test.dbxml')/tree[type=('a','b','c')]
    with XQuery variable when it is unclear how many entries will be in the listeType beforehand? I would like to somehow put ('a', 'b', 'c') in a context of query as a variable to something like:
    collection('test.dbxml')/tree[type=$var]
    So, avoiding the risk of strengthening of string concatenation queries.

    Hello

    Java example:

    XmlResults res = manager.createResults();
    res.add(new XmlValue("a"));
    res.add(new XmlValue("b"));
    res.add(new XmlValue("c"));
    ....
    
    xmlQueryContext.setVariableValue("myVarName", res);
    

    Vyacheslav

  • Mistake to link the variable with the clause "like %"?

    Hello everyone;

    I would like to know how to make a like clause to bind variables, with this code, I get ' ORA-00933: SQL not correctly completed command ' error
    :
    v_query:= 'UPDATE ' || collection(i) ||' SET REF_PLAN=:quatre_champ WHERE FAM_SIM like ''%'':prem_champ''%'' AND PRISE_V1P like ''%'':deux_champ''%'' AND BROCHE_V1P like ''%:trois_champ%''';
                                  EXECUTE IMMEDIATE v_query USING quatre_champ,prem_champ,deux_champ,trois_champ;
    Maybe my "'" are in a bad position?

    Thanks for your help, regards.

    Try this:

    v_query:= 'UPDATE ' || collection(i) ||' SET REF_PLAN=:quatre_champ
    WHERE FAM_SIM like ''%''||:prem_champ||''%''
    AND PRISE_V1P like ''%''||:deux_champ||''%''
    AND BROCHE_V1P like ''%''||:trois_champ||''%''';
    
  • Error using filter with Expression SQL

    Hey all -

    New to Oracle BI and have a problem with filters that use the SQL Expressions.

    The column I'm filtering is a 4-digit year, expressed as a VARCHAR2(4 byte) in the physical database. My SQL Expression in the filter is:

    Column: CAL 4-DIGIT YEAR
    Operator: is in
    SQL expression: TO_CHAR (ADD_MONTHS (SYSDATE,-24), "YYYY"))

    When I click on the "Results" tab, I get the following error message:
    Error codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    ODBC driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 27002] Near <>(): syntax error [nQSError: 26012]. (HY000)

    I've isolated the problem to the above expression. If I put a literal value and provide a year to four digits as below, it works:

    Column: CAL 4-DIGIT YEAR
    Operator: is in
    SQL expression: * 2008. *

    Any ideas on what is causing my problem?

    Thank you!

    Mac

    Yep, this should work, although sometimes you need an extra cast to CHAR.

    It works fine:
    SELECT "D0 time." "" Saw_0 T05 by name of the year ","recipes of F1. " "" Recipes 1-01 (all in all) ' saw_1 'Sample Sales' WHERE 'Time D0. "" T05 by name year ' = CAST (YEAR (TIMESTAMPADD (SQL_TSI_MONTH-24, CURRENT_DATE)) as CHAR) ORDER BY saw_0

    concerning

    John
    http://www.obiee101.blogspot.com/

  • Using jQuery with no access to the file system

    Hello

    I use APEX 3.2.1 with Oracle 10 g on Windows XP Pro SP3.

    I need (I want!) to use the JQuery library to get more beautiful datepickers (especially).

    I tried to download the jQuery library and included in my page template. I have followed me some tutorials and help from the page (or tried to help...):
    http://www.oracleapplicationexpress.com/tutorials/66-integrating-jQuery-into-apex
    http://www.oracleapplicationexpress.com/tutorials/65-jQuery-datePicker
    http://carlback.blogspot.com/2007/12/Apex-and-3rd-party-JS-libraries.html
    etc...

    Nothing has worked.

    But if I understand I need a file system access? I don't have!
    I can't use Google links too my application needs to be secured (actually https).

    I really need a script that fits easily just by adding a js for example file.
    Is it possible, or perhaps you know of other good libraries?

    Thank you.

    Yann.

    Hmm... I vaguely remember a thread about this the other day:

    Re: SEO image of workspace in the CSS file

    I think that it is best to put the style in the header html section or in the page template

    And their SEO in external JS files is discussed here: #WORKSPACE_IMAGES # is accessible from an external JS?

    Good luck!

    BTW... why not have access to / i?

  • When using webcam with MSN or Skype, the contact does not hear me.

    Original title: Audio

    When I use my Web Cam with MSN or Skype, my contact sees me but does not hear me. Suggestions?

    Hello

    Have you made changes on the computer before this problem?

    I suggest to set the default microphone and check if it helps.

    Follow the steps to set up the microphone as default:

    a. click Start, type sound in the search and open sound in Control Panel.

    b. click the recording tab.

    c. Select the Microphone icon.

    d. click set as default.

    e. click on apply then Ok to save the changes.

    Hope the information is useful.

  • Using ListView with ArrayDataModel displays only the first element in each QVariantMap within the matrix

    I have this QML who have a ListView with datasource to a full ArrayDataModel from the CPP file for creationcompleted, I loop in the table to add the hour together to appear as a label on the page, what works. However, when I want to view these items in the list, it will display only the first element of the QVariantMap within the table, no error on the log of the device. Also, triggered more does not work, but when I click it, it will have a blue border surrounding it, but the onTriggered does not fire.

    Here is an excerpt of the CPP on the table fill

    This-> eventsModel = new ArrayDataModel();

    QVariantMap event;

    event ['EventName'] = "Event1";

    event ["EventHour"] = "00";

    event ["EventMinute"] = "01";

    event ["EventSecond"] = '02 ";

    QML-> setContextProperty ("eventsModel", it-> eventsModel);

    Here's the QML

    {Of container

    ID: eventListContainer

    {To ListView

    ID: eventList

    dataModel: eventsModel

    Use a ListItemComponent to customize the appearance of the list view

    listItemComponents:]

    {ListItemComponent}

    type: 'point '.

    {StandardListItem}

    Title: 'Event' + ListItemData.EventName;

    Description: "time:" + ListItemData.EventHour + ":" + ListItemData.EventMinute + ":" + ListItemData.EventSecond; "»

    }

    }

    ]

    onTriggered: {}

    var selectedEvent = dataModel.data (row);

    var eventDetailPage = eventDetailDefinition.createObject ();

    eventDetailPage.txtEventName.text = selectedEvent ['EventName'];

    eventDetailPage.pickEventTime.value = picker.dateFromTime(selectedEvent["EventHour"]+":"+selectedEvent["EventMinute"]+":"+selectedEvent["EventSecond"]);

    eventDetailPage.open ();

    }

    }

    Any help would be appreciated.

    Thank you.

    ListView determines ItemType of the element by calling the function itemType of the dataModel. By default, an ArrayDataModel returns an empty string for this call (see https://developer.blackberry.com/cascades/reference/bb__cascades__arraydatamodel.html).

    This leaves you with a few options:

    (1) If you have no header and all the elements are the same, you can make

    ListItemComponent {
         type: ""
         ...
    

    (2) If you have headers or different elements, you can extend ArrayDataModel and implement your own function of itemType

    (3) you can define a function of ItemType on your ListView in QML. Documentation:

    ListView called DataModel::itemType() for each item in order to know the type. QML, this can be overridden by declaring the itemType function (data, row) on the ListView element. ListView then call this function instead of the function DataModel.

    Here's how to create a list in QML which creates a header for all items on the high level and aStandardListItem for each item below the top level:

  • How to use "sketches with current brush" in the menu 3d

    Hi all

    I had a question:

    How can I work with "current sketch with brush" in the menu 3d photoshop cs6

    Help me!!!

    Hello! It must all firstly, make sure you are not using Windows XP, because the 3D functions are not available with this operating system.

    What are you trying to follow a tutorial video, or you have questions about how to use this particular function?

  • can you use FaceTime with three devices at the same time.

    I need to be able to have a video conference with three people. A person will demonstrate a product whose other two will check to see that it is OK. Each person is in a different location. I can't find anywhere how to do this. Since it is an event of the time, I won't buy any conference high-end software. We will have a combination of iPhones and iPads.

    N ° but Skype should work.

  • APEX_UTIL. JSON of SQL in the variable

    Hi all

    How do we store result of APEX_UTIL. JSON_FROM_SQL ("select a, b, c of double'") in a SQL PL variable? Any help. Urgent!

    Thank you

    Sunil bhatia

    declare
      function sql2json( p_sql varchar2 )
      return varchar2
      is
        t_cur pls_integer;
        t_cols dbms_sql.desc_tab2;
        t_ncols pls_integer;
        t_dummy pls_integer;
        t_d date;
        t_n number;
        t_v varchar2(4000 char);
        t_json varchar2(32767);
        t_object varchar2(32767);
      begin
        t_cur := dbms_sql.open_cursor;
        dbms_sql.parse( t_cur, p_sql, dbms_sql.native );
        dbms_sql.describe_columns2( t_cur, t_ncols, t_cols );
        for i in 1 .. t_ncols
        loop
          case
            when t_cols(i).col_type in ( 2, 100, 101 )
            then
              dbms_sql.define_column( t_cur, i, t_n );
            when t_cols(i).col_type in ( 12, 180, 181, 231 )
            then
              dbms_sql.define_column( t_cur, i, t_d );
            else
              dbms_sql.define_column( t_cur, i, t_v, 4000 );
          end case;
        end loop;
        t_dummy := dbms_sql.execute( t_cur );
        while dbms_sql.fetch_rows( t_cur ) > 0
        loop
          t_object := '{';
          for i in 1 .. t_ncols
          loop
            t_object := t_object || case when i > 1 then ',' end || '"' || t_cols(i).col_name || '":';
            case
              when t_cols(i).col_type in ( 2, 100, 101 )
              then
                dbms_sql.column_value( t_cur, i, t_n );
                t_object := t_object || nvl( to_char( t_n, 'TM9', 'NLS_NUMERIC_CHARACTERS=.,' ), 'null' );
              when t_cols(i).col_type in ( 12, 180, 181, 231 )
              then
                dbms_sql.column_value( t_cur, i, t_d );
                t_object := t_object || '"' || to_char( t_d, 'dd-mm-yyyy' ) || '"';
              else
                dbms_sql.column_value( t_cur, i, t_v );
                t_object := t_object || '"' || replace(
                                               replace(
                                               replace(
                                               replace(
                                               replace(
                                               replace(
                                               replace(
                                               replace( t_v
                                                      , '\', '\\' )
                                                      , '"', '\"' )
                                                      , '/', '\/' )
                                                      , chr(8), '\b' )
                                                      , chr(12), '\f' )
                                                      , chr(10), '\n' )
                                                      , chr(13), '\r' )
                                                      , chr(9), '\t' ) || '"';
            end case;
          end loop;
          t_json := t_json || case when t_json is null then '[' else ',' end || t_object || '}';
        end loop;
        dbms_sql.close_cursor( t_cur );
        return nvl( t_json, '[' ) || ']';
      end;
    begin
      dbms_output.put_line( sql2json( q'~select 'test' || level a, level b, sysdate c from dual connect by level <= 5~' ) );
    end;
    
  • I've used TrueCrypt for 2010 when it was installed on my computer by our office technology. I used it with no problems until the last update I installed on Tuesday evening. Since that time, I was not able to open TrueCrypt

    Tuesday night, I downloaded and installed the latest security update. On Wednesday morning at the restart, AVG Anti Virus intercepted a few Trojans and several files of phishing. I then proceeded to power work and tried to open TrueCrypt, which contains working files. I get this error message: MacFUSE file system is unavailable (- 1). I searched for the last 24 hours as he tried to do what work I can without these files for a solution to discover that MacFUSE is no longer supported (useless?).

    I tried to reverse the quarantine of the AVG files, I was wondering if those who were somehow the culprits who have been involved - which didn't work so then I ran AVG again completely to remove all people still. When I got home from work, I discovered that my Time Machine and AirPort have not communicated since Oct. 15. I'm in the middle of a new backup, which takes forever. I don't know what to do next. I hate the idea of restoring my computer to Oct. 15, when I was able to access the files. Is there a way to restore my computer to the State before the upgrade of security?

    I've seen it is called OSXFUSE I was wondering if I installed if she somehow would allow me to access the files in TrueCrypt and decided which was just fantastic.

    What would you recommend?

    MacBook Pro OS X Yosemite 10.10.5, 2.7 GHz Intel Core i7, 16 GB, 500 GB hard drive

    What would you recommend?

    Uninstall "AVG" and restore your Mac from a backup created before leave corrupting your system. Do not reinstall, or something like that, never.

    Uninstall, read and follow these instructions, paying special attention to the grammatically incorrect "Note" at the end of the page: everything-AVG-AntiVirus-for-Mac https://support.avg.com/SupportArticleView?q=uninstall+avg&urlname=How-to-uninst & l = en_US

  • use robocopy with the switch /MIR safe?

    Hello

    I use Robocopy to copy my phone book c:\users\username on a second hard drive (D :). No problem. But I also want the mirror of this second hard drive on a third drive hard (e). I have been using the /MIR copy/mirror hard drive D: E: switch.
    We know that /MIR deletes several files from the disk of destination files (e: in this case) if they no longer exist on the source (d) drive.

    But I recently saw somewhere on the internet, there are certain risks that /MIR can also remove some of the source files in certain circumstances. Scary!
    Here is the exact quote (unfortunately I did not record the site it comes.)

    Use /MIR with caution - it has the ability to delete a file from the source and destination, under certain conditions.

    This happens usually if a file/folder in the destination has been removed, causing ROBOCOPY to mirror the source to the destination. As a result, the same files in the source folder are also deleted. To avoid this situation, never to delete all the files/folders on the destination - remove from the source and then run the backup to mirror the destination to the source.

    If in doubt, do not use the MIR, but be aware that backups will take more time.

    So I wonder if it's true and/or tailored to my needs.  The explanation above don't make much sense to me. For the moment, I have abandoned the /MIR switch and am just using the Robocopy command to copy the second HD in the third.

    Thanks much for the thoughts or advice or links.

    Jack

    The /MIR switch is NOT a two-way synchronization.  Right of the Microsoft documentation, it tells you/MIR/e + / purge.  It does not remove the source files.  The /MOV option removes the files from the source because you move them from the source to the destination.

    The /mir option is equivalent to /e plus/purge with a small difference options in behavior:

    • With the /e plus/purge option, if the destination directory already exists, the destination directory security settings are not replaced.
    • With the /mir option, if the destination directory already exists, the security settings for destination directory are replaced.
  • Apply the variable definition in the subclass with abstract method

    Hello

    It's his practice use? :
    public abstract class Base {
        private int importantPrivateVariable = setImportantPrivateVariable();
        protected abstract int setImportantPrivateVariable();
    }
    I want to apply the extension of the class to define a private variable, but there is no variable abstract in java, I can use a method for that.

    Thank you
    lemonboston

    Edit: the variable can be protected as well, I guess that's not important here, but correct me if I'm wrong

    lemonboston wrote:
    Hello

    It's his practice use? :

    I don't think it's so common, but it's easily understandable code. However, there are several problems with this approach:

    public abstract class Base {
    private int importantPrivateVariable = setImportantPrivateVariable();
    protected abstract int setImportantPrivateVariable();
    }
    

    I want to apply the extension of the class to define a private variable

    This is some what your code implements: your base class requires the subclasses to return an int value, and the Base class uses this value to assign to the variable.

    Therefore, the method should be called to (for example getInitialValueOfImportantVariable()+ to have a consistent naming with his signature (it returns a value, whereas a regular setter must declare a void return type: protected abstract void setImportantPrivateVariable (int someValue);).)

    Edit: the variable can be protected as well, I guess that's not important here.

    Well, Yes, it is 'important' - at least, there is a noticeable difference: the variable is private, the base class is free to treat it as seems it (for example, assign the value at construction time and never change it later). If the variable was protected, the subclass could change in ways and at times not known by the base class.

    but correct me if I'm wrong

    There is a trap in this construction: the method is called in the variable initializer, i.e., behind the scenes, about during execution of the Base, so before the constructor of the sub-class class constructor. For example, you call a method on an object that is not completely initialized (for example some of its attributes may always be null at this point). There is a rule that discourages this kind of situation, which goes something like "no calling private and unofficial constructor methods.

    To avoid this trap, two options:
    -requires an int argument in the constructor of the Base class, as suggested above
    -Don't be and set the value of the important variable in the code of the initializer or the constructor, but a special method in the base class instead:

    public abstract class Base {
        private int importantPrivateVariable; // default value is zero
    // or alternatively:
    //    private int importantPrivateVariable = ...; // Some default value
        protected abstract int getImportantPrivateVariable();
    
        public void initializeImportantPrivateVariable() {
            importantPrivateVariable = getImportantPrivateVariable();
        }
    }
    

    This construction is a degenerate form of a common model known as the model method (where a base class method calls usually several methods of the subclass in a specified order and with a specified sequence, allowing for the subclass to implement the details of the methods).

    The downside is that the client code (the one that uses the Base instance) must know when to call this initialization method, while initialization, a constructor-based allows the free client code of don't like do not at all.

    Much luck,

    J.

  • SE THROW in SQL in the AIR?

    Hello

    I understand how to use the headphones of BEGIN and COMMIT etc.

    I was wondering if you can use BEGIN TRANSACTION and COMMIT around a bunch of SQL process into a single string?

    for example

    "BEGIN TRANSACTION".

    CREATE IF NOT EXISTS idx1 INDEXES ON table1 (COLLATE NOCASE artist, title COLLATE NOCASE);

    CREATE IF NOT EXISTS idx2 INDEXES ON table1 (Id, Date);

    CREATE INDEXES IF NOT EXISTS idx3 ON table1 (time, reason COLLATE NOCASE);

    END OF TRANSACTION.

    or must all be distinct instructions, each with a listener?

    I ask that I get an error "BEGIN is not allowed in SQL.

    See you soon

    I don't think it's the correct way to use transactions with AS3 SQL, try using the methods of the SQLConnection class transaction. Check out this link: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/data/SQLConnectio n.html #begin (). It is very easy, you simply add sqlcon.begin () before you run instructions and use sqlcon.commit () after.

    Hope I was helpful

Maybe you are looking for

  • animations of Siri 9.2 iOS on iPhone glitch 6 Plus

    Anyone else notice this? It's a bit annoying for eyes. Reminds me of Android. Use iPhone 6 Plus

  • HP 3050 HAS

    I just bought printer HP 3050 has that is wireless. Unfortunately, my DVD/CD drive is broken and I can't use the drive. I was able to buy an external DVD player £40 but is possible that I can get my printer to post a link in my laptop and the router

  • Can MapPoint 2011 - be installed without the substitution of previous versions?

    I need to be able to keep older versions of MapPoint on my laptop while having access to 2011.  I could install 2009 without the substitution of 2004 and 2006, but my IT people say it cannot be done with 2011.  Can he?

  • SATA 3 6 GB showing in safely remove hardware?

    I just installed a new hard drive WD SATA 3 (WD1002FAEX)and it shows in the remove hardware safely. I found this fix: How Stop disk appearing in Safely Remove Hardware It seems that Windows 7, some sata ports are incorrectly installed as external por

  • Data clear BBM BBM Android will change BBM PIN code?

    Dear Experts, Currently my BBM on my Lennovo S920 was very slow and I am planning on getting some clear data via the parameter > Apps > BBM > clear data to free up space used (now, it has already reached > 200 MB). My question is, by doing this, when