SQL Server Oracle Migration: semantics of the column

I'm testing a migration to SQL Server 2012 to Oracle 12 c using SQL Developer 4.0.0.13 migration Assistant. The problem that I am facing is that all the generated table creation scripts have CHARACTER semantics for character columns. I wish that the semantic bytes. As the generated tables and columns are several thousand it is not possible to manually change the semantics.

CREATE TABLE account_dod)

account_ID VARCHAR2 (16 CHAR) NOT NULL,

I can't find any possibility to change the semantics when generating. Anyone know of any option that I can set so that the migration wizard will generate all of the columns in the form of BYTES?

Thank you very much

Hello

If you email me, I can provide an extension changed to use unity BYTE CHAR and VARCHAR2 columns.

My email address is my [email protected]

Kind regards

Dermot ONeill

SQL development team

Tags: Database

Similar Questions

  • 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

  • Why is a user with the DBA privilege necessary side SQL Server to migrate?

    Greetings

    Project to migrate a SQL database to Oracle using SQL Developer.

    The docs say that a user with DBA privileges is required in the SQL Server database when you run the migration of the side Oracle.

    Why?

    Why a user with only READ access to SQL Server data would be necessary?

    Thank you very much!!

    -gary

    The DBA privilege at the source database is required because SQL Dev Migration is also collect information from SQL Server system tables, which a normal user is not always possible to query. It is mandatory that the migration is trying to build an Oracle schema which corresponds as much as possible the source database.
    But this requires having become DBA in the foreign database to avoid permission problems. If you SQL Server admin does not want the DBA privilege, you can also do a Migration offline - here the ADMINISTRATOR must run the generated scripts offline in-> Migration-> 3rd capture in the database offline party

  • [Oracle] [ODBC SQL Server driver] String truncation on the right {01004} data

    When importing data from SQL Server 2005 to Oracle 11 g Release2 gateway, I get following error:

    insert into CSDescr select * from CSDescr@sqlserver
    *
    ERROR on line 1:
    ORA-28500: connection between ORACLE and a non-Oracle system has sent this message:
    [Oracle] [ODBC SQL Server driver] string data, right truncation + {01004} +.
    ORA-02063: preceding 2 lines from SQLSERVER

    Oracle database characterset is AL32UTF8
    SQLServer database characterset is SQL_Latin1_General_CP1_CI_AS

    Here is the configuration file for the gateway settings:

    HS_KEEP_REMOTE_COLUMN_SIZE = LOCAL
    HS_NLS_LENGTH_SEMANTICS = CHAR

    I think that the definition of the parameter HS_LANGUAGE must correct the error, but I want to know what should be the value of this setting?

    HS_LANGUAGE must be set to a character set used by the foreign database

    Try: HS_LANGUAGE = american_america. WE8MSWIN1252
    Also specify HS_NLS_NCHAR = UCS2 nvarchars of SQl Server are stored in the UCS2 character set

  • How to solve problems online datamove for 1 of 3 SQL Server 2008 migration.

    I have 3 databases SQL Server 2008 I need to migrate to Oracle 11 g 2 with data only. For all the databases that I can capture, convert and deploy the database target. I can also do this with success a data movement for 2 databases online. The third database runs for about 2 hours and gives a message that the migration completed with success, but not a single line of any of the tables invades. How to understand what failed. I see nothing in the reports with SQL Developer (3.2.20.09). To save time and since I'm only interested in the tables, indexes, and data, after capturing the model, I remove developer QL, views, procedures, functions, sequences and triggers before disguised step.

    Hello

    did you remove the views, procedures, functions, etc. of the model only convert to the database where you have the problem or did you do the same for all three database?

    Did you look at the MIGRLOG table in your repository of migration? It contain useful information?

    Concerning
    Wolfgang

  • equivalent of CLRSplitSting function for sql server Oracle

    Hello friends,

    I have a query in SQL Server - which becomes data.

    Select addl_info_id, sort_seq, code, row_data, addl_info_group_id, group_sort_seq, group_row_data from dbo. CLRSplitString('2406081,2410381,2427008,2430449,2466981,2495083,1586420,2406081,2410381,2427008,2430449,2466981,2495083,1586420','',',') x v join ein_addl_info_v on x.col1 = v.addl_info_id order by sort_seq
    We have same data in oracle too, so I converted the query above to sql to ORACLE like this server...


    Select addl_info_id, sort_seq, code, row_data, addl_info_group_id, group_sort_seq, group_row_data from (with t as)
    Select '2406081,2410381,2427008,2430449,2466981,2495083,1586420,2406081,2410381,2427008,2430449,2466981,2495083,1586420', ",","double str
    Select regexp_substr(str,'[^,]+',1,level) sub_str *) t connect by level < = regexp_count (str, ',') + 1) x *.

    Join cnh_cs_targ_csce_eur_1.ein_addl_info_v v x.sub_str = v.addl_info_id order of sort_seq


    but I don't get all the data. Can someone check if the query oracle above is equivalent to the above SQL query.

    Thank you/Kumar

    Published by: kumar73 on February 15, 2013 08:47

    So your query:

    select  addl_info_id,
            sort_seq,
            code,
            row_data,
            addl_info_group_id,
            group_sort_seq,
            group_row_data
      from      xmltable(
                         'ora:tokenize($str,",")'
                         passing ',2406081,2410381,2427008,2430449,2466981,2495083,1586420,2406081,2410381,2427008,2430449,2466981,2495083,1586420' as "str"
                         columns col1 varchar2(2000) path '.'
                        ) x
            join
                ein_addl_info_v v
              on x.col1 = v.addl_info_id
      order by sort_seq
    /
    

    SY.

  • Selecting a SQL Server 2005 with names of long columns (&gt; 30 characters)

    Hello

    I was able to put in place a db Oracle 11.2.0.1 link to SQL Server 2005 using DG4ODBC.

    My problem is that some column names in Sql Server are more than 30 tanks and trying to select gives me the ORA-00972: identifier is a mistake too long.

    If I omit those select columns succeeds.
    I know that I can create a view in sql server and query it instead of the original table, but I was wondering if there is a way to overcome it with sql.

    My selection looks like this:
    select "good_column_name" from sometable@sqlserver_dblink -- this works
    select "good_column_name","very_long_column_name>30 chars" from sometable@sqlserver_dblink -- ORA-00972
    Thank you

    No there is no other way then using a view in SQl Server and select in the view rather than the table. The reason is that the Oracle database has a restriction that the column names must be 30 or fewer characters.

  • Problem with SQL Server 2008 migration

    Hello

    I am having trouble capturing SQL Server (Express 2008) tables/views/data for Migration to Oracle 11. I was able to connect to the source (SQL Server 2008 Express) and databases of destination (Oracle 11) on the same server (Windows Vista 32 bit). However, when I select objects SQl server (tables or views) and click on "Capture Microsoft SQL Server" or "Table of Capture" etc, nothing happens... No message and the tool is just sitting there. The models 'captured' is empty... Could someone please help? Where can I find the error logs? I followed the instructions as described in the help text and also found that some other people were able to run on SQL Server. I wonder what might be different about my situation.

    Thank you!

    BK

    Hello

    SQL Developer Migration Workbench does not yet support the migration to SQL Server 2008.

    See http://www.oracle.com/technology/tech/migration/workbench/pdf/migrationdatasheet_15.pdf

    This data sheet lists only the versions of SQL Server 7.0, 2000 and 2005.

    Maybe the next Metalink note allows more:

    Note 393760.1: how to migrate databases non-Oracle, for which an Option of Migration Workbench is not available

    Kind regards
    Wolfgang

  • Question to sql server oracle DBlink

    Hello

    I followed steps below

    1 connection configured and tested ODBC connection is successful and ODBC calls SQLT.

    2. I added under entry in the C:\app\product\11.2.0\dbhome_1\hs\admin\initdg4odbc.ora file

    HS_FDS_CONNECT_INFO = SQLT

    HS_FDS_TRACE_LEVEL = OFF

    3. turn under entry in the tnsnames.ora file

    SQLSERVER =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = tcp (PORT = 1551))(HOST=mylocalhostname))

    (CONNECT_DATA = (SID = dg4odbc))

    (HS = OK)

    )

    * I also tried SID = SQLT in tnsnames file

    4. added under entry in the listner

    SID_LIST_SQLSERVER =

    (SID_LIST =

    (SID_DESC =

    (ORACLE_HOME = C:\app\product\11.2.0\dbhome_1)

    (SID_NAME = dg4odbc)

    (PROGRAM = dg4odbc)

    )

    )

    ADR_BASE_SQLSERVER = directory

    SQLSERVER =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP (PORT = 1551))(HOST = mylocalhostname))

    )

    * I also tried SID_NAME = SQLT file listner

    5 lsnrctl reload

    6 created db link

    CREATE SQLSERVER1 LINK DATABASE to CONNECT to 'MyUser' IDENTIFIED BY 'Mypassword' USING 'SQLSERVER ';

    but still I am getting below error.

    ERROR on line 1:

    ORA-28545: error diagnosed by Net8 when connecting to an agent

    Cannot retrieve the text of the message NETWORK/NCR 65535

    ORA-02063: preceding 2 lines of *.

    I also followed link below

    https://Oracle-base.com/articles/Misc/heterogeneous-services-generic-connectivity

    even that also does not work. kindly help me

    Hello, it seems that listener or HS is not allowed.

    Check the status of the listener, then try with HS_FDS_CONNECT_INFO =:/ / in initdg4odbc.ora

    Do

    c: > lsnrctl stop SQL SERVER

    c: > lsnrctl start SQLSERVER

    run

    c: > lsnrctl status SQLSERVER

    and after release.

    This OPINION score could be useful 234517.1.

    Concerning

  • Display SQL Server Oracle data error

    Dear friends,

    I use Oracle10g XE.

    I made a link to view or insert data into Oracle's SQL Server database.

    I did all the things with the help of the link below.

    http://www.databasejournal.com/features/Oracle/article.php/3442661/making-a-connection-from-Oracle-to-SQL-Server.htm

    Everything worked well. but when I run query below

    Select "EmployeeNo" in hrtattendance@mysqlserverdsn

    It gives an error that is mentioned below

    ERROR on line 1:

    ORA-28545: error diagnosed by Net8 when connecting to an agent

    Impossible to reteieve text of MESSAGE NETWORK/NCR 65535

    ORA-02063: preceding 2 lines of MYSQLSERVERDSN

    Help, please. I will be grateful.

    Kind regards

    Hi Klaus,

    Now it works after

    run

    lsnrctl start listenermysqlserverdsn again.

    This means that it is not auto-start. Anywayz it's done. Thanks a lot for your time, help and support.

    I am very grateful to you.

    Thank you and best regards,

  • Update SQL Server Oracle Table

    Hello

    I have a doubt, Im working with a database in oracle 10g and found a trouble trying to update a SQL Server database with a BPM system that retrieve data from the Oracle database... my question is...

    How can I update the SQL database every 8 hours with the new information inserted into the Oracle database... I tried using OpenQuery but shows the AMT ORA-12514: listener

    I'll apreciate any help

    ORA-12514 is one of the most common misconfiguration problems reported on the web. Go to google and you will find 33 800 hits. Thousands of containing the solution to your problem.

    Troubleshooting and the solution is also written on a large number of times on metalink.

    But I have to say to transfer data from Oracle to SQL Server makes no sense. You already have a copy of data in a location secured with the data integrity guaranteed. Instead of move... buy a report generator and work with it in place.

  • SQL Server 2005 unattended install using the script fails on Windows 2003 Cluster

    We strive to perform the installation without SQL Server 2005 via the script assistance, but the installation fails on Windows 2003 Cluster, we use Windows 2008 with HyperV running a DC with two nodes (all Win 2003). Script is...

    Start/wait setup.exe/qb VS = INSTALLVS SQLTEST = SQL_Engine INSTANCENAME = SQL123 ADDLOCAL = SQL_Engine ADDNODE = sqlnode-1, sqlnode-2 GROUP = SQL1 IP = 192.168.1.85, SQLNetwork ADMINPASSWORD = Windows8! SAPWD = Windows8! INSTALLSQLDIR=%ProgramFiles%\Microsoft SQL Server\ INSTALLSQLDATADIR = G:\SQLDATADIR\ SQLACCOUNT = SQLPASSWORD lab\sql_svc = Windows8! AGTACCOUNT = lab\sql_svc = Windows8 AGTPASSWORD! SQLBROWSERACCOUNT = SQLBROWSERPASSWORD = Windows8 lab\sql_svc! SQLCLUSTERGROUP = "lab\sql_grp" AGTCLUSTERGROUP = "lab\sql_grp" FTSCLUSTERGROUP = "lab\sql_grp" ERRORREPORTING = 1 SQMREPORTING = 1 SQLCOLLATION = SQL_Latin1_General_CP1_CI_AS

    Errors on the nodes:

    SQLSetup0008_SQLNODE1_Core (Local)

     Running: InstallSqlAction to the: 4/14/2012 22:56:39

    Installation: sql on target: SQLNODE1

    Waiting for remote setup (s) to prepare

    Remote Setup (s) is ready

    Problem of determining the State of the virtual server for the package: '1' because of the exception of data store:

    Source the name of the file: datastore\cachedpropertycollection.cpp

    Compiler timestamp: Fri 29 Jul 01:13:49 2005

    Function name: CachedPropertyCollection::findProperty

    The source line number: 63

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

    Could not find the property 'VsDataPath' {'PackageIdStateScope', ' ', '1'} in the cache.

    Source the name of the file: datastore\packageidstatescopecollector.cpp

    Compiler timestamp: Wed Aug 24 13:40:04 2005

    Function name: PackageIdStateScopeCollector::collectProperty

    The source line number: 115

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

    dataPathValue is empty

    Cluster functionality detected: SQL_Engine

    Loaded DLL:C:\Program SQL Server\90\Setup Bootstrap\sqlsval.dll Version: 2005.90.1399.0

    Source the name of the file: datastore\cachedpropertycollection.cpp

    Compiler timestamp: Fri 29 Jul 01:13:49 2005

    Function name: CachedPropertyCollection::findProperty

    The source line number: 130

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

    Unable to find property 'IPResources' {"VirtualServerInfo", "", "SQLTEST"} in the cache

    Source the name of the file: datastore\cachedpropertycollection.cpp

    Compiler timestamp: Fri 29 Jul 01:13:49 2005

    Function name: VirtualServerInfo.IPResources

    The source line number: 113

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

    Could not collect the property 'IPResources' {"VirtualServerInfo", "", "SQLTEST"}

    Transact package threw an exception.

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: sqlchaining\highlyavailablepackage.cpp

    Compiler timestamp: Mon Aug 29 01:18:42 2005

    Function name: sqls::HighlyAvailablePackage:manageVsResources

    The source line number: 490

    ---- Context -----------------------------------------------

    SQLs::HighlyAvailablePackage:preInstall

    SQLs::HighlyAvailablePackage:manageVsResources

    m_dataDirPath is empty

    Cluster API threw an exception during operations of virtualization.

    Package first notify: 13

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: sqlchaining\highlyavailablepackage.cpp

    Compiler timestamp: Mon Aug 29 01:18:42 2005

    Function name: sqls::HighlyAvailablePackage:manageVsResources

    The source line number: 490

    ---- Context -----------------------------------------------

    SQLs::HighlyAvailablePackage:preInstall

    SQLs::HighlyAvailablePackage:manageVsResources

    m_dataDirPath is empty

    Cluster API threw an exception during operations of virtualization.

    SQLSetup0008_SQLNODE2_Core (Local)

     

    Local configuration can complement

    Running: InstallSqlAction at: 4/2012/14 23:23:57

    Installation: sql on target: SQLNODE2

    Informs the package is ready to start: 0

    Waiting for notification start installation

    Local configuration can begin installation

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: remotepackageengine\remotepackageinstallersynch.cpp

    Compiler timestamp: Wed Aug 24 13:40:17 2005

    Function name: sqls::RemotePackageInstallerSynch:preInstall

    The source line number: 128

    ---- Context -----------------------------------------------

    SQLs::InstallPackageAction: perform

    SQLs::RemotePackageInstallerSynch:preInstall

    Abandonment of the package: "sql", due to an error from the configuration of the host: 13

    Notify all ready to commit: 13

    Notify all ready to put end to: 13

    Waiting for notification complete installation

    Local configuration can complement

    Packaging return code: 13

    Complete: InstallSqlAction at: 4/2012/14 23:23:59, returned false

    Error: The 'InstallSqlAction' Action failed during execution.  Error during execution information:

    Target collection includes the local machine.

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

    Error: The 'UninstallForRS2000Action' Action failed during execution.  Error during execution information:

    Action: "UninstallForRS2000Action" will be marked as failed due to the following condition:

    The condition 'rs has been correctly upgraded level.' returned false.

    Package installation: 'patchRS2000' failed due to a precondition.

    Running: ReportChainingResults at: 4/2012/14 23:24:1

    Error: Action "ReportChainingResults" threw an exception during execution.

    One or more packages could not be installed. See logs for details of the error. : 13

    Error code: 0x8007000d (13)

    Windows error text: these data are incorrect.

    Source the name of the file: sqlchaining\sqlchainingactions.cpp

    Compiler timestamp: 1 Thu Sep 22:23:05 2005

    Name of the function: sqls::ReportChainingResults: perform

    The source line number: 3097

    Please notify.

    Assani

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums. You can follow the link to your question:

    http://TechNet.Microsoft.com/en-us/WindowsServer/bb512923

    Hope this information helps.

  • Problems installing SQL Server Express 2008 R2 on the laptop

    I tried to install sql server express 2008 R2 on my Dell Inspiron 1525 laptop running Windows 7 and I'm not able to get SQL Agent to start and I do not have the SQL Management Studio program as an option under all programs. What I am doing wrong?

    Hello

    You send messages in the Forum Installation in Vista

    For the best results for your questions, please repost in the SQL Server Express Forum.

    http://social.technet.Microsoft.com/forums/en/SQLExpress/threads

    See you soon.

  • SQL help - Need help to rotate the columns to rows

    I have a HughesNet to divide the columns into multiple lines. For example:

    EMP_DEPT

    ROWID empid1 ename1 empid2 ename2 empid2 ename2 empid4 ename4 dept4 dep3 dep2 dept1
    100001 1 'SCOTT' 10 2 'DAVE' 20 3 10 4 20 SMITH "MILLER"
    100002 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER' 20

    Note: EMP_DEPT do not always have information about the 4 employees settled for example in info only 3 employees rank 2 are there

    I need to convert and insert it into the EMPLOYEE table as follows:

    EMPLOYEE

    EmpID ename dept
    1 SCOTT 10
    2 20 DAVE
    3 MILLER 10
    4 SMITH 20

    1 SCOTT 10
    2 20 DAVE
    3 MILLER 20

    Thank you
    KeV

    Hey Kevin,

    Here's one way:

    WITH t AS (
      SELECT level i FROM dual CONNECT BY level <= 4
    )
    SELECT enty_type, enty_name, enty_id
    FROM (
      SELECT case when mod(t.i,2) = 0 then 'DEPARTMENT'
                  else 'EMPLOYEE'
             end as enty_type
           , case t.i
               when 1 then emp_name1
               when 2 then dept_name1
               when 3 then emp_name2
               when 4 then dept_name2
             end as enty_name
           , case t.i
               when 1 then emp_id1
               when 2 then dept_id1
               when 3 then emp_id2
               when 4 then dept_id2
             end as enty_id
      FROM emp
           CROSS JOIN t
    )
    WHERE enty_id IS NOT NULL
    ;
    

    Another using the MODEL clause:

    SELECT *
    FROM (
      SELECT enty_id, enty_name, enty_type
      FROM emp
      MODEL
      RETURN UPDATED ROWS
      PARTITION BY (pk)
      DIMENSION BY (0 i)
      MEASURES(
         emp_id1, emp_name1
       , emp_id2, emp_name2
       , dept_id1, dept_name1
       , dept_id2, dept_name2
       , cast(null as number(10)) enty_id
       , cast(null as varchar2(200)) enty_name
       , cast(null as varchar2(30)) enty_type
      )
      RULES (
         enty_type[1] = 'EMPLOYEE' , enty_id[1] = emp_id1[0], enty_name[1] = emp_name1[0]
       , enty_type[2] = 'EMPLOYEE' , enty_id[2] = emp_id2[0], enty_name[2] = emp_name2[0]
       , enty_type[3] = 'DEPARTMENT' , enty_id[3] = dept_id1[0], enty_name[3] = dept_name1[0]
       , enty_type[4] = 'DEPARTMENT' , enty_id[4] = dept_id2[0], enty_name[4] = dept_name2[0]
      )
    )
    WHERE enty_id IS NOT NULL
    ;
    

    Published by: odie_63 on 8 Dec. 2010 21:00

  • Help me convert after the SQL Server Oracle script script

    could someone help me conversion following script in oracle script




    Create procedure Insert_profilebasicdetail
    (
    @isubprofileid as int,
    @Copyisubprofileid as int,
    @itranno as int,
    )
    As
    Begin

    Declare @IncKeyId as int
    Declare @tempkeyId as int
    Set @IncKeyId = (select isNull (Max (ikeyId), 0) as profilebasicdetail MaxKeyId)

    Declare TempInsert cursor for select ikeyId - iprofileid, iquestionid, vquestionans, cstatusindi, dmodifyon, imodifyby, iyear
    of profilebasicdetail where isubprofileid=@Copyisubprofileid and itranno=@itranno
    Open TempInsert
    the extraction of TempInsert in @tempkeyId
    While @fetch_Status = 0
    Begin

    Set @IncKeyId = @IncKeyId + 1

    Insert into profilebasicdetail
    (ikeyid, iprofileid, iquestionid, vquestionans, cstatusindi, dmodifyon, imodifyby, itranno, iyear, isubprofileid)
    values (select @IncKeyId, iprofileid, iquestionid, vquestionans, cstatusindi, dmodifyon, imodifyby, '1',
    profilebasicdetail iYear,@isubprofileid where ikeyId=@tempkeyId)

    extract the following TempInsert in @tempkeyId
    End

    End





    Kind regards
    Ajay

    You always seem to be missing the semicolon (;) in the end of your CURSOR, as Aman has pointed out in his last message.

    CURSOR TempInsert IS
      SELECT ikeyid, iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,iyear
        FROM profilebasicdetail
       WHERE isubprofileid=723 and itranno=58*;*
    

    (Note that the * are simply to point out where the change needs to be done.) You don't want those in your actual code)

    Justin

Maybe you are looking for