Where oracle records type LOB data?

I am new to oracle, so I don't know how the LOB data, are recorded as in postgresql all LOB is saved in a table (pg_largeobject) and all tables with LOB columns have an id for this "main table".

If oracle except LOB in a table and all the tables there just an id to the 'main' table or each table has its own copy of the lob.

Welcome to Oracle!

Oracle database stores the LOBs in the form of segments in a tablespace.

Suppose you have a table with a column lobcolumn lobtable, segment of the table is stored in the tablespace of the SCT and also his JOB. You can set a different tablespace to store the LOB segment if you wish.

Please take a look at the documentation.

http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28393/adlob_tables.htm#i1006378

Kind regards

Franky

Tags: Database

Similar Questions

  • regarding type LOB data...

    I'm not so familiar with LOB and was hoping someone could shed some light for me.

    I am under Oracle 11.2.0.2 EE and made an interesting discovery of this new database I load.

    First of all, I discovered that I have a table which is about 7.4 G, but there two columns LOB that when I have a dba_lobs query, I found that they contains 365 G of lobs and the table itself has 22 G of LOB - don't know what the difference is.
    SQL> 1  select segment_name, round(sum(bytes)/1024/1024/1024,1) as "SIZE" , segment_type
      2  from dba_segments where owner = 'ARADMIN'
      3  group by segment_name, segment_type
      4  having round(sum(bytes)/1024/1024/1024,1) > 1
      5* order by 2
     /
    
    SEGMENT_NAME                                SIZE SEGMENT_TYPE
    -------------------------------- --------------- ------------------
    . . .
    SYS_LOB0000077517C00027$$                    4.2 LOBSEGMENT
    SYS_LOB0000210343C00029$$                    4.4 LOBSEGMENT
    SYS_LOB0000077480C00002$$                    4.6 LOBSEGMENT
    T465                                           5 TABLE
    T2052                                        8.3 TABLE
    T2115                                       12.4 TABLE
    T2444                                       13.4 TABLE
    T2179                                       14.8 TABLE
    T2192                                       21.8 TABLE
    SYS_LOB0000077549C00015$$                    182 LOBSEGMENT   <=== (related to table T2192)
    SYS_LOB0000077549C00016$$                  184.4 LOBSEGMENT  <=== (related to table T2192)
    
    30 rows selected.
    Now, let's look at the table these LOBS belong...
    SQL> select table_name, column_name, segment_name
      2  from dba_lobs
      3  where segment_name in (
      4  select segment_name from dba_segments where owner = 'ARADMIN'
      5   having round(sum(bytes)/1024/1024/1024,1) > 1
      6  group by segment_name
      7  )
      8  /
    
    
    TABLE_NAME                       COLUMN_NAME                      SEGMENT_NAME
    -------------------------------- -------------------------------- --------------------------------
    B1947C536880923                  C536880923                       SYS_LOB0000077310C00002$$
    T2051                            C536870998                       SYS_LOB0000077426C00041$$
    T2052                            C536870987                       SYS_LOB0000077440C00063$$
    T2115                            C536870913                       SYS_LOB0000077463C00009$$
    B2125C536880912                  C536880912                       SYS_LOB0000077480C00002$$
    B2125C536880913                  C536880913                       SYS_LOB0000077483C00002$$
    T2179                            C536870936                       SYS_LOB0000077517C00027$$
    T2192                            C456                             SYS_LOB0000077549C00015$$   <====
    T2192                            C459                             SYS_LOB0000077549C00016$$   <====
    T2444                            C536870936                       SYS_LOB0000210343C00029$$
    T1990                            C536870937                       SYS_LOB0000250271C00026$$
    
    11 rows selected.
    So, in the light of the foregoing, I noticed in the first query that contains the table T2192 21.8 G of LOBS and that C456 and C459 of same table columns (181,7 + 183.9) total = 365.6 G.

    First question is how can the table be only 21.8 G, and business segments the columns of the table of 365,6 G of the Lobs?
    It seems that some type LOB data should be external, while others are part of the table.

    Then, I wonder if a line is removed from the table, would be the LOB associated with this line that is referenced by columns C456 and C459 also deleted.
    Discuss with our senior developer, he said, the table is purged of lines longer than 6 months, but my question is if the LOB is actually purged with the lines.

    Any ideas?

    Published by: 974632 on December 27, 2012 08:05

    The space occupied by business segments is not reported as part of space for table segment, welll, don't not all still. What is reported as part of the size of the table is the size of the lob index (a pointer to the segment of the 'real' job, 16 bytes if I remember correctly) and the LOB that are stored online in the table (those under 4 k). To get the "full" size of the table, you must add the space occupied by the ant lob columns.

    If you delete a line, then the space occupied in the business segments will be defined as free space inside the existing segment. He will thereafter (there are a number of round redo and undo that are managed differently from the lobs), be used by the data for the other lines, but it might take some time.

    There are a number of documents on My Oracle support in this regard, many are related to:

    Troubleshooting Guide (TSG) - large objects (LOBs) [ID 846562.1]

    John

  • TYPE LOB DATA

    Hello experts

    There are some queries to view and recover the unused space of LOV in non-spatail tablein this link http://www.idevelopment.info/data/Oracle/DBA_tips/LOBs/LOBS_85.shtml

    We have geometry with sdo_geometry tables and their associates LOB sdo_ordinates and Ansdo_elem_info.

    Can I apply these requests mentioned in the link to the spatial tables to recover unused space? If yes how?

    Thank you

    Can you please try something similar to the following?

    ALTER table table_name modify varray geom_column. SDO_ORDINATES (retraction space);

    ALTER table table_name modify varray geom_column. Ansdo_elem_info (space of retraction);

    or

    ALTER table table_name modify varray geom_column. SDO_ORDINATES (narrowing space) modify varray geom_column. Ansdo_elem_info (space of retraction);

  • ORA-02327: cannot create indexes on the LOB data type expression

    DB 10.2.0.4
    DB 5.2

    I am not able to move lobindex and lobsegment. While try occurs below error

    SQL > ALTER INDEX dev. "" SYS_IL0000718396C00002$ $"REBUILD THE TABLESPACE DATA_TEMP;
    ALTER INDEX dev. "" SYS_IL0000718396C00002$ $"REBUILD TABLESPACE DATA_TEMP
    *
    ERROR on line 1:
    ORA-02327: cannot create indexes on the LOB data type expression

    Thank you

    Published by: user13382934 on October 16, 2012 14:05

    correct syntax is
    ALTER TABLE.

    MOVE the LOB ()
    STORE AS (tablespace );

    Where is a name of the / columns LOB, not the name of the segment. Moving type LOB data will move its indexes as well.

  • How to use the LOB data type?

    I can't create a table with the LOB data type.

    Do I need an additional parameter in sys.odbc.ini?

    My dsn information is

    [tpch]

    Driver=/home/TimesTen/TimesTen/tt1121/lib/libtten.so

    Data store = / home/timesten/TimesTen/tt1121/tpch/tpch

    LogDir = / home/timesten/TimesTen/tt1121/tpch/logs

    PermSize = 4096

    TempSize = 2048

    PLSQL = 1

    LOB = 1

    DatabaseCharacterSet = US7ASCII

    -bash-4, $ 1 ttdaemonadmin-version

    TimesTen Release 11.2.1.2.0

    There is no LOB = 1 attribute; Please, delete it from your definition ODBC to avoid potential errors.

    LOB support has been added in the major version 11.2.2 TimesTen. So you use 11.2.1 LOB is not available. If you want to use LOB data, then you must upgrade to 11.2.2.

    Chris

  • Where to define new custom data types?

    Hello

    In the past (TS 3.5) I created our own range of custom type file that has been used

    to store the new data types and then referred the case to other colleagues. The file would be

    stored in the ...\Program Files\...\User area.

    My question arose because we now use the TS 4.1/4.2, which is no longer a separate

    Directories of NOR and user in \Program Files.

    Because now I want to change an existing custom data type, I find that our range of custom type has

    fallen by the way side, forgotten.

    Even though I can see the custom data definitions within the sequence of type files that use

    custom data types, which means that I can edit them locally, I intend to return to

    a range of custom type, i.e. comprehensive definition.

    What is the relationship between the definitions in a range of custom type and custom data

    definitions of type of a file of sequence?

    When a palette to update file a file of sequence?, who takes over in the event of conflicts?

    is a really necessary sequence files palette file if they are separated by using the same custom data type

    can update the other? What is good practice when defining custom types of data?

    Thank you

    Gary.

    Hey guys,.

    This is a very interesting thread, and I've got everything right, in heart, with advice given so far. I just wanted to offer some additional tips on the conflicts of kind - with more response, the initial question concerning the definition of what is priority in case of conflict.

    It is important to note that TestStand uses type names and version numbers to identify the different types. It is also important to note that when you use a definition of type of customers within a sequence, the sequence (.seq) file containing the sequence will keep a copy of the type definition. This greatly facilitates distributed sequence files. However, it also opens the door to potential conflicts type.

    TestStand allows only one type of unique name to be loaded into memory at any given time, so that it uses the number of versions of the type to try to resolve these conflicts automatically. For example, TestStand can be configured to load any type is the largest version number (note that this can be changed via the tab Preferences dialog box Options of Station).

    All this information and more are found in the following tutorials...

    Conflicts and TestStand Type Versioning

    How to make a Type of custom step?

    Thanks for your time. I hope this has been helpful!

  • OracleDataAdapter error: unable to cast object of type 'Oracle.DataAccess.Types.OracleDecimal' type 'System.IConvertible '.

    Uses: Oracle9i Standard Edition, ODAC 11.2.0.4, Oracle Instant Client 11.2.0.4

    I am to convert the Microsoft Oracle for Oracle ODP.NET provider of my projects

    * Error *.

    Cannot be cast to type 'Oracle.DataAccess.Types.OracleDecimal' object type 'System.IConvertible '. Could not store < 145982 > in the RECEIPTID column. Type is Int64.

    This error is poped up when my stored Proc has a return parameter. The return is a numeric data type in Oracle. I had no problem when using Oracle Provider from Microsoft.

    Initially, I had my command setting insert the value

    System.Data.OracleClient.OracleType.Number

    for the column RECEIPTID; After ODP.NET, I converted to

    Oracle.DataAccess.Client.OraclDbType.Double

    Then the error throwed upward. Implement

    Oracle.DataAccess.Client.OracleDbType.Int64

    as suggested by the error, but nothing seems to prevent the error a way.

    I am running using the OracleDataAdapter.

    The OracleCommand object initialization *.

    public class ReceiptAccountBusinessTable : EquityBroker32.APP_DATA.config.GenericBusinessTable
            {
                OracleCommand[] nCommandCollection;
    
                public ReceiptAccountBusinessTable()
                {
                    this.Tablename = "JKSBSCHEMA.RECEIPTACCOUNT";
                    this.KeyDBField = "RECEIPTID";
                    this.DefaultSql = string.Format("SELECT * FROM {0} WHERE {1}= (SELECT MAX({1}) FROM {0} )", this.Tablename, this.KeyDBField);
    
                    //select command
                    this.nCommandCollection = new Oracle.DataAccess.Client.OracleCommand[4];
    
                    this.nCommandCollection[0] = new OracleCommand();
                    this.nCommandCollection[0].Connection = this.DataConnection;
                    this.nCommandCollection[0].CommandText = this.DefaultSql;
                    this.nCommandCollection[0].CommandType = System.Data.CommandType.Text;
    
                    //update command
                    this.nCommandCollection[1] = new OracleCommand();
                    this.nCommandCollection[1].Connection = this.DataConnection;
                    this.nCommandCollection[1].CommandText = "JKSBSCHEMA.RECEIPTACCOUNT_ADDCHG_PROC";
                    this.nCommandCollection[1].BindByName = true;
                    this.nCommandCollection[1].CommandType = System.Data.CommandType.StoredProcedure;
                    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PRECEIPTID", Oracle.DataAccess.Client.OracleDbType.Int64, 10, System.Data.ParameterDirection.InputOutput, false, 10, 0, "RECEIPTID", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PACCOUNTID_NEW", Oracle.DataAccess.Client.OracleDbType.Char, 13, System.Data.ParameterDirection.Input, false, 0, 0, "CLIENTACCOUNTID", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PACCOUNTID_OLD", Oracle.DataAccess.Client.OracleDbType.Char, 13, System.Data.ParameterDirection.Input, false, 0, 0, "CLIENTACCOUNTID", System.Data.DataRowVersion.Original, null));
                    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PXSACTVALUE", Oracle.DataAccess.Client.OracleDbType.Double, 22, System.Data.ParameterDirection.Input, false, 0, 0, "XSACTVALUE", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PXSACTDESC", Oracle.DataAccess.Client.OracleDbType.Varchar2, 255, System.Data.ParameterDirection.Input, false, 0, 0, "XSACTDESC", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PPAGEBREAK", Oracle.DataAccess.Client.OracleDbType.Int32, 22, System.Data.ParameterDirection.Input, false, 0, 0, "PAGEBREAK", System.Data.DataRowVersion.Current, null));
    
                    //insert command
                    this.nCommandCollection[2] = new OracleCommand();
                    this.nCommandCollection[2].Connection = this.DataConnection;
                    this.nCommandCollection[2].CommandText = "JKSBSCHEMA.RECEIPTACCOUNT_ADDCHG_PROC";
                    this.nCommandCollection[2].CommandType = System.Data.CommandType.StoredProcedure;
                    this.nCommandCollection[2].BindByName = true;
                    this.nCommandCollection[2].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PRECEIPTID", Oracle.DataAccess.Client.OracleDbType.Int64, 10, System.Data.ParameterDirection.InputOutput, false, 10, 0, "RECEIPTID", System.Data.DataRowVersion.Proposed, null));
                    this.nCommandCollection[2].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PACCOUNTID_NEW", Oracle.DataAccess.Client.OracleDbType.Char, 13, System.Data.ParameterDirection.Input, false, 0, 0, "CLIENTACCOUNTID", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[2].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PACCOUNTID_OLD", Oracle.DataAccess.Client.OracleDbType.Char, 13, System.Data.ParameterDirection.Input, false, 0, 0, "CLIENTACCOUNTID", System.Data.DataRowVersion.Original, null));
                    this.nCommandCollection[2].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PXSACTVALUE", Oracle.DataAccess.Client.OracleDbType.Double, 22, System.Data.ParameterDirection.Input, false, 0, 0, "XSACTVALUE", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[2].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PXSACTDESC", Oracle.DataAccess.Client.OracleDbType.Varchar2, 255, System.Data.ParameterDirection.Input, false, 0, 0, "XSACTDESC", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[2].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PPAGEBREAK", Oracle.DataAccess.Client.OracleDbType.Int32, 22, System.Data.ParameterDirection.Input, false, 0, 0, "PAGEBREAK", System.Data.DataRowVersion.Current, null));
    
                    //delete command
                    this.nCommandCollection[3] = new OracleCommand();
                    this.nCommandCollection[3].Connection = this.DataConnection;
                    this.nCommandCollection[3].CommandText = "DELETE FROM " + this.Tablename + " WHERE RECEIPTID=:p1 AND ACCOUNTID=RPAD(:p2,15)";
                    this.nCommandCollection[3].CommandType = System.Data.CommandType.Text;
                    this.nCommandCollection[3].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("p1", Oracle.DataAccess.Client.OracleDbType.Int64, 22, System.Data.ParameterDirection.Input, false, 0, 0, "RECEIPTID", System.Data.DataRowVersion.Current, null));
                    this.nCommandCollection[3].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("p2", Oracle.DataAccess.Client.OracleDbType.Char, 15, System.Data.ParameterDirection.Input, false, 0, 0, "ACCOUNTID", System.Data.DataRowVersion.Current, null));
    
                    this.CommandCollection = this.nCommandCollection;
                }
            }
    

    * The glance of the stored Proc *.

    PROCEDURE RECEIPT_ADDCHG_PROC
        (
        preceiptid IN OUT NUMBER,
        preceiptmode IN CHAR,
        pxsactdate IN DATE,
        pxsactvalue IN NUMBER,
        pbankaccountid IN VARCHAR2,
        pchequeno IN VARCHAR2,
        pclientbankid IN VARCHAR2,
        pdescription IN VARCHAR2,
        pstatementno in varchar2 default null,
        pcustodypayment IN NUMBER)
        is
        nrow number;
        begin
    
        --check if posted
        SELECT COUNT(*) INTO nrow from accountledger
        WHERE receiptid = preceiptid;
    
        IF nrow > 0 THEN
          RAISE_APPLICATION_ERROR(-20001, 'Record Already Posted');
        END IF;
    
        UPDATE Receipt
          Set pmodeid = preceiptmode,
          xsactdate = pxsactdate,
          xsactvalue = pxsactvalue,
          bankaccountid = pbankaccountid,
          chequeno = pchequeno,
          clientbankid = pclientbankid,
          description = pdescription,
          statementno = pstatementno,
          custodypayment = pcustodypayment
        WHERE receiptid = preceiptid;
    
        IF (SQL%NOTFOUND) THEN
          INSERT INTO RECEIPT(receiptid,
                              pmodeid,
                              xsactdate,
                              xsactvalue,
                              bankaccountid,
                              chequeno,
                              clientbankid,
                              description,
                              statementno,
                              custodypayment
                              )
          VALUES(preceiptid,
                  preceiptmode,
                  pxsactdate,
                  pxsactvalue,
                  pbankaccountid,
                  pchequeno,
                  pclientbankid,
                  pdescription,
                  pstatementno,
                  pcustodypayment
                  ) RETURNING receiptid into (preceiptid);
        END IF;
    
        end;
    

    * It's how I update the Table *.

    public void UpdateData(DataTable tbl, Oracle.DataAccess.Client.OracleTransaction oTran)
                {
                    try
                    {
                        SetTransaction(oTran);
                        this._adapter.Update(tbl);
                        //this was added on 03-Aug-2011
                        tbl.AcceptChanges();
                    }
                    //handling concurrency problem
                    catch (DBConcurrencyException dbcx)
                    {
                        MessageBox.Show(CreateMessage(dbcx.Row), "Concurrency Exception", MessageBoxButtons.YesNo);
                    }
                    catch (OracleException ex)
                    {
                        throw ex;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
    
                }
    

    * The said Stack Trace *.

    at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors (Int32 commandCount RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo [batchCommands])
    at System.Data.Common.DbDataAdapter.UpdatedRowStatus (Int32 commandCount RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo [batchCommands])
    to System.Data.Common.DbDataAdapter.Update (DataRow [] dataRows, DataTableMapping tableMapping)
    to Oracle.DataAccess.Client.OracleDataAdapter.Update (DataRow [] dataRows, DataTableMapping tableMapping)
    at System.Data.Common.DbDataAdapter.UpdateFromDataTable (DataTable dataTable, DataTableMapping tableMapping)
    at System.Data.Common.DbDataAdapter.Update (DataTable dataTable)
    at EquityBroker32.APP_DATA.config.GenericBusinessTable.UpdateData (DataTable tbl, OracleTransaction oTran) in d:\REVERSION\Latest\APP_DATA\config\GenericBusinessTable.cs:line 293

    This is found!

    I add the following code to my existing and it worked!

    this.nCommandCollection[1].Parameters.Add(new Oracle.DataAccess.Client.OracleParameter("PRECEIPTID", Oracle.DataAccess.Client.OracleDbType.Double, 10, System.Data.ParameterDirection.InputOutput, false, 10, 0, "RECEIPTID", System.Data.DataRowVersion.Current, null));
    this.nCommandCollection[1].Parameters["PRECEIPTID"].DbType = DbType.Decimal;
    

    Thanks to this site and the person who answered: .Net technology: find a sequence of a S-P with typed DataSet problem - dotnet - tech.todaysummary.com

  • Dynamic SQL with in bulk in the record type

    Oracle 10.2 g

    I received this Tom

    [http://asktom.oracle.com/pls/apex/f?p=100:11:0:NO:]

    I'm able to do this without dynamic SQL, but my requirement is to do it in dynamic SQL
     create table t1 ( x int, y int );
    
     insert into t1 select rownum, rownum+1 from all_users where rownum <= 5;
    
     create table t2 ( x int, y int, z int );
    
     declare
                type array is table of t1%rowtype;
                l_data array;
        begin
                select * bulk collect into l_data from t1;
      
                forall i in 1 .. l_data.count
                
                       execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
        end;
     
    Error at line 1
    ORA-06550: line 9, column 90:
    PLS-00457: expressions have to be of SQL types
    ORA-06550: line 9, column 20:
    PL/SQL: Statement ignored
    There is a work around in 11g, but can we do something in 10g?



    Thank you
    HESH.

    HESH wrote:

    but following does not.

    declare
    type array is table of t1%rowtype;
    l_data array;
    begin
    select * bulk collect into l_data from t1;
    
    forall i in 1 .. l_data.count
    
    execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
    end;
    

    I want just a dynamic SQL code for the insert with FORALL statement would adopt as well as collections.

    Doesn't make much sense.

    Extract you the data from the SQL engine in the table of the record type. If the output data that cursor SQL must be read in the SQL engine and copied into the memory of PL/SQL engine.

    Then, you send that VERY SAME DATA back to the SQL engine to be used by a SQL insert cursor.

    Where is the logic behind the extraction of data from SQL in a PL/SQL table structure and then push this same structure table on the SQL engine database? What is the purpose to send data on a detour of underperforming and non-scalale through the PL/SQL engine?

    You have any justification (technical or functional wise) to back up this absurd approach?

    Why this can be achieved using a single SQL cursor that does both the choice (extraction) and (in bulk) insertion - using the plain old INSERT... SELECT structure?

    And if the insert is variable, then what? Create a dynamic INSERT... SELECT cursor and execute it (using bind values). This simple... Right?

  • SQL Developer 3.0 EA 1 Advanced support for the type of data in the unit tests

    Hello

    According to SQL Developer 3.0 EA 1 New Feature List (http://www.oracle.com/technetwork/developer-tools/sql-developer/rel3-featurelist-ea1-166831.html#ut)
    the EA 1 version 3.0 supported advanced data types in the unit tests. This means support the ANYDATA and RECORD types? I installed version 3.0 of EA 1 to CentOS linux, but it seems that those advanced types are not supported yet. When I try to add a unit test for a function that returns the record type, I get quick error: "the return of PL/SQL RECORD type is not supported. Cannot test (function_name) because 1 arguments have not supported for types". Also if I try to unit test procedure which parameter is of type ANYDATA, I get quick error: "the type UNDEFINED P_DATA argument is not supported. Cannot test (procedure_name) because 1 arguments have not supported for types". Are those advanced data types supported in SQL Developer 3.0 FINAL version?

    Thank you
    Miikka L

    Edited by: user12844253 the 27.10.2010 16:31

    Hi Mikka,

    Only simple PL/SQL records are currently supported i.e. those containing no optional or repeating components and where all components are themselves supported. This restriction is in place, due to the fact that we are using JDBC as a parameter mechanism which does not directly support the passage the PL/SQL record type.

    ANYTYPE and ANYDATA are currently not supported because they have a dynamic value type and must be set programmatically. In the future, it would be possible to support these via the dynamic value and and validation features.

    This will remain for the final version.

    Kind regards
    Richard

  • objects and the record type

    Hello experts.

    create type emp2_obj is object
    (
    objno number
    ,
    objname varchar2
    (20),
    objdept number
    );

    create type emp2_objarr is table of emp2_obj;

    and

    type emp2_rec is record
    (
    recno number
    ,
    recname varchar2
    (20),
    recdept number
    );

    create type emp2_recarr is table of emp2_rec ;

    Objects and types of records are created similar and have the same similar object.  Is it only advisable to use registration type if you use a collection in PL/SQL type... Please advice

    user13328581 wrote:

    the only reason why I ask is because he asked during an interview

    -Objects and the types of records are created similar and have the same similar object.  Is it only advisable to use registration type if you use a collection in PL/SQL type... Please advice

    Not at all.  You can use record types used with collection types outside.  They are a group concept.  If you want to group a set of values together (including fields), you can use a record.  It may be convenient.  You can send documents around proc and functions.

    Be aware that the record types are limited to procedures, functions, anonymous blocks and packages (i.e. PL/SQL), while the types of objects are stored in the dictionary of data as a separate Oracle objects (they can also have methods, the records may not).  Object types can be used in SQL, as said sol.beach types of records (outside of the intelligent pipeline situations) is for PL/SQL.

  • Return the record type


    Hello

    I have a requirement of the company, where I need to return a record type (OUT parameter) for environment call based on the given input value.

    Suppose that if the value is correct and corresponding record is found in the table then the return values for this key entry. If matching record is found, then return the exception to the calling environment.

    To do this, I created an example of test table and populated records.

    create table plch_test(dept_id number,dept_name varchar2(50),cost_centre number);
    insert into plch_test values(10,'SALES',1010);
    insert into plch_test values(20,'FINANCE',2010);
    insert into plch_test values(30,'MKTG',3010);
    
     
    SQL> select * from plch_test;
       DEPT_ID DEPT_NAME                                          COST_CENTRE
    ---------- -------------------------------------------------- -----------
            10 SALES                                                     1010
            20 FINANCE                                                   2010
            30 MKTG                                                      3010
    
     
     
    

    I wrote a simple block and gave a valid key dept_id (10 in this case) to display costcentre for this dept_id and dept_name I said tow types of records, one for valid record and another exception

    
    

    SQL> DECLARE 
      2  TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
      3  l_rec_dept rec_dept;
      4  TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
      5  l_rec_exception rec_exception;
      6  BEGIN
      7  SELECT dept_name,cost_centre
      8  INTO l_rec_dept
      9  FROM plch_test
     10  where dept_id=10;
     11  dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
     12  EXCEPTION WHEN NO_DATA_FOUND THEN
     13  l_rec_exception.err_code:=sqlcode;
     14  l_rec_exception.error_message:=sqlerrm;
     15  dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message);
     16  END;
     17  .
    SQL> /
    DEPT_NAME SALES COSTCENTRE 1010
    PL/SQL procedure successfully completed.
    SQL> 
    
     
    

    Now for invalid dept_id and expose the message by using exception record type I stated.

    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2  TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
      3  l_rec_dept rec_dept;
      4  TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
      5  l_rec_exception rec_exception;
      6  BEGIN
      7  SELECT dept_name,cost_centre
      8  INTO l_rec_dept
      9  FROM plch_test
     10  where dept_id=40; --Invalid --data is not present
     11  dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
     12  EXCEPTION WHEN NO_DATA_FOUND THEN
     13  l_rec_exception.err_code:=sqlcode;
     14  l_rec_exception.error_message:=sqlerrm;
     15  dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message);
     16* END;
    SQL> /
    100 ORA-01403: no data found
    PL/SQL procedure successfully completed.
    
    

    Now as you can see I need to include this point in a procedure with an input parameter and output must be a record types which will return

    rec_dept if it becomes a key input valid or an exception if she meets a key not valid.

    
    CREATE PROCEDURE test_prc IS(p_in_dept_id IN plch_test.dept_id,p_output ??????
    DECLARE 
    TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
    l_rec_dept rec_dept;
    TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
    l_rec_exception rec_exception;
    BEGIN
    BEGIN
    SELECT dept_name,cost_centre
    INTO l_rec_dept
    FROM plch_test
    where dept_id=p_ind_dept_id;
    RETURN l_rec_dept;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    l_rec_exception.err_code:=sqlcode;
    l_rec_exception.error_message:=sqlerrm;
    RETURN l_rec_exception;
    END;
    dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
    END;
    

    Hope that the explanation above help in imposes the requirement

    Kind regards

    Claudy kotekal

    Return a record which can mean two things is complicated; I'm not an experienced myself pl/sql developer, but this looks like a craft.

    The idea of exceptions under Sir Thomas of Kyte, is that any treatment must be stopped; You should RAISE an exception to the appellant so that he can figure out what to do with it.  What you are saying, this is an exception, but is not a little, cos it's okay, I'll just keep but I will go back to the appellant in any way, but the appellant shall include this registration type is - would it be a record representing a row of the table, or it might be an exception... yuck.

    (a) is it really an exception

    (b) what do you do with it? You he could log into a table, you could write to a file, you can display an error message on the screen

    But really, it's weird to want to pass an exception as return value.

    These are all considerations of design, not really anything to do with the pl/sql language in itself.

    But hard, if you send a record type a successful being found, registration-based stick to it and don't use it to return a record; do not try to do double duty with her flipping something else.  Just save the message put in a table, or print it to the console, or what you want to do with; but as I said, the most important decision is, is this really an exception. And is based on the data model and the expectations of cleanliness of the data etc.

    Think about how you call built-in functions. If you send garbage to a built-in function it does not return successfully, leaving you to figure out whether he succeeded or not by inspecting the return value; It goes kaboom, something bad happened.  That's what your function should do if something bad happens, that is to say, if you get an exception, it should probably go kaboom.

  • PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type

    Hello

    Having a little trouble with the following code example provided to http://www.dba-oracle.com/plsql/t_plsql_cursor_variables.htm:
      1  DECLARE
      2    TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
      3    c_cursor  t_ref_cursor;
      4    l_row   NUMBER;
      5  BEGIN
      6    DBMS_OUTPUT.put_line('Strongly typed REF CURSOR using SCALAR type. Expect an error!');
      7    OPEN c_cursor FOR
      8      SELECT COUNT(*) cnt
      9      FROM   cursor_variable_test;
     10    LOOP
     11      FETCH c_cursor
     12      INTO  l_row;
     13      EXIT WHEN c_cursor%NOTFOUND;
     14      DBMS_OUTPUT.put_line(l_row);
     15    END LOOP;
     16    CLOSE c_cursor;
     17* END;
     18  /
      TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
                           *
    ERROR at line 2:
    ORA-06550: line 2, column 24:
    PLS-00362: invalid cursor return type; 'NUMBER' must be a record type
    ORA-06550: line 2, column 3:
    PL/SQL: Item ignored
    In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
    Why can't return a value in a column of a row in a NUMBER?
    How can I change the SQL code so that I can do this?

    Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?

    Thank you very much
    Jason

    >
    TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
    *
    ERROR on line 2:
    ORA-06550: line 2, column 24:
    PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
    ORA-06550: line 2, column 3:
    PL/SQL: Ignored Element

    In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
    Why can't return a value in a column of a row in a NUMBER?
    How can I change the SQL code so that I can do this?
    >
    The exception is in line 2: your cursor statement. And the answer is in the text that you access
    >
    The return value of a strongly typed REF CURSOR must be a folder that can be defined using % TYPE % ROWTYPE attributes or record structure.
    >
    You said the CURSOR to return a NUMBER. And as the text says, he must be a 'record '.
    >
    Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
    >
    As you said already FETCH retrieves the next line, if any. A query is a request is a request. It returns a result set. A query that uses aggregates returns a result set. A query that does not aggregate returns a result set.

    Your simple COUNT (*) SELECT query returns a result set that consists of a LINE and a line a ONE COLUMN of type NUMBER. Although there is only one column in the result set, what is returned is a RECORD or a LINE. That's why you have to report your data cursor return type a document using the % ROWTYPE or % TYPE attributes or a record structure.

  • Update a primary key of type char data

    Hello
    Not a guy to oracle technology. but am forced to work on a query that is a basic requirement.

    I have a table that has a composite primary key values (6 columns).
    Of these, I've updated 1 specific column, which is a char data type.

    I tested after writing my logic as a query, threw it [the Unique constraint violated schema.tablename];

    So I gave it a query simple base to test it yet, still get the same error.

    Query such as:

    Update table_name set Column1 = "100000" where column2 = 'BOMBAY '; (Column1 is the primary key of type char)

    Even if it did not work.
    Now a doubt arises, a column is a primary key of type Char can be modified? or is it not possible at all to do?

    Note: I made sure only am not updated with a duplicate value;


    Thank you.

    Published by: 966353 on October 18, 2012 12:01

    While you never need to update a primary key (regardless of the type of data), it is possible to do. If you get an error ORA-00001 indicating that a unique constraint has been violated and the unique constraint that is violated is associated with the primary key of the table (I'm guessing that this is the case according to your description of the error), implying strongly that the update would result in duplicate rows. Your UPDATE statement updates more than 1 row? If so, how do you determine when the update is complete there will be no duplicate lines?

    Justin

  • Error using BULK collect with RECORD TYPE

    Hello

    I wrote a simple procedure to declare a record type & then by a variable of type NESTED table.

    I then selects the data using COLLECT in BULK & trying to access it via a LOOP... We get an ERROR.

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

    CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
    IS

    TYPE rec_type () IS RENDERING
    emp_id VARCHAR2 (20).
    level_id NUMBER
    );

    TYPE v_rec_type IS TABLE OF THE rec_type;

    BEGIN

    SELECT employe_id, level_id
    LOOSE COLLECTION v_rec_type
    OF portfolio_exec_level_mapping
    WHERE portfolio_execp_id = 2851852;

    FOR indx IN v_rec_type. FIRST... v_rec_type. LAST
    LOOP

    dbms_output.put_line ('Emp-' | v_rec_type.emp_id (indx) |) » '|| v_rec_type.level_id (indx));

    END LOOP;

    END;
    -----------------------------------------------------------------------------------------------------------------------------------

    Here is the ERROR I get...


    -Errors of compilation for the PROCEDURE DOMRATBDTESTUSER. SP_TEST_BULKCOLLECT

    Error: PLS-00321: expression "V_REC_TYPE" is not appropriate for the left side of an assignment statement
    Online: 15
    Text: IN portfolio_exec_level_mapping

    Error: PL/SQL: ORA-00904: invalid identifier
    Online: 16
    Text: WHERE portfolio_execp_id = 2851852;

    Error: PL/SQL: statement ignored
    Line: 14
    Text: COLLECT LOOSE v_rec_type

    Error: PLS-00302: component 'FIRST' must be declared
    Online: 19
    Text: LOOP

    Error: PL/SQL: statement ignored
    Online: 19
    Text: LOOP
    ------------------------------------------------------------------------------------------------

    Help PLZ.

    and with a complete code example:

    SQL> CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
      2  IS
      3  TYPE rec_type IS RECORD (
      4  emp_id VARCHAR2(20),
      5  level_id NUMBER
      6  );
      7  TYPE v_rec_type IS TABLE OF rec_type;
      8  v v_rec_type;
      9  BEGIN
     10     SELECT empno, sal
     11     BULK COLLECT INTO v
     12     FROM emp
     13     WHERE empno = 7876;
     14     FOR indx IN v.FIRST..v.LAST
     15     LOOP
     16        dbms_output.put_line('Emp -- '||v(indx).emp_id||' '||v(indx).level_id);
     17     END LOOP;
     18  END;
     19  /
    
    Procedure created.
    
    SQL>
    SQL> show error
    No errors.
    SQL>
    SQL> begin
      2     sp_test_bulkcollect;
      3  end;
      4  /
    Emp -- 7876 1100
    
    PL/SQL procedure successfully completed.
    
  • Foreground of Oracle process to access data under Linux files

    As far as I know, processes user in an Oracle database running the application code, but the processes of database running Oracle database server code (server process analyze and execute the SQL statements issued through the app, read data of data files blocks and return the results to the application.) Background treats the archive logs, update the headers of all the data files to save the details of the control point, written content of the buffers of data files, runs the recovery if necessary, etc.)

    However, I could see the oracle user processes to access data files in my Oracle database. When I look for the processes to access data belonging to the tablespace files "recprov", I get the following:

    [root@ymir ~] # lsof | grep recprov
    Oracle Oracle 465 11u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 465 13u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 465 15u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 964 11u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 964 13u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 964 14u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 13364 14u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 13364 76u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 16445 17u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 16445 18u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 20522 REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659 82uW
    Oracle Oracle 20522 REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658 122uW
    Oracle Oracle 20532 44u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 20532 75u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658
    Oracle Oracle 20534 17u REG 8.18 4823457792 /ora2/oradata/essepr3/recprov_tb_02.dbf 48496659
    Oracle Oracle 20534 79u REG 8.18 6291464192 /ora2/oradata/essepr3/recprov_tb_01.dbf 48496658

    As you can see, there are 7 oracle processes that access data files: 4 processes user and 3 background processes:

    [root@ymir ~] # ps - ef
    ...
    Oracle 465 1 Jan27 0? 00:00:23 oracleessepr3 (LOCAL = NO)
    Oracle 964 1 Jan27 0? 00:00:25 oracleessepr3 (LOCAL = NO)
    Oracle 13364 1 0 Jan13? 02:45:02 oracleessepr3 (LOCAL = NO)
    Oracle 16445 1 0 Jan21? 00:00:05 oracleessepr3 (LOCAL = NO)
    20522 1 0 2009 Oracle? 00:09:59 ora_dbw0_essepr3
    20532 1 0 2009 Oracle? 00:04:24 ora_ckpt_essepr3
    20534 1 0 2009 Oracle? 00:04:10 ora_smon_essepr3
    ...

    And I confirmed this information from the data base repository:

    SQL > select p.SPID, SSE. TYPE, SSE. Username, SSE. MACHINE, SSE. PROGRAM
    session $ v ESS, v$ process p
    where p.SPID (465, 964, 13364, 16445, 20522, 20532, 20534) and SES. PADDR = p.ADDR;

    USER NAME OF TYPE SPID MACHINE PROGRAM
    ----- ----------- --------------- --------------- ---------------------------------------------------------
    20522 BACKGROUND dbserver (DBW0) oracle@dbserver
    20532 BACKGROUND dbserver oracle@dbserver (CKPT)
    20534 BACKGROUND dbserver oracle@dbserver (SMON)
    13364 USER DBSNMP dbserver emagent@dbserver (TNS V1 - V3)
    964 RECPROV USER appserver JDBC Thin Client
    16445 USER SYSTEM userPC PlSqlDev.exe
    465 RECPROV USER appserver JDBC Thin Client

    * RECPROV is the name of the user of the application database.

    My question is, why are there user processes to access data files? I think that it does not match the process architecture defined by Oracle. And most importantly, it does not mean a security leak in the database?

    DB version: 10.2.0.3, dedicated
    The Linux Version: Linux 2.6.18 - 53.el5xen #1 SMP Sat Nov 10 19:46:06 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

    Thanks in advance

    Hello

    There seems to be some confusion, even in the Oracle documentation, in terms of nomenclature.

    Think of it this way. There is the client program that connects to Oracle, such as SQL * Plus, Toad, custom, etc. written application. This program runs on the client. This may or may not be on the database server.

    Then there's the Oracle database server process. They run always on the database server. These processes are of two types, the USER and the background.

    You can see:

    SQL> select background,count(*) from v$process group by background;
    
    B   COUNT(*)
    - ----------
              65
    1         37
    

    Here are copies of the file binary oracle attach directly to the SGA and interact with database files. The binary oracle works with several different "personalities" based on the different purposes, he is currently serving. The type of background process, are divided into different specific methods for specific purposes.
    Yet once, observe:

    SQL> select pname from v$process where background = 1;
    
    PNAME
    -----
    PMON
    VKTM
    GEN0
    DIAG
    DBRM
    PING
    PSP0
    ACMS
    DIA0
    LMON
    LMD0
    
    PNAME
    -----
    LMS0
    LMS1
    RMS0
    LMHB
    MMAN
    DBW0
    DBW1
    LGWR
    CKPT
    SMON
    RECO
    
    PNAME
    -----
    RBAL
    ASMB
    MMON
    MMNL
    MARK
    LCK0
    RSMN
    GTX0
    SMCO
    W000
    RCBG
    
    PNAME
    -----
    QMNC
    Q001
    CJQ0
    Q005
    
    37 rows selected.
    

    Thus, each background process serves a different purpose. For example. DBW0 concerns only to write data from the buffer cache data files and maintaining all data structures associated with it. Each background process above serves a different purpose, I will not go into all. Generally, the background processes start up time of instance startup, even though some may be started on demand, at a certain time after the start of the proceeding.

    Now, consider a dedicated server model. When you connect to the database by using SQL * Plus, for example, you run the binary "sqlplus". Assume that you are connected via SQL * Net. In this case, sqlplus connects to the listener, the listener creates an oracle server process, type 'USER '. This process always runs on the database server. It runs under the user 'oracle', and it provides your real and direct interface to the database. This user can interact with the database and read the database files directly.

    Mainly, your server processes the USER will read the data from the cache buffers and, in the case of an absence of cache, will read the data in the data files and loading into the buffer cache. In addition, according to the code path, it can directly read or write to the datafiles, bypassing the buffer cache.

    So, the bottom line, all server (USER and BOTTOM) processes, interact with the database and associated files. The code of client program (sqlplus, Toad, etc.) NEVER directly interacts with the database.

    Hope that things cleared up.

    -Mark

Maybe you are looking for