Dynamic cursor Type strong?

I am currently using Oracle 11.2 G and I was wondering if you can declare a dynamic cursor as a strong Ref Cursor type or it may be declared as weak type ref cursor? Now, if she can only be declared as a weak type Ref Cursor, is it possible to avoid having to explicitly declare the type names and field being returned by the cursor? Sense, is any way to avoid having to do something like that...
TYPE example_rec IS RECORD
(
 col1 VARCHAR2,
 col2 NUMBER,
 col3 NUMBER,
 etc...
)
Instead, I was wondering if I could just set the fields and their types by defining them as a TABLE OF THE ref cursor?

I wonder if this is possible is because I have a large number of fields returned in my cursor, and I was hoping on not having to type each person and its type. In addition, I think this would make maintenance easier.

user652714 wrote:
No, not quite. I ask if I can create a strong dynamic type Ref cusors. Here is a Pseudo code:

DECLARE
TYPE test_rec IS TABLE OF test_cur%ROWTYPE; -- i'm wondering if i can do something like this
--'The code below is what I am TRYING TO AVOID'
TYPE test_cur IS REF CURSOR;
TYPE test_rec IS RECORD
(
col1 VARCHAR2,
col2 NUMBER,
col3 NUMBEr
)

Is not possible.

Let's say you would set an TEST_REC as above. How would refer to the members of the structure of your code? This type could describe anything like projection of the cursor could be anything - a unique column, to a 100 columns. A combination of columns that can include data types of the LOB of tables nested SQL types defined by the user.

So, how can you refer to these columns in the structure of table TEST_REC ? Guess?

A new concept - all SQL statements are parsed, stored and executed as sliders. REF CURSOR, cursors implicit, explicit cursors and so on, are CLIENT interfaces to the created SQL cursor. Each of these interfaces to client cursor works in a specific way and provide a set of specific features.

Next concept - to extract a SQL cursor, the client code NEEDS to know the structure of the projection of this cursor SQL. The code needs to know the number and types of data in the columns returned by the cursor.

The customer may address the issue in two ways.

Statically. In other words, at the time of coding, SQL projection, returned by this SQL cursor is known. The developer can thus use some thing like + % RowType % + to indicate to the compiler that record structure to define. The compiler parses the SQL cursor in the code, describes the projection of SQL and compiles this projection of SQL as the static structure in the code.

+ % RowType + in this regard is as a #define of C macro. He tells the PL/SQL compiler to describe the cursor SQL projection, then produced a PL/SQL, based on the record structure.

Dynamically. This means at the time of coding, SQL, returned by this SQL cursor is unknown. In this case the compiler has no idea at compile time what structure will be returned by the cursor. Compiled source code may not define a static structure for this cursor SQL - the SQL cursor may return any kind of structure. The source code needs to use the same approach as what the compiler does when it comes to SQL static cursors.

The source code needs to analyze the cursor, describe the SQL cursor and then pick dynamically by the cursor. Client cursor interface that supports this approach is DBMS_SQL. No ref Cursor.

Keep in mind that these static and dynamic methods to describe how the code consumes the cursor - extraction of rows in the cursor.

A static method (where the projection of SQL is known) however apply to the TWO instructions static SQL and dynamic SQL statements. You can use dynamic SQL statements in your code, but a rule which stipulates that, regardless of the SQL code is waiting for a specific static SQL projection of this SQL cursor.

The dynamic method (where the projection of SQL is unknown) is 'real' dynamic SQL - as the projection of SQL and are all two dynamic SQL code.

Examples of Basic code:

// STATIC SQL CURSOR
SQL> create or replace procedure FooProc is
  2          cursor  c is select object_id, object_name from user_objects;
  3          type    TBuffer is table of c%RowType;
  4          buffer  TBuffer;
  5  begin
  6          open c;
  7          loop
  8                  fetch c bulk collect into buffer limit 100;
  9                  DBMS_OUTPUT.put_line( buffer.Count||' row(s) fetched.' );
 10                  exit when c%NotFound;
 11          end loop;
 12          close c;
 13  end;
 14  /

Procedure created.

SQL>
SQL> exec FooProc
100 row(s) fetched.
43 row(s) fetched.

PL/SQL procedure successfully completed.
// STATIC SQL PROJECTION, BUT DYNAMIC SQL CURSOR
SQL> create or replace procedure FooProc( c in out sys_refcursor ) is
  2          E_CURSOR_ERROR  exception;
  3          pragma exception_init( E_CURSOR_ERROR, -00932 );
  4          type    TRecord is record(
  5                          name varchar2(30),
  6                          value varchar2(100)
  7                  );
  8          type    TBuffer is table of TRecord;
  9          buffer  TBuffer;
 10  begin
 11          loop
 12                  fetch c bulk collect into buffer limit 100;
 13                  DBMS_OUTPUT.put_line( buffer.Count||' row(s) fetched.' );
 14                  exit when c%NotFound;
 15          end loop;
 16          close c;
 17  exception when E_CURSOR_ERROR then
 18          close c;
 19          raise_application_error(
 20                  -20000,
 21                  'Cursor projection contains an invalid data structure.'
 22          );
 23  end;
 24  /

Procedure created.

SQL> var c refcursor
SQL> exec open :c for select object_id, object_name from user_objects;

PL/SQL procedure successfully completed.

SQL> exec FooProc( :c );
100 row(s) fetched.
43 row(s) fetched.

PL/SQL procedure successfully completed.

SQL> exec open :c for select object_id, object_name, created from user_objects;

PL/SQL procedure successfully completed.

SQL> exec FooProc( :c );
BEGIN FooProc( :c ); END;

*
ERROR at line 1:
ORA-20000: Cursor projection contains an invalid data structure.
ORA-06512: at "BILLY.FOOPROC", line 19
ORA-06512: at line 1
// DYNAMIC SQL AND DYNAMIC SQL PROJECTION
SQL> create or replace procedure FooProc( sqlSelect varchar2 ) is
  2          c               integer;
  3          rc              integer;
  4          colCnt          integer;
  5          fetchCnt        integer;
  6          projection      DBMS_SQL.DESC_TAB;
  7  begin
  8          --// ceate and parse the cursor
  9          c := DBMS_SQL.open_cursor;
 10          DBMS_SQL.parse(
 11                  c,
 12                  sqlSelect,
 13                  DBMS_SQL.native
 14          );
 15
 16          rc := DBMS_SQL.execute( c );
 17
 18          --// describe the sql projection
 19          DBMS_SQL.describe_columns( c, colCnt, projection );
 20
 21          --// the sql projection's fields/columns
 22          DBMS_OUTPUT.put_line( 'SQL projection:' );
 23          for i in 1..colCnt loop
 24                  DBMS_OUTPUT.put_line( '- '||projection(i).col_name );
 25          end loop;
 26
 27          --// fetch and process
 28          fetchCnt := 0;
 29          loop
 30                  rc := DBMS_SQL.fetch_rows( c );
 31                  exit when rc = 0;
 32                  --// use DBMS_SQL.column_value() to read fetched row's columns
 33                  fetchCnt := fetchCnt + 1;
 34          end loop;
 35          DBMS_OUTPUT.put_line( fetchCnt||' row(s) fetched.' );
 36
 37          DBMS_SQL.close_cursor( c );
 38  end;
 39  /

Procedure created.

SQL>
SQL> exec FooProc( 'select object_id, object_name from user_objects' );
SQL projection:
- OBJECT_ID
- OBJECT_NAME
143 row(s) fetched.

PL/SQL procedure successfully completed.

Tags: Database

Similar Questions

  • How to declare a dynamic cursor % rowtype?

    Hi guys

    I need to declare a variable of a dynamic cursor rowtype. Is this possible?
    The porpouse this is to store this train in a pl/sql table.

    Example:

    DECLARE
    T_CURSOR IS REF CURSOR TYPE
    MY_C IS T_CURSOR;
    MY_RT IS MY_C % ROWTYPE;
    IS OF TYPE MY_TABLE TABLE OF INDEXES MY_RT BY BYNARI_INTEGER;

    BEGIN
    MY_C OPEN FOR ' SELECT * FROM MYTABLE ';
    SEARCH MY_C MY_TABLE (1);
    SEARCH MY_C MY_TABLE (2);
    SEARCH MY_C MY_TABLE (3);
    LOOK FOR MY_C IN...
    END;

    Obviously this Don t work, but do someone know how I can do something to get the same result?

    Thank you

    Alex Tutor wrote:

    I need to declare a variable of a dynamic cursor rowtype. Is this possible?

    Is not possible. You know upfront structure returned by ref cursor or, if you are in 11g, convert it into cursor DBMS_SQL, retrieves the structure and convert it back (or treat it in DBMS_SQL).

    SY.

  • Plot multiple charts XY (dynamic data type)

    Hello world

    I searched but could not find the solution. I'm tracing several XY graphs with dynamic data type.

    I have here an example five 2D-arrays of X/axis Y to draw.

    I need them in dynamic data in order to trace in Diadem using Diadem protocol.vi.

    I get all the values of the X/Y axis as values Y.

    Any help is really appreciated,

    Yan.


  • In Illustrator, how can I get the cursor type to effectively indicate WHERE the guy is going to start?

    I don't understand. What is the point of having a cursor type at all if the cursor position doesn't look like whatever the point type will begin in? I checked all the Options in the type menu and any leader is zero, so there is no lag anywhere, but when I click on a particular spot on the page, it's because that's where I hope to see the type. What a laugh! No placement type correct, will never be. It must be scooted in place. using the arrow. Is it possible to make the entry point makes it a resemblance to the point ' by clicking on '?

    I don't see a problem:

    Your paragraph palette has something inside in addition to zeros? My guess is that you have left a big indent in the first field.

  • ORA-19279: XPTY0004 - dynamic XQuery type mismatch: expected - singleton sequence got several sequence element

    Hello

    Can you please help me by questioning from the following XML code.

    under query works for the 1 iteration. but for several games I get following error.

    ORA-19279: XPTY0004 - dynamic XQuery type mismatch: expected - singleton sequence got several sequence element

    19279 00000 - "dynamic XQuery type mismatch: expected - singleton sequence got several sequence element.

    * Cause: The sequence of XQuery passed was more than one element.

    * Action: Fix the XQuery expression to return a single element of the sequence.

    Help, please

    Select X.*

    ABC evt

    , XMLTABLE (XMLNAMESPACES ('urn:swift:xsd:mtmsg.2011' AS NS2, DEFAULT 'urn:swift:xsd:fin.970.2011'),

    "$msg_xml" by PASSING EVT.col1 as 'msg_xml '.

    COLUMNS

    Path Varchar (40) F61ValueDate "/ F61/ValueDate [1]."

    Path of DebitCreditMark Varchar (40) "/ / Document/MT970/F61a/F61/DebitCreditMark [1]."

    Amount Varchar (40) path ' / / Document/MT970/F61a/F61/amount [1]. "

    Path of TransactionType Varchar (40) "/ / Document/MT970/F61a/F61/TransactionType [1]."

    Path of IdentificationCode Varchar (40) "/ / Document/MT970/F61a/F61/IdentificationCode [1]."

    Path of ReferenceForTheAccountOwner Varchar (40) "/ / Document/MT970/F61a/F61/ReferenceForTheAccountOwner [1]."

    Path of SupplementaryDetails Varchar (40) "/ / Document/MT970/F61a/F61/SupplementaryDetails [1].

    ) X

    where EVT.col2 = 2

    < FinMessage xmlns = "urn:swift:xsd:mtmsg.2011" xmlns:FinMessage ="urn:swift:xsd:mtmsg.2011" > "
    < Block1 >
    < ApplicationIdentifier > F < / ApplicationIdentifier >
    < ServiceIdentifier > 01 < / ServiceIdentifier >
    < LogicalTerminalAddress > IRVTDEFXAXXX < / LogicalTerminalAddress >
    < open > 5252 < / open >
    < SequenceNumber > 699163 < / SequenceNumber >
    < / Block1 >
    < Block2 >
    < OutputIdentifier > O < / OutputIdentifier >
    < > 970 MessageType < / MessageType >
    < > 1633 InputTime < / InputTime >
    < MessageInputReference >
    < date > 131101 < / Date >
    < LTIdentifier > EBASBEBBQ < / LTIdentifier >
    < BranchCode > XXX < / BranchCode >
    < open > 1113 < / open >
    < n > 070016 < / ISN >
    < / MessageInputReference >
    < date > 131101 < / Date >
    < time > 1634 < / Time >
    < MessagePriority > N < / MessagePriority >
    < / Block2 >
    < Block3 >
    ENS0000857017566 < F108 > < / F108 >
    < / Block3 >
    < canton4 >
    < xmlns = "urn:swift:xsd:fin.970.2011 document" xmlns:Document ="urn:swift:xsd:fin.970.2011" > "
    < MT970 >
    < F20a >
    ENS17566/END of < F20 > < / F20 >
    < / F20a >
    < F25a >
    < F25 > IRVTDEFX/EUR/131101/N < / F25 >
    < / F25a >
    < F28a >
    < F28C >
    < StatementNumber > 215 < / StatementNumber >
    < SequenceNumber > 16 < / SequenceNumber >
    < / F28C >
    < / F28a >
    < F60a >
    < F60M >
    < DCMark > D < / DCMark >
    < date > 131101 < / Date >
    < currency > EUR < / currency >
    < amount > 2686836,28 < / amount >
    < / F60M >
    < / F60a >
    < F61a >
    < F61 >
    < valueDate > 131101 < / ValueDate >
    < DebitCreditMark > D < / DebitCreditMark >
    < amount > 40248, < / amount >
    < TransactionType > S < / TransactionType >
    < IdentificationCode > 103 < / IdentificationCode >
    < ReferenceForTheAccountOwner > FX5445414 < / ReferenceForTheAccountOwner >
    < SupplementaryDetails > KREDBEBBXXXIRVTDEFXXXXN011031 < / SupplementaryDetails >
    < / F61 >
    < / F61a >
    < F61a >
    < F61 >
    < valueDate > 131101 < / ValueDate >
    < DebitCreditMark > D < / DebitCreditMark >
    < amount > 41605, < / amount >
    < TransactionType > S < / TransactionType >
    < IdentificationCode > 103 < / IdentificationCode >
    < ReferenceForTheAccountOwner > FX5443846 < / ReferenceForTheAccountOwner >
    < SupplementaryDetails > DEUTDEFFXXXIRVTDEFXXXXN011031 < / SupplementaryDetails >
    < / F61 >
    < / F61a >
    < F61a >
    < F61 >
    < valueDate > 131101 < / ValueDate >
    < DebitCreditMark > D < / DebitCreditMark >
    < amount > 43730, < / amount >
    < TransactionType > S < / TransactionType >
    < IdentificationCode > 103 < / IdentificationCode >
    < ReferenceForTheAccountOwner > C13110130526301 < / ReferenceForTheAccountOwner >
    < SupplementaryDetails > BARCGB22XXXIRVTDEFXXXXN011033 < / SupplementaryDetails >
    < / F61 >
    < / F61a >
    < F61 >
    < valueDate > 131101 < / ValueDate >
    < DebitCreditMark > D < / DebitCreditMark >
    < amount > 58000, < / amount >
    < TransactionType > S < / TransactionType >
    < IdentificationCode > 202 < / IdentificationCode >
    < ReferenceForTheAccountOwner > FXT1311010000500 < / ReferenceForTheAccountOwner >
    < ReferenceOfTheAccountServicingInstitution > FXT1311010000500 < / ReferenceOfTheAccountServicingInstitution >
    < SupplementaryDetails > BKAUATWWXXXIRVTDEFXXXXN011116 < / SupplementaryDetails >
    < / F61 >
    < / F61a >
    < F61a >
    < F61 >
    < valueDate > 131101 < / ValueDate >
    < DebitCreditMark > D < / DebitCreditMark >
    < amount > 59826,21 < / amount >
    < TransactionType > S < / TransactionType >
    < IdentificationCode > 103 < / IdentificationCode >
    < ReferenceForTheAccountOwner > FX5446070 < / ReferenceForTheAccountOwner >
    < SupplementaryDetails > CHASGB2LXXXIRVTDEFXXXXN011031 < / SupplementaryDetails >
    < / F61 >
    < / F61a >
    < F61a >
    < F61 >
    < valueDate > 131101 < / ValueDate >
    < DebitCreditMark > D < / DebitCreditMark >
    < amount > 60309,4 < / amount >
    < TransactionType > S < / TransactionType >
    < IdentificationCode > 103 < / IdentificationCode >
    < ReferenceForTheAccountOwner > 01987HS016415 < / ReferenceForTheAccountOwner >
    < SupplementaryDetails > EFGBGRAAXXXIRVTDEFXXXXN011458 < / SupplementaryDetails >
    < / F61 >
    < / F61a >
    < F62a >
    < F62M >
    < DCMark > D < / DCMark >
    < date > 131101 < / Date >
    < currency > EUR < / currency >
    < amount > 3736765,9 < / amount >
    < / F62M >
    < / F62a >
    < / MT970 >
    < / document >
    < / canton4 >
    < / FinMessage >

    Thank you

    Siva Prakash

    under query works for the 1 iteration. but for several games I get following error.

    When you want to present the groups repeating in relational format, you must extract the sequence of elements of the main XQuery expression.

    Each element is then spent the COLUMNS clause to be more shredded into columns.

    This should work as expected:

    Select x.*

    ABC t

    xmltable)

    XmlNamespaces)

    default 'urn:swift:xsd:fin.970.2011 '.

    , 'urn:swift:xsd:mtmsg.2011' as 'ns0 '.

    )

    , ' / ns0:FinMessage / ns0:Block4 / Document/MT970/F61a/F61 '

    in passing t.col1

    columns F61ValueDate Varchar (40) Path 'ValueDate '.

    , Path of the DebitCreditMark Varchar (40) "DebitCreditMark".

    , Varchar (40) path 'Amount' rise

    , Path TransactionType Varchar (40) "TransactionType".

    , Path of the IdentificationCode Varchar (40) "IdentificationCode".

    , Path of the ReferenceForTheAccountOwner Varchar (40) "ReferenceForTheAccountOwner".

    , Path of the SupplementaryDetails Varchar (40) "SupplementaryDetails".

    ) x ;

  • Dynamic XQuery Type mismatch (ORA-19279)

    Hello

    I'm "ORA-19279: XPTY0004 - dynamic XQuery type mismatch: expected - singleton sequence got several sequence element" error with the XML block below. Query works well when there is no repeating element XML block (address, income and phone). In addition, the query looks good from a performance perspective?

    with the trial as (select xmltype

    ("" < SampleRequest = xmlns:ns0 "http://abc.org/SampleRequest/one" xmlns ="http://abc.org/SampleRequest/one" > ")

    < ns0:Address >

    < ns0:AddressType >

    < CurrAdrInd xmlns = "" > Y < / CurrAdrInd >

    < OutOfAreaInd xmlns = "" > N < / OutOfAreaInd >

    < YearDur xmlns = "" > 15 < / YearDur >

    < MthDur xmlns = "" > 0 < / MthDur >

    < / ns0:AddressType >

    < AdrLine1 xmlns = "" > line 1 < / AdrLine1 >

    < AdrLine2 xmlns = "" > line 2 < / AdrLine2 >

    < AdrLine3 xmlns = "" > line 3 < / AdrLine3 >

    < Name xmlns = "" > city < / name >

    < PostCd xmlns = "" > 123456 < / PostCd >

    < / ns0:Address >

    < ns0:Address >

    < ns0:AddressType >

    < CurrAdrInd xmlns = "" > N < / CurrAdrInd >

    < OutOfAreaInd xmlns = "" > Y < / OutOfAreaInd >

    < YearDur xmlns = "" > 5 < / YearDur >

    < MthDur xmlns = "" > 0 < / MthDur >

    < / ns0:AddressType >

    < AdrLine1 xmlns = "" > line 1 < / AdrLine1 >

    < AdrLine2 xmlns = "" > line 2 < / AdrLine2 >

    < AdrLine3 xmlns = "" > line 3 < / AdrLine3 >

    < Name xmlns = "" > city < / name >

    < PostCd xmlns = "" > 987654 < / PostCd >

    < / ns0:Address >

    < ns0:Customer >

    < TitleCd xmlns = "" > Mr < / TitleCd >

    < FrstName xmlns = "" > customer 1 < / FrstName >

    < midName xmlns = "" / >

    < name xmlns = "" > LAST < / LastName >

    < BrthDt xmlns = "" > 1979-06-21 < / BrthDt >

    < / ns0:Customer >

    < ns0:Income >

    < IncmTypeCd xmlns = "" > gross < / IncmTypeCd >

    < IncmAmt xmlns = "" > 2700 < / IncmAmt >

    < / ns0:Income >

    < ns0:Income >

    < IncmTypeCd xmlns = "" > other < / IncmTypeCd >

    < IncmAmt xmlns = "" > 1500 < / IncmAmt >

    < / ns0:Income >

    < ns0:Telephone >

    < PhnNumTypeCd xmlns = "" > home < / PhnNumTypeCd >

    < PhnAreaCd xmlns = "" > 123 < / PhnAreaCd >

    < PhnNum xmlns = "" > 123467 < / PhnNum >

    < / ns0:Telephone >

    < ns0:Telephone >

    < PhnNumTypeCd xmlns = "" > work < / PhnNumTypeCd >

    < PhnAreaCd xmlns = "" > 987 < / PhnAreaCd >

    < PhnNum xmlns = "" > 9876543 < / PhnNum >

    < / ns0:Telephone >

    < / SampleRequest >

    clob_xml') of double)

    Select x.* from the test,

    XMLTable (xmlnamespaces ('http://abc.org/SampleRequest/one' as "ns0"),)

    ' for $i in /ns0:SampleRequest

    Return $i' from clob_xml

    columns

    path of varchar2 (10) ttl_cd ' / / ns0:Customer / TitleCd',

    path of varchar2 (32) frst_nm ' / / ns0:Customer / FrstName ",

    path of varchar2 (1) mid_nm ' / / ns0:Customer / MidName',

    "path of varchar2 (32) last_nm ' / / ns0:Customer / LastName."

    date path brth_dt ' / / ns0:Customer / BrthDt',

    path of varchar2 (1) curr_adr_ind ' / / ns0:Address / ns0:AddressType / CurrAdrInd',

    path of varchar2 (1) out_of_area_ind ' / / ns0:Address / ns0:AddressType / OutOfAreaInd',

    path number (3) tm_at_adr_year_dur ' / / ns0:Address / ns0:AddressType / YearDur',

    path number (2) tm_at_adr_mth_dur ' / / ns0:Address / ns0:AddressType / MthDur',

    path of varchar2 (32) flat_num ' / / ns0:Address / AdrLine1',

    path of varchar2 (32) hse_num ' / / ns0:Address / AdrLine2',

    path of varchar2 (32) hse_nm ' / / ns0:Address / AdrLine3',

    path of varchar2 (32) town_nm ' / / ns0:Address / name ',

    path of varchar2 (8) post_cd ' / / ns0:Address / PostCd',.

    path of varchar2 (1) incm_type_cd ' / / ns0:Income / IncmTypeCd',

    path number (10) incm_amt ' / / ns0:Income / IncmAmt',

    path of varchar2 (2) phn_num_type_cd ' / / ns0:Telephone / PhnNumTypeCd',

    path of varchar2 (5) phn_num_area_cd ' / / ns0:Telephone / PhnAreaCd',

    path of varchar2 (12) phn_num ' / / ns0:Telephone / PhnNum'

    ) x ;

    Kind regards

    Chandra KenR

    Thanks, that's much clearer this way.

    For example, to retrieve information related to income:

    SQL > select x.*

    tmp_xml 2 t

    3, xmltable)

    4 xmlnamespaces ('http://abc.org/SampleRequest/one' as "ns0")

    5, ' / ns0:SampleRequest'

    6 passage t.object_value

    7 columns

    8 path of varchar2 (10) ttl_cd ' ns0:Customer / TitleCd'

    "9 road to varchar2 (32) frst_nm ' ns0:Customer / FrstName"

    10 road of varchar2 (1) mid_nm ' ns0:Customer / MidName'

    "11 road of varchar2 (32) last_nm ' ns0:Customer / LastName"

    12, date of brth_dt path ' ns0:Customer / BrthDt'

    13, path number (10) grs_incm_amt ' ns0:Income [IncmTypeCd = "Raw"] / IncmAmt'

    14 road number (10) oth_incm_amt ' ns0:Income [IncmTypeCd = 'Other'] / IncmAmt'

    (15) x

    16;

    TTL_CD FRST_NM MID_NM LAST_NM BRTH_DT GRS_INCM_AMT OTH_INCM_AMT

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

    Mr. customer 1 LAST 21/06/1979 2700-1500

    On your question about performance:

    Yes, there are some general guidelines to follow to get the best performance of the execution of XQuery.

    Those are the storage dependent and independent storage, with greater importance of the former.

    For example, in the test case above, I first stored the XML in a binary table of XMLType (TMP_XML): it is an optimization of storage-dependent.

    I also removed all the descendants axis (/ /) for path expressions: those who were not needed and should be avoided if the exact location of the target node is known, this is typically an independent optimization of storage.

    You will find everything you need to know in details here:

    http://www.Oracle.com/technetwork/database-features/xmldb/overview/xmldb-bpwp-12cr1-1964809.PDF

  • ORA-19279: XPTY0004 - dynamic XQuery type mismatch

    Hi all
    When I run select it below the statement I had the "ORA-19279: XPTY0004 - dynamic XQuery type mismatch: expected - singleton sequence got several sequence element" oracle error.
    select valtag 
      from XMLTABLE( '/root'
                     passing XMLTYPE('<root>
                                                  <subroot><valtag>6666446612</valtag></subroot>
                                                  <subroot><valtag>6666446613</valtag></subroot>
                                      </root>'
                                     ) 
                    Columns
                          valtag varchar(20) path 'subroot/valtag'
                   ) s
    required result:
    VALTAG
    ---------------
    6666446612
    6666446613
    Please let me know where I made the mistake?

    Thank you
    RAM.

    Published by: Rama Krishna.CH on November 26, 2012 15:48

    Please let me know where I made the mistake?

    The main manifestation of XQuery (here = ' / root ') defines what will be the relational lines based on the result set.
    (Strictly speaking, this expression must return a sequence of elements)

    Here, so you want the element subroot be your 'line':

    SQL> select s.valtag
      2  from XMLTABLE( '/root/subroot'
      3         passing XMLTYPE('
      4             6666446612
      5             6666446613
      6           ')
      7         Columns
      8            valtag varchar(20) path 'valtag'
      9       ) s
     10  ;
    
    VALTAG
    --------------------
    6666446612
    6666446613
     
    
  • Fetch cursor types

    Hello
    I want to write a procedure that has parameters which are records in a table.
    But I don't know how to search cursor type and then pass the result to the settings.
      
    create or replace procedure out_student_names3
      (id out students.std_id%type,name out students.std_name%type)
      is
     type TYPE_STD is table of students.STD_ID%type ;
     type type_std_name is table of students.STD_NAME%type;
     type_1 type_std;
     type_2 type_name;
     cursor c is  select std_id ,std_name from students ;
      begin
    OPEN C;
      LOOP
    --fetch c into type_1,type_2;
     
    exit when c%notfound; 
     
     end loop;
    end;
    /

    A cursor is a memory structure where stored instructions to execute a SQL statement. There are 3 operation involved in the treatment of a slider they are OPEN, FETCH, and CLOSE. So to print a data in the cursor, you need to open the cursor, fetch the cursor, then close.

    Client tools like SQLPlus offers an API to display the records of cursor. PRINT is a custom api provided by SQLPlus to print a cursor. You can use it. Here is an example.

    SQL> create or replace procedure get_emp_detail(out_cursor out sys_refcursor)
      2  is
      3  begin
      4     open out_cursor for select empno, ename from emp;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> var rc refcursor
    
    SQL> exec get_emp_detail (:rc)
    
    PL/SQL procedure successfully completed.
    
    SQL> print rc
    
         EMPNO ENAME
    ---------- ----------------------------------------------------------------------------------------------------
             1 Karthick
             2 Karthick_1
             3 Ram
             4 Ram_1
    
    SQL> 
    
  • Using using Cluase for dynamic cursors using Bind Variables.

    Hello

    I have a quick question. I build dynamic cursor depends on the setting. The one here is my common charly.

    I use the 5 parameter in place several in my query. So, I use almost 40 values if I used with would adopt it. Is there another way to manage rather than spend 40 times.
    SELECT
            decode(GROUPING(nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))), '1', 'Total',
              nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))) NAME,
              SUM(kpi),
              .....
    from  tb_test1,...
    where  WHERE upper(nvl(LVL1, ''UNKNOWN'')) = upper(nvl(p_level1, LVL1))
            AND upper(nvl(LVL2, ''UNKNOWN'')) = upper(nvl(p_level2, LVL2))
            AND upper(nvl(LVL3, ''UNKNOWN'')) = upper(nvl(p_level3, LVL3))
            AND upper(nvl(LVL4, ''UNKNOWN'')) = upper(nvl(p_level4, LVL4))
            AND upper(nvl(LVL5, ''UNKNOWN'')) = upper(nvl(p_level5, LVL5))
            AND upper(nvl(LVL6, ''UNKNOWN'')) = upper(nvl(p_level6, LVL6))
          GROUP BY ROLLUP(nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN'')))))))
          ORDER BY nvl2(p_level5, nvl(hier.LVL6,''UNKNOWN''), nvl2(p_level4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(p_level3, nvl(hier.LVL4,''UNKNOWN''), nvl2(p_level2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(p_level1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))));
    Appreciated your help.

    Kind regards
    Vincent.

    Just capture once inside SQL, then use local versions of their

    for example

    with t as (select p_level1 as pl1
                     ,p_level2 as pl2
                     ,p_level3 as pl3
                     ,p_level4 as pl4
                     ,p_level5 as pl5
               from dual)
    SELECT
            decode(GROUPING(nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))), '1', 'Total',
              nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))))) NAME,
              SUM(kpi),
              .....
    from  t, tb_test1,...
    where  WHERE upper(nvl(LVL1, ''UNKNOWN'')) = upper(nvl(pl1, LVL1))
            AND upper(nvl(LVL2, ''UNKNOWN'')) = upper(nvl(pl2, LVL2))
            AND upper(nvl(LVL3, ''UNKNOWN'')) = upper(nvl(pl3, LVL3))
            AND upper(nvl(LVL4, ''UNKNOWN'')) = upper(nvl(pl4, LVL4))
            AND upper(nvl(LVL5, ''UNKNOWN'')) = upper(nvl(pl5, LVL5))
            AND upper(nvl(LVL6, ''UNKNOWN'')) = upper(nvl(p_level6, LVL6))
          GROUP BY ROLLUP(nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN'')))))))
          ORDER BY nvl2(pl5, nvl(hier.LVL6,''UNKNOWN''), nvl2(pl4, nvl(hier.LVL5,''UNKNOWN''),
              nvl2(pl3, nvl(hier.LVL4,''UNKNOWN''), nvl2(pl2, nvl(hier.LVL3,''UNKNOWN''),
              nvl2(pl1, nvl(hier.LVL2,''UNKNOWN''), nvl(hier.LVL1,''UNKNOWN''))))));
    
  • Followed, does not not for the cursor Type

    I just SC5. I remember when I wanted to address followed, I used to be able to just drag the icon in the character Panel. This doesn't seem to work now! I looked through prefs but can't seem to find anything to fix. Any thoughts are appreciated.

    Not in Illustrator, there no dynamic cursors as other applications such as After Effects

  • Dynamic cursors

    Hello

    I'm working on dynamic cursors.
    When I try to run the code below, I get the following error.
    BEGIN
      DYNAMIC_CURSOR.OPENCURSOR();
    END;
    
    exception raised ORA-00932: inconsistent datatypes: expected - got -
      
    Here is my code:
    CREATE OR REPLACE
    PACKAGE BODY dynamic_cursor AS
        PROCEDURE dyn_sel (
            tab_name   IN VARCHAR2, 
            field_name IN VARCHAR2, 
            val        IN VARCHAR2, 
            crs        IN OUT t_crs)
        IS 
            stmt VARCHAR2(200); 
        BEGIN 
            stmt := 'select * from '|| tab_name || ' where '|| field_name ||  ' = :1';
            OPEN crs FOR stmt USING val;
        END dyn_sel; 
    
        PROCEDURE openCursor IS 
            tc t_crs; 
            f1 VARCHAR2(50); 
            f2 VARCHAR2(50); 
        BEGIN 
            dyn_sel ('EMP','JOB','MANAGER', tc); 
            LOOP
                FETCH tc INTO f1, f2; 
                EXIT WHEN tc%notfound; 
                dbms_output.put_line (f2); 
            END LOOP; 
        EXCEPTION 
            WHEN OTHERS THEN
                dbms_output.put_line ('exception raised '||SQLERRM);
        END openCursor; 
    END dynamic_cursor; 
    -Thank you

    The selected columns must match the INTO clause, you'll need to extract exactly two columns, for example in

     ...
      stmt := 'select ename, job from ' || tab_name || ' where ' || field_name || ' = :1';
    ....
    
  • Dynamic cursor error:

    Hi experts

    Please help me with this error
    In this code the terms cursor not add to the query
    so when I execute the result it displays error
    can you help me on this
    SQL> CREATE OR REPLACE PROCEDURE test_dynamic_detailed_rpt (
      2     v_typ             IN       VARCHAR2,
      3     v_initiator   IN       VARCHAR2,
      4     p_rc                  OUT      sys_refcursor
      5  )
      6  IS
      7     v_sql   VARCHAR2(32767);
      8  BEGIN
      9     v_sql := 'SELECT  COUNT(*) FROM  txnlg tl WHERE ';
     10
     11      v_sql := v_sql||'tl.typ = ''1''';
     12
     13
     14           FOR j IN (SELECT tc.tgid, tc.tranid, tc.reqtype
     15                       FROM txnccde tc
     16                      WHERE tc.actstatus = 'Y'
     17                        AND tc.txndesc = v_typ)
     18           LOOP
     19              IF LENGTH (j.tgid) < 4
     20              THEN
     21                 v_sql := v_sql || ' OR ''UP''||J.tgid';
     22                 --'''|| v_typ|| ''')';
     23              ELSE
     24                 v_sql := v_sql || ' OR   J.tgid';
     25              END IF;
     26           END LOOP;
     27
     28     DBMS_OUTPUT.PUT_LINE(v_sql);
     29  END;
     30  /
    
    Procedure created.
    
    SQL>
    SQL> set serveroutput on;
    SQL>
    SQL> Var  p_rc refcursor;
    SQL>
    SQL> BEGIN
      2  test_dynamic_detailed_rpt('ALL','C',:p_rc);
      3  END;
      4  /
    SELECT  COUNT(*) FROM  txnlg tl WHERE tl.typ = '1'
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> print p_rc;
    ERROR:
    ORA-24338: statement handle not executed
    
    
    SP2-0625: Error printing variable "p_rc"
    SQL>

    If you think you need to use dynamic SQL statements to apply additional conditions (if you did not specify this) simply not so like this code you looks like it generates:

    select count(*)
    from tab1
    where col1 = (1st value from tab2)
    or col1 = (2nd value from tab2)
    .
    .
    .
    or col1 = (nth value from tab2)
    /
    

    while I would say that you are better off getting:

    select count(*)
    from tab1
    , tab2
    where (tab1.col1 = tab2.col1 and length tab2.col2 <4)
      or (tab1.col1 = 'xx'||tab2.col1 and length tab2.col2 >=4)
    /
    

    Because the second query is only long, not n (plus some) lines long. No matter if you write SQL static or dynamic: you must write a SQL query appropriate, concise and not a huge, sprawling. Then you will not have to worry about the limitation of the data type VARCHAR2 holding the full text of the query.

    If, after writing a nice concise sql query and it is always > 32 k long, so you might want to look at using the VARCHAR2S and DBMS_SQL data type. TO_REFCURSOR

    The example tables and data and the required results will make usefule much easier to give advice.

    Ben

  • Track of multiple graphs on a single diagram of waveform with dynamic data types

    I'm putting multiple charts on a single diagram of waveform and data contract error. I was wondering if it has something to do with the fact that the dynamic data is used (I have had no problem with other types of data in the past). Does anyone know how to fix this? I have attached the following .VI. There will be a lot of. Live on the bottom which does not load, but they are not related to this problem.

    Thank you!

    Brian

    I don't know what you're doing now, but a part of your origianl code is simply ridiculous. Your DAQ assistant takes a single point. You convert that into an array. If you had converted into a scalar value (which is) first place, your graphics update would have been fine.

    If you want to remove the DAQ Assistant, and then select generate DAQmx code. You'll be a little more closely, but it seems that it generates a NChan DAQmx Read 1Samp instead of a 1Chan 1Samp DAQmx read.

  • How we prevent suddenly back in the mark cursor type?

    When you type numbers or letters in the words, emails etc. type suddenly will return to the cursor mark.  Is there a solution?

    This happened after my Dell 1720 pc crashed and "all" Windows Vista has been reinstalled.

    Hey Stan,

    Glad to know that the problem is solved. Let us know if face you any problems with Windows in the future.

  • Dynamic XQuery type mismatch

    I have the following. How to avoid the dynamic type mismatch?

    < ResGuests >

    < ResGuest >

    profile of <>

    < ProfileInfo >

    < Type UniqueID = "21" ID = "3558" / >

    < profile >

    < TPA_Extensions >

    < TPA_Extension >

    < DRI_INFO MemberLevel = GuestType "s/o" = "GST" / > "

    < / TPA_Extension >

    < / TPA_Extensions >

    < customer >

    < PersonName >

    < name > Ws < / name >

    D. JAMES < GivenName > < / GivenName >

    < / PersonName >

    < / customer >

    < / profile >

    < / ProfileInfo >

    < ProfileInfo >

    < Type UniqueID = "21" ID = "3568" / >

    < profile >

    < TPA_Extensions >

    < TPA_Extension >

    < DRI_INFO MemberLevel = GuestType "s/o" = "Assistant Director General" / > "

    < / TPA_Extension >

    < / TPA_Extensions >

    < customer >

    < PersonName >

    < name > M < / name >

    < GivenName > GUY < / GivenName >

    < / PersonName >

    < / customer >

    < / profile >

    < / ProfileInfo >

    < / profile >

    < / ResGuest >

    < / ResGuests >

    SELECT lengthofstay

    boarding

    resvtype

    devices

    membertype

    IN n_lengthofstay

    n_amount_to_charge

    v_resvtype

    n_num_devices

    v_member_type

    FROM XMLTABLE)

    xmlnamespaces (DEFAULT 'http://www.opentravel.org/OTA/2003/05'), ' / OTA_ResRetrieveRS'

    PASSAGE mxml

    COLUMNS lengthofstay VARCHAR2 (2000)

    Path "ReservationsList/HotelReservation/Services/Service/TPA_Extensions/TPA_Extension/WiFiFees/@LengthOfStay".

    TOLL number

    Path "ReservationsList/HotelReservation/Services/Service/TPA_Extensions/TPA_Extension/WiFiFees/@AmountBeforeTax".

    , resvtype VARCHAR2 (2000)

    Path "ReservationsList/HotelReservation/RoomStays/RoomStay/RoomRates/RoomRate/@BookingCode".

    Number of devices

    Path "ReservationsList/HotelReservation/Services/Service/TPA_Extensions/TPA_Extension/WiFiFees/@NumberConnections".

    , membertype VARCHAR2 (2000)

    Path "ReservationsList/HotelReservation/ResGuests/ResGuest/Profiles/ProfileInfo/Profile/TPA_Extensions/TPA_Extension/DRI_INFO/@MemberLevel");

    I would be able to extract the data in a given table?

    This is not really to the point.

    First, you must decide how to deal with the various nodes of type of repetition, we could meet in the XML file.

    If you want extract as a single flat tabular structure or rather as separate entity sets?

    If flattening is OK, then something like this will not work on your current sample XML:

    DECLARE
        x_xml          CLOB
            := '
    
       
       
          
       
       
          
             
             
                
                   
                      
                         
                      
                   
                
             
             
                
                   
                      
                         
                         
                            
                               
                                  
                               
                            
                            
                               
                                  Winters
                                  JAMES D.
                               
                            
                         
                      
                      
                         
                         
                            
                               
                                  
                               
                            
                            
                               
                                  M
                                  GUY
                               
                            
                         
                      
                   
                
             
             
                
                   
                   
                      
                         
                            
                         
                      
                   
                   
                
             
          
       
    ';
        mxml           XMLTYPE;
    
        TYPE data_rec IS RECORD
        (
            lengthofstay   NUMBER
           ,chargeable     NUMBER
           ,resvtype       VARCHAR2 (2000)
           ,devices        NUMBER
           ,membertype     VARCHAR2 (2000)
           ,guesttype      VARCHAR2 (2000)
        );
    
        TYPE results IS TABLE OF data_rec;
    
        a_results      results;
    
    BEGIN
        mxml        := xmltype (x_xml);
    
        SELECT x1.lengthofstay
             , x1.chargeable
             , x1.resvtype
             , x1.devices
             , x2.membertype
             , x2.guesttype
        BULK COLLECT INTO a_results
        FROM XMLTABLE (
               XMLNamespaces (DEFAULT 'http://www.opentravel.org/OTA/2003/05')
             , '/OTA_ResRetrieveRS/ReservationsList/HotelReservation'
               PASSING mxml
               COLUMNS lengthofstay VARCHAR2(2000)  PATH 'Services/Service/TPA_Extensions/TPA_Extension/WiFiFees/@LengthOfStay'
                     , chargeable   NUMBER          PATH 'Services/Service/TPA_Extensions/TPA_Extension/WiFiFees/@AmountBeforeTax'
                     , resvtype     VARCHAR2(2000)  PATH 'RoomStays/RoomStay/RoomRates/RoomRate/@BookingCode'
                     , devices      NUMBER          PATH 'Services/Service/TPA_Extensions/TPA_Extension/WiFiFees/@NumberConnections'
                     , profiles     XMLType         PATH 'ResGuests/ResGuest/Profiles/ProfileInfo'
             ) x1
           , XMLTABLE (
               XMLNamespaces (DEFAULT 'http://www.opentravel.org/OTA/2003/05')
             , '/ProfileInfo/Profile/TPA_Extensions/TPA_Extension/DRI_INFO'
               PASSING x1.profiles
               COLUMNS memberType  VARCHAR2(2000)   PATH '@MemberLevel'
                     , guestType   VARCHAR2(2000)   PATH '@GuestType'
             ) x2 ;
    
        for i in 1 .. a_results.count loop
          DBMS_OUTPUT.put_line (   a_results(i).lengthofstay
                                || ' -->'
                                || a_results(i).chargeable
                                || ' -->'
                                || a_results(i).resvtype
                                || ' -->'
                                || a_results(i).devices
                                || ' -->'
                                || a_results(i).membertype
                                || ' -->'
                                || a_results(i).guesttype
                                );
        end loop;
    END;
    /
    

    output:

    5--> 0--> REN--> 4--> N / A--> GST

    5--> 0--> REN--> 4--> N / A--> ADG

    but as said, don't forget that it will fail as soon as there is more than one Service, ideal or RoomRate node.

Maybe you are looking for

  • Archive utility: temporary folder?

    Hello Where is the "temporary folder" when 'extraction' of an archive using the utility to archive Mac? The archiving utility not always use same folder of temporary mining, say, for example during extraction of a file on a network share? I had a pro

  • Satellite R 630 - BatteryBar Pro shows my wear and tear on the battery under the name more 14%

    Hello My R630 is only a few months old, but in BatteryBar Pro, it's showing my wear of the battery under the names of over 14%. What is classified as wear unacceptable battery to get a Toshiba replacement battery and how is the best way to exercise o

  • hp14-d010au windows 7 64-bit driver

    Help me find driver for hp14-d010au for windows 7 64 bit... TQ

  • Podcast questions

    I recently spent a clip + sport clip and have found the feature Podcast works correctly. Specifically with the file command and it's return to the correct file when I take an artist/album more later. For example: I have 6 files: 41.MP3, 42.mp3 43.mp3

  • CD DVD does not read by the reader of cd/dvd from my PC

    guys, my PC does not read DVD discs for a while now... tried troubleshooting several times but I keep getting a message that "the DVD/CD drive works properly".. .He video plays audio CDs and CD fine, it's just the DVD; It stops after spinning for lik