DATA_TYPE Oracle (using SQL) questions

I have a Client Server application that I created using a server for MS - SQL (MS - SQL Server 2008 R2 Express) database.

Since MS - SQL Server has wide range and number of DATA_TYPEs, I chose to devote some of these DATA_TYPEs to the application-specific processing (mainly MONEY and DATA_TYPES BOOLEAN).

In addition, I decided that in the Client Application that the general treatment of a particular field would be determined by the corresponding DATA_TYPE stored in the database.

The value of the DATA_TYPE for a particular field within the SQL Server database and can be determined by querying:

"select DATA_TYPE from INFORMATION_SCHEMA. Columns
"where ((Column_name = «my_Field») and (Table_Name = 'myTable')).

I also extract/use other DATA_TYPE information as necessary or appropriate.

With this information the Client Application can systematically treated differently may be a MONEY (a DATA_TYPE in MS - SQL Server) a decimal or one BIGINT (two other DATA_TYPEs in MS - SQL Server). I have to create the field with the correct DATA_TYPE in the database, but after that I don't have to worry about this.
.
.
.
Now, I'm moving a database to Oracle (Oracle Database Express Edition 11 g Release 2). And I would have the same (or similar) feature, as described above.

Oracle has less DATA_TYPES is more difficult to bind an application-specific-data type to a database-Oracle-DATA_TYPE-specific. There are simply not as many "sacrifice" to my specific processing of the application. I don't want to treat each field DIGITAL like 'le-apps-money-type.'

With Oracle can I associate 'the-apps-money-type', let's say, a NUMERIC (9,2), then the Client Application will process all NUMERIC (9.2) as 'the-apps-money-type '.

The Client Application queries the Oracle database for DATA_TYPE DATA_PRECISION, DATA_SCALE to make this determination.

But this approach doesn't appeal to me, suppose I have other NUMERIC fields (9,2) who are not of the 'the-apps-money-type '. How can I set and then later determine, from the Oracle backend, if the NUMERIC field (9.2) is intended to be used as 'the-apps-money-type' or just a regular number?

Is it possible I can create a kind of "sub DATA_TYPE" in Oracle?

I have considered this in the COMMENT field associated with particular field. Then a query for this comment when I did DIGITAL DATA_TYPEs. But the COMMENTS field seems not to turn all_tab_columns and user_tab_columns.

(With Oracle SQL Developer, you can create/edit/delete user created tables/fields. COMMENTS can be added to the individual fields in a table - this are the COMMENTS that I am referring above).
.
.
.
What I would do, and a more direct approach for me, would be in some way create a user defined DATA_TYPE is simply:
(1) a user defined DATA_TYPE name (such as MY_MONEY_TYPE),
(2) associated with a built-in Oracle data type (such as NUMERIC (9.2).)

Then when the client application queries user_tab_columns the field may be treated appropriately. If I can't do it, maybe there is somewhere else I may be put and subsequently ask for such information.

What are the most direct ways to implement the functionality described above?

You can create an object type and certainly use it in your table definition

SQL> create type my_money_type as object (
  2    val number(9,2)
  3  );
  4  /

Type created.

SQL> create table foo (
  2    col1 number primary key,
  3    col2 my_money_type
  4  );

Table created.

SQL> insert into foo values( 1, my_money_type(1.23) );

1 row created.

SQL> select col1, col2 from foo;

   COL1
-------
COL2(VAL)
--------------------------------------------------------------------------------
   1.00
MY_MONEY_TYPE(1.23)

This usually isn't a particularly good way to design an application, however. Types of objects are very useful in the treatment of PL/SQL, but their conservation in a table is usually a pain - you must constantly to call the constructor of the object and the getter methods (I did not worth defining here) assuming that you want to return the number of 1.23 rather than an instance of MY_MONEY_TYPE.

Justin

Tags: Database

Similar Questions

  • Oracle PL SQL Question to get some data to oracle tables descrepancy

    Version of database

    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE Production 9.2.0.8.0
    AMT for HP - UX: 9.2.0.8.0 - Production Version
    NLSRTL Version 9.2.0.8.0 - Production

    created a few sample data

    drop table tab1 purge;
    create table tab1 (DEPT_ID COMP, qc_subtype_id char (4), EQUIP_CODE varchar2 (20), create_time date);
    Insert into tab1 values(13,'1026','HEMORYA011',sysdate);
    Insert into tab1 values(13,'1012','HEMORYA011',sysdate);
    Insert into tab1 values(95,'1026','HEMORYA121',sysdate);
    Insert into tab1 values(95,'1012','HEMORYA121',sysdate);
    ----------------------
    Insert into tab1 values(13,'1026','HEMORYA014',sysdate);
    Insert into tab1 values(13,'1012','HEMORYA005',sysdate);
    Insert into tab1 values(13,'1012','HEMORYA013',sysdate);
    Insert into tab1 values(95,'1012','HEMORYA013',sysdate);
    Insert into tab1 values(95,'1012','HEMORYA148',sysdate);

    commit;

    I need to get a query to get the records of the gap

    Dept HEMORYA014 13 lack 1012

    HEMORYA005 dept 12 lack 1026

    Dept HEMORYA013 13 lack 1026

    The dept 95 lack 1026 HEMORYA013

    The dept 95 lack 1026 HEMORYA148

    I want to show the latter on the report

    Thanks in advance.

    Thanks for posting a unit test.
    I hope it will work for you, but maybe you will need to set the WHERE clause (add additional predicates).

    SQL> select equip_code
      2  from ( select equip_code
      3         ,      count(distinct qc_subtype_id)
      4         from   tab1
      5         group by equip_code
      6         having count(distinct qc_subtype_id)<2
      7        )
      8  order by equip_code;
    
    EQUIP_CODE
    --------------------
    HEMORYA005
    HEMORYA013
    HEMORYA014
    HEMORYA148
    
  • Load the XML file into oracle using sql loader

    Hello

    I'm trying to load an xml file into a table using sqlldr.
    I have a table as follows:
    CREATE TABLE xmlloadtable
    ( id number,
     data_xml XMLType
     )
      XmlType data_xml STORE AS CLOB;
    I have a control file that I know is perfectly false:
    LOAD DATA 
    INFILE '/home/oraread/'
    INTO TABLE xmlloadtable 
    (
    id,
    data_xml 
    )
    I googled for the file control and tried in different ways, but of no use.
    I want to load the entire xml file into the table.
    Can someone help me with the correct control file. Any help is appreciated!

    Try this

    LOAD DATA
    INFILE '/home/oraread/'
    INTO TABLE xmlloadtable
    (id,
     file_name          filler,
     data_xml          lobfile(file_name) terminated by eof
    )
    

    You can add the file as a column name field to your table between the id and xml column and remove the word to fill in the .ldr file if you need to keep the name of the file

  • Building xml in oracle without unnecessary tags using sql

    I wanted to build XML in oracle using sql, I found a way to construction using sql functions after a little research, I am completely unaware of any XML. My query is


    SELECT XMLELEMENT("orderwave",
      XMLAGG
    (XMLELEMENT("order_header",
      
    -- XMLATTRIBUTES(t2.l_name AS "order_number"),
      XMLFOREST
    (
      nvl
    (t2.l_name,' ') as "order_number",
      
    (
      SELECT XMLAGG
    (XMLELEMENT("order_line",
      XMLFOREST
    ( nvl(t1.l_name,' ') AS "label_type",
      nvl
    (t1.l_num,0) AS "lpn",
      nvl
    (t1.l_num,0) AS "sku"
      
    )
      
    )
      
    ) 
      FROM test_table t1
      WHERE UPPER
    (t1.record_type)='D'  
      
    ) AS sap
      
    )
      
    )
      
    )
      
    ) AS HEADER
      FROM test_table t2
      WHERE UPPER
    (t2.record_type) ='H';


    My problem is for using xmlforest, I had to use alias name 'sap' in my query to work and to get xml output. If i am using that, I am getting an unwanted tag 'SAP' around my data which I have to later cut it, which is unacceptable. Is there a way I can get rid of this extra 'SAP' tag without having to cut. The output data is


    <orderwave>
      
    <order_header>
      
    <order_number>order1</order_number>
      
    <SAP>
      
    <order_line>
      
    <label_type>test1</label_type>
      
    <lpn>1</lpn>
      
    <sku>1</sku>
      
    </order_line>
      
    <order_line>
      
    <label_type>test2</label_type>
      
    <lpn>2</lpn>
      
    <sku>2</sku>
      
    </order_line>
      
    <order_line>
      
    <label_type />
      
    <lpn>0</lpn>
      
    <sku>0</sku>
      
    </order_line>
      
    </SAP>
      
    </order_header>
      
    <order_header>
      
    <order_number>order2</order_number>
      
    <SAP>
      
    <order_line>
      
    <label_type>test1</label_type>
      
    <lpn>1</lpn>
      
    <sku>1</sku>
      
    </order_line>
      
    <order_line>
      
    <label_type>test2</label_type>
      
    <lpn>2</lpn>
      
    <sku>2</sku>
      
    </order_line>
      
    <order_line>
      
    <label_type />
      
    <lpn>0</lpn>
      
    <sku>0</sku>
      
    </order_line>
      
    </SAP>
      
    </order_header>
    </orderwave>


      Any help is really appreciated and thanks in advance.

    -- sample data
    with test_table
    as
    (
        select 'H' record_type, 'order1' l_name, 0 l_num from dual
        union all
        select 'H' record_type, 'order2' l_name, 0 l_num from dual
        union all
        select 'D' record_type, 'test1'  l_name, 1 l_num from dual
        union all
        select 'D' record_type, 'test2'  l_name, 2 l_num from dual
    )
    -- end of sample data
    select xmlelement
           (
              "order_wave"
            , xmlagg
              (
                xmlelement
                (
                    "order_header"
                  , xmlelement("order_number", t1.l_name)
                  , xmlagg
                    (
                      xmlelement
                      (
                         "order_line"
                       , xmlelement("label_type", t2.l_name)
                       , xmlelement("lpn", t2.l_num)
                       , xmlelement("sku", t2.l_num)
                      )
                    )
                )
              )
           ) xml_data
      from test_table t1
     cross
      join test_table t2
     where t1.record_type = 'H'
       and t2.record_type = 'D'
     group
        by t1.l_name;
    
    -- output
    /*
    
            
                    order1
                    
                            test1
                            1
                            1
                    
                    
                            test2
                            2
                            2
                    
            
            
                    order2
                    
                            test1
                            1
                            1
                    
                    
                            test2
                            2
                            2
                    
            
    
    */
    
  • Using sql developer

    Hello

    I have mysql on a server and oracle on other sever (both under linux). I want to migrate data from mysql to oracle using sql Developer installed on another remote computer. What are the neccessities base that I have to keep in mind in this regard, or should I just use the installed with oracle sql developer.

    I do not have the required display variables defined on the oracle server and also an older version of sqldeveloper is installed with oracle. I think installing the latest version of sql developer on windows platform and then want to access the database on linux machines.
    Please notify.

    Thanx

    11 g DBA wrote:
    Hello

    I have mysql on a server and oracle on other sever (both under linux). I want to migrate data from mysql to oracle using sql Developer installed on another remote computer. What are the neccessities base that I have to keep in mind in this regard, or should I just use the installed with oracle sql developer.

    I do not have the required display variables defined on the oracle server and also an older version of sqldeveloper is installed with oracle. I think installing the latest version of sql developer on windows platform and then want to access the database on linux machines.
    Please notify.

    Thanx

    Download the latest developer SQL on your PC. Enable your firewall rules accept connections from your PC to the database port (usually 1521 - Oracle, 3306 - MySQL).
    Establish a connection with your data (assuming that the privileges are sorted) and start the migration.
    Note: For MySQL, you will need to download third party connector (a quick Google and you'll find the download and installation instructions).

    You already have the URL for the migration.

  • MySQL-&gt; table using SQL Developer Oracle

    Greetings,

    Currently, I am a (student) temporary employee who is responsible for the migration of the MySQL database of a company to their new (gr 11, 2) Oracle database.

    So far, I use SQL Developer, because I learned a few minor techniques with this application.

    I have tried different methods for the migration, including those of the Oracle (Migration of MySQL) page

    I however got no positive results with most of the methods.

    -J' have established a connection to the MySQL database Oracle database aswell, within SQL Developer

    Now, so far, I've copied manually (right click on the table, copy to Oracle) 90% of the tables from the MySQL to Oracle database successfully.

    However, these tables contain only about 5% of the data. The problem is in the 2 tables that actually have a decent amount of records.

    FOR INFO:

    File 1: 75MB file .csv, ~150.000 records (individual records contain all select queries, where the size)

    File 02:50 MB of files .csv, ~2.200.000 records

    My previous attempts to use the same copy for Oracle option to right click on one of the two largest tables resulted in the following error:

    The table of queries down. Message: java.io.IOException: IO error: socket read timed out

    My first action to prevent this error has been to add a second file data to the current storage space, giving it 200M maxsize.

    Okay it's coming, my real questions!

    This could be a possible solution to avoid the error mentioned earlier to return?

    What other issues are possible in case of failure?

    Uses an external table to a faster and more effective method?

    (The reason for which I have not yet tried external tables is because I had no SYS (TEM) privileges, so anything that requires privileges, I first have to discuss with my superior).

    Any help is appreciated! Although my next answer is maybe not earlier that come Monday 17.

    Welcome, Brent

    Hello

    I just discovered there is a csv Import Wizard in sqldeveloper also - don't know if you tried?

    tables in the destination database (oracle) - right-click and choose Import data - this will bring you in a Wizard of csv.

    However, I think that due to the volumes of data it may have similar problems.

    sqlldr is probably your best choice - it's pretty simple once you find a decent example - it seems to cover the basics of ok - Oracle SQL Stuff (for example): SQL-Loader: the tutorial step by step - example 1 (CSV file)

    See you soon,.

    Rich

  • Error when using SQL Developer to IMPORT access data in Oracle

    Hello
    I use SQL Develoepr to export the Access mdb file to Oracle. When I try to use the tools -? Migration-> Microsssfot-> export access
    I get an error message to attach the Access database file, the error indicates

    "Error #40179 - XMLExporter - Methiod 'AddFromFile' of object ' _References failed." Export failed.

    What could be the reason for this error please notify.

    Thank you

    Don't know if it is related to your question, but you need a JDK 1.6 (Java SDK). What do you get in Help - about - Version?

    K.

  • MySQL to Oracle using LKM SQL to Oracle, poor performance

    Hello

    I'm on the underside of technology.

    I'm try to use ODI to import data from MySQL to Oracle using the LKM SQL to Oracle, it works well for small amounts of documents but once volumes go higher it performs very badly.

    I'm replacing an integration of existing HS dblink to 44 seconds and ODI is 9 minutes.

    The MySQL and Oracle DB are on the same host with an autonomous ODI agent on the same host.

    MySQL 5.6.21

    Oracle 11.2.0.4

    Oracle Data Integrator 12.1.3

    I may try a different approach to dumping the MySQL table to a flat file and import from external table or sqlldr but y at - it a way to make the LKM SQL for Oracle perform better?

    Hello

    This problem has been resolved.

    I was setting the table sizes in batches on the data source server, after you set the values on the target data server is it now works as expected.

    Using a value of 5,000 for the two tables has reduced the operating time of 9 minutes to about 40 seconds.

  • Problem with migration SQL Server Oracle 11.2 2012 DB using SQL Developer Migration workbench

    Hello

    I have a problem when migrating SQL Server Oracle 11.2 2012 using SQL Developer Migration workbench, hope that someone had the same problem before and can give same advide...

    I use SQL Developer Version 4.0.1.14 and Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0. and last jtds - 1.3.

    I created the schema migration_repo, privileges, connected to the third part of Db (SQL Server) and begin a trial with assistant. In the first step of the model to Capture, I get the message from the:

    "Company Capture Capture failed.  Refer to the table MIGRLOG in the repository for more details ".

    But MIGRLOG is empty.

    Here is my log:

    <? XML version = "1.0" encoding = "windows-1252" standalone = 'no '? >

    < Log >

    account <>

    < date > 2014-03-16T 20: 49:17 < / date >

    oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >

    < level > SEVERE < / level >

    oracle.dbtools.migration.workbench.core.logging.MigrationLogUtil < class > < / class >

    < message > Capture

    Capture Enterprise

    Capture failure.  Refer to the MIGRLOG table in the repository for more details < / message >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doOnlineEnterpriseCapture(FullMigrateTask.java:758) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doCapture(FullMigrateTask.java:601) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doMaskBasedActions(FullMigrateTask.java:400) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:314) < param > < / param >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask.doWork(FullMigrateTask.java:147) < param > < / param >

    oracle.dbtools.raptor.backgroundTask.RaptorTask.call(RaptorTask.java:193) < param > < / param >

    java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >

    oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ (RaptorTaskManager.java:554) < param > RaptorFutureTask.run < / param >

    java.util.concurrent.Executors$ (Executors.java:471) < param > RunnableAdapter.call < / param >

    java.util.concurrent.FutureTask.run(FutureTask.java:262) < param > < / param >

    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) < param > < / param >

    java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:615) < param > < / param >

    java.lang.Thread.run(Thread.java:744) < param > < / param >

    oracle.dbtools.migration.workbench.core.logging.LogInfo@68e69a < param > < / param >

    < exception >

    < message > oracle.dbtools.migration.workbench.core.ui.FullMigrateTask$ FullMigrateTaskException: Capture

    Capture Enterprise

    Capture failure.  Refer to the MIGRLOG table in the repository for more details < / message >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 758 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 601 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    line 400 > of < < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 314 < / line >

    < / framework >

    < frame >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    < line > 147 < / line >

    < / framework >

    < frame >

    oracle.dbtools.raptor.backgroundTask.RaptorTask < class > < / class >

    < line > 193 < / line >

    < / framework >

    < frame >

    java.util.concurrent.FutureTask < class > < / class >

    < line > 262 < / line >

    < / framework >

    < frame >

    oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$ RaptorFutureTask < class > < / class >

    < line > 554 < / line >

    < / framework >

    < frame >

    java.util.concurrent.Executors$ RunnableAdapter < class > < / class >

    < line > 471 < / line >

    < / framework >

    < frame >

    java.util.concurrent.FutureTask < class > < / class >

    < line > 262 < / line >

    < / framework >

    < frame >

    java.util.concurrent.ThreadPoolExecutor < class > < / class >

    < line > 1145 < / line >

    < / framework >

    < frame >

    java.util.concurrent.ThreadPoolExecutor$ Worker < class > < / class >

    < line > 615 < / line >

    < / framework >

    < frame >

    java.lang.Thread < class > < / class >

    < line > 744 < / line >

    < / framework >

    < / exception >

    < / recording >

    account <>

    < date > 2014-03-16T 20: 49:17 < / date >

    oracle.dbtools.migration.workbench.core.MigrationLogResourceBundle < recorder > < / recorder >

    WARNING < level > < / level >

    oracle.dbtools.migration.workbench.core.ui.FullMigrateTask < class > < / class >

    <>error message: ORA-06550: line 1, column 14:

    PLS-00201: identifier ' SS2K5ALLPLATFORM. STAGECAPTURE' must be declared

    ORA-06550: line 1, column 7:

    PL/SQL: Statement ignored

    : FAILED: Database Migration: FAILURE < / message >

    oracle.dbtools.migration.workbench.core.logging.LogInfo@1e2c9b99 < param > < / param >

    < / recording >

    I try with model db (DB empty, just a single table), but the error is same. However, if I try to copy the acronym tabele from SQL Server to Oracle it works fine...

    I guess it's something with the configuration, but beacause I am new in Oracle still have no idea...

    Any help would be much appreciated

    I thank in advance

    Stefan

    Hello Stefan,

    did you create the repository Migration of your database to Oracle (Tools-> Migration-> repository management)?

    The SS2K5ALLPLATFORM package is usually created when you add the migration of the Oracle database repository and it contains the function StageCapture.

    So please make sure that you have created a repository of migration in an Oracle database and associate it with the first step of your migration.

    -Klaus

  • How to count the number of columns in an oracle table using sql

    How to count the number of columns in an oracle table using sql

    You must put the name of the table in capital letters

    As

    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    
    or
    
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');
    

    Concerning
    Arun

  • How can I use SQL to check the Version of Oracle Forms and object of the request?

    Hi all:

    How can I use SQL to check the Version of Oracle Forms and object of the request?





    Concerning
    Terry

    Terry,

    See the following threads/docs for the version of forms.

    How to find the developer version
    Re: How to find the developer version

    Note: 466890.1 - Script to find the Apache, Java, Jinitiator, version of forms and details of the JVM for Oracle E-Business Suite 11i
    Note: 392793.1 - how to get Forms Oracle Oracle Applications 11i Command Line Version
    Note: 468311.1 - Script to find the Apache, Java, JRE, Forms for Oracle E-Business Suite R12 version

    What purpose are you talking?

    Thank you
    Hussein

  • How to access Mobile Oracle using PL/SQL Server logs?

    I started using Oracle solutions, so I'm a complete newbie.

    I am doing a project which requires to newspapers to mobile devices using the Oracle Mobile Server (integrated into Oracle Database Lite).
    The mobile server has services that I could use or do I interpret log files?

    Thanks in advance for all support!

    Published by: Hugo Zenha on April 15, 2009 07:40

    Details of base for sync history is MOBILEASDMIN. C$ SYNC_HISTORY. This will give you the id of the customer (name), start and end times, success or failure (and error if failure) as well as the total volume of data uploaded and downloaded.

    You can get more details by joining with c$ sync_his_pub_items on session_id, and this gives details of each downloaded table (phase = UPLOAD) regarding the timings and records and the same for the download. Upload tends to be the complete set of tables (records = 0 for no activity), while the download is only active tables and includes a full refresh occurred

    You can get information for the MGP process via mgp_history c$ and c$ mgp_his_clients

    As all the repository data is stored in the database, there are a lot of possibly interesting things if you look through it.

    We use SQL and PL/SQL to make reports on different users with clocks in a loading time and identification of customers having problems

  • Question to load data using sql loader in staging table, and then in the main tables!

    Hello

    I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.

    I have develop a shell script to load the data and it works fine except one thing.

    Here are the details of a data to re-create the problem.

    Staging of the structure of the table in which data will be filled using sql loader

    create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));

    create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));

    create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));

    DATA in the csv file-

    for stg_cmts_data-

    cmts_map_03092015_1.csv

    WNLB-CMTS-01-1. 10.15.0.1

    WNLB-CMTS-02-2 | 10.15.16.1

    WNLB-CMTS-03-3. 10.15.48.1

    WNLB-CMTS-04-4. 10.15.80.1

    WNLB-CMTS-05-5. 10.15.96.1

    for stg_dhcp_data-

    dhcp_map_03092015_1.csv

    DHCP-1-1-1. 10.25.23.10, 25.26.14.01

    DHCP-1-1-2. 56.25.111.25, 100.25.2.01

    DHCP-1-1-3. 25.255.3.01, 89.20.147.258

    DHCP-1-1-4. 10.25.26.36, 200.32.58.69

    DHCP-1-1-5 | 80.25.47.369, 60.258.14.10

    for stg_link_data

    cmts_dhcp_link_map_0309151623_1.csv

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5

    DHCP-1-1-3. WNLB-CMTS-01-1

    DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3

    DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7

    WNLB-DHCP-1-13 | WNLB-CMTS-02-2

    Now, after loading these data in the staging of table I have to fill the main database table

    create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));

    create table link (link_nm varchar2 (50));

    SQL scripts that I created to load data is like.

    coil load_cmts.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_cmts IS SELECT *.

    OF stg_cmts_data;

    TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;

    l_stg_cmts t_stg_cmts;

    l_cmts_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_cmts.

    Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;

    BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST

    LOOP

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;

    IF l_cmts_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_cmts (i) .cmts_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_cmts EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for dhcp


    coil load_dhcp.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_dhcp IS SELECT *.

    OF stg_dhcp_data;

    TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;

    l_stg_dhcp t_stg_dhcp;

    l_dhcp_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_dhcp.

    Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;

    BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST

    LOOP

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;

    IF l_dhcp_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_dhcp (i) .dhcp_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_dhcp EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for link -.

    coil load_link.log

    Set serveroutput on

    DECLARE

    l_cmts_1 VARCHAR2 (4000 CHAR);

    l_cmts_add VARCHAR2 (200 CHAR);

    l_dhcp_cnt NUMBER;

    l_cmts_cnt NUMBER;

    l_link_cnt NUMBER;

    l_add_link_nm VARCHAR2 (200 CHAR);

    BEGIN

    FOR (IN) r

    SELECT dhcp_token, cmts_to_add | ',' cmts_add

    OF stg_link_data

    )

    LOOP

    l_cmts_1: = r.cmts_add;

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = r.dhcp_token;

    IF l_dhcp_cnt = 0 THEN

    DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);

    ON THE OTHER

    While l_cmts_add IS NOT NULL

    LOOP

    l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = TRIM (l_cmts_add);

    SELECT COUNT (1)

    IN l_link_cnt

    LINK

    WHERE link_nm = l_add_link_nm;

    IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN

    INSERT INTO link (link_nm)

    VALUES (l_add_link_nm);

    DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;

    ELSIF l_link_cnt > 0 THEN

    DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);

    ELSIF l_cmts_cnt = 0 then

    DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);

    END IF;

    l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    END LOOP;

    END IF;

    END LOOP;

    COMMIT;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    control files -

    DOWNLOAD THE DATA

    INFILE 'cmts_data.csv '.

    ADD

    IN THE STG_CMTS_DATA TABLE

    When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')

    and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:cmts_token))' cmts_token,

    cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "

    for dhcp.


    DOWNLOAD THE DATA

    INFILE 'dhcp_data.csv '.

    ADD

    IN THE STG_DHCP_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "

    for link -.

    DOWNLOAD THE DATA

    INFILE 'link_data.csv '.

    ADD

    IN THE STG_LINK_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""

    SHELL SCRIPT-

    If [!-d / log]

    then

    Mkdir log

    FI

    If [!-d / finished]

    then

    mkdir makes

    FI

    If [!-d / bad]

    then

    bad mkdir

    FI

    nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    nohup time username/password@SID @load_cmts.sql

    nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_dhcp.sql

    nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_link.sql

    MV *.log. / log

    If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.

    Now that we can here multiple CMTS are associated with unique DHCP.

    So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.

    for example

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2

    Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.

    same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).

    But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.

    Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.

    I use COMMIT in my script also but it only does not help me.

    Run these scripts in your machine let me know if you also get the same behavior I get.

    and please give me a solution I tried many thing from yesterday, but it's always the same.

    It is the table of link log

    link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2

    link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3
    link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3

    link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2
    link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7

    Device not found: wnlb-dhcp-1-13

    IF NEED MORE INFORMATION PLEASE LET ME KNOW

    Thank you

    I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.

    It was the dos2unix error!

    Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)

  • running of SQL question

    Hi expert,


    When I ran after SQL, error message reads "table or view does not exist" pointing to the table "dba_tab_cols" and "dba_all_tables". There is no other question for this statement, because if I changed table "user_tab_cols" and "user_all_tables", it works well.


    declare
    v_old_table DBA_tab_columns.table_name%type;
    v_where Varchar2 (4000);
    Boolean v_first_col: = true;
    type rc is ref cursor;
    c rc;
    v_rowid varchar2 (20);
    Val varchar2 (50): = "Test note";

    Start
    for r in)
    Select
    t.*
    Of
    dba_tab_cols t, dba_all_tables a
    where t.table_name = a.table_name
    and t.data_type like '% CHAR % '.
    and a.owner = 'QA'
    order by t.table_name loop)

    If v_old_table is null then
    v_old_table: = r.table_name;
    end if;

    If v_old_table <>r.table_name then
    v_first_col: = true;

    -dbms_output.put_line ('search' | v_old_table);

    Open c for ' select rowid from ' ' |. ' v_old_table | '" ' || v_where;

    extract the c in v_rowid;
    loop
    When the output c % notfound;
    dbms_output.put_line (' rowid: ' | v_rowid |) "in" | v_old_table);
    extract the c in v_rowid;
    end loop;

    v_old_table: = r.table_name;
    end if;

    If v_first_col then
    v_where: = 'where ' | r.column_name | "as" %' | Val | '%''';
    v_first_col: = false;
    on the other
    v_where: = v_where | "or" | r.column_name | "as" %' | Val | '%''';
    end if;

    end loop;
    end;


    But if I choose these DBA tables in the toad sql Editor, it works well, I am currently using my own credentials, not the administrator credentials. why he get different effects running in these two ways?

    Thank you very much

    >

    Hello

    When I ran after SQL, error message reads "table or view does not exist" pointing to
    Table 'dba_tab_cols' and 'dba_all_tables '. There is no other question for this statement, because

    If I changed table "user_tab_cols" and "user_all_tables", it works well.
    But if I choose these DBA tables in the toad sql Editor, it works well, I am currently using my own
    credentials, not the administrator credentials. why he get different effects running in these two ways?

    You answered your own question - you know that you have the administrator privileges when you
    Open a session under your own credentials - but your id user obviously does TOAD.

    You use SQL * for the query that fails?

    BTW, you do not give us your version of Oracle - you must always tell us what it is

    Please read the forum FAQ and also the thread "sticky" by BluShadow at the top of the list of positions
    on the forum homepage. These forums are an excellent resource - you will get the best out of them if
    you follow the instructions.

    HTH,

    Paul...

    Published by: Paulie July 24, 2012 16:40

  • That means 1z0-117 oracle 11g sql tuning now say it includes v12 addition v11

    Hello

    I did the 1z0-117 sql tuning review once.

    Not too far away.

    I studied under and turned off for a while.

    I anticipate taking in 1 month.

    However, I just noticed that the oracle site says 1z0-117 also said that v12 is also included for consideration:

    Oracle 11g sql tuning.

    It makes no sense at all.

    Roger

    However, I just noticed that the oracle site says 1z0-117 also said that v12 is also included for consideration:

    Oracle 11g sql tuning.

    Unless you are looking for something I'm not, what actually is the 1Z0-117 page says: "validated against: review has been validated against Oracle Database 11g Release 2 version 11.2.0.1.0 and database Oracle 12 c 12.1.0.1.0"

    What they actually mean by it is that someone went through all the issues and and asked the question "is still a relevant issue for the release of 12 c to Oracle?'." "  If they find issues that are not valid because of an update/change, then the question will be removed from review (or changed) so that someone who has used 12 c but not 11 g will not at a disadvantage.

    This is * No * means that Oracle has added questions to the review of the capabilities that were introduced in version 12 c.

Maybe you are looking for