How can i run Following SQL Server Script in to Oracle 10g

I m new in Oracle...
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 MaxKeyId from profilebasicdetail)
Declare TempInsert cursor for select ikeyId--,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,iyear
from profilebasicdetail where isubprofileid=@Copyisubprofileid and itranno=@itranno
open TempInsert
fetch from TempInsert into @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',
iyear,@isubprofileid from profilebasicdetail where ikeyId=@tempkeyId)
fetch next from TempInsert into @tempkeyId
End
End
Regards,
Ajay

YOu want to migrate your MS sql server procedure to Oracle procedure
Before running procedure please set the values of tempkeyId_v variable
Try this
Create or replace Procedure Insert_profilebasicdetail( isubprofileid_v  number, Copyisubprofileid_v number, itranno_v number )
As
     IncKeyId_v  profilebasicdetail.ikeyid%type;
     tempkeyId_v profilebasicdetail.ikeyid%type;
begin
      select nvl((select Max(ikeyId) as MaxKeyId from profilebasicdetail),0) into IncKeyId_v
      from dual ;
     for i in (select ikeyId--,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,iyear
            from profilebasicdetail
            where isubprofileid=Copyisubprofileid_v and itranno=itranno_v)
     loop
          IncKeyId_v = IncKeyId_v + 1;
          Insert into profilebasicdetail
               (ikeyid,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,itranno,iyear,isubprofileid)
               values(select IncKeyId_v,i.iprofileid,i.iquestionid,i.vquestionans,i.cstatusindi,i.dmodifyon,i.imodifyby,'1',
                    i.iyear,isubprofileid_v from profilebasicdetail where ikeyId=tempkeyId_v);
     end loop
End;
/ Regards
Singh
Create or replace Procedure Insert_profilebasicdetail( isubprofileid_v  number, Copyisubprofileid_v number, itranno_v number )
As
     IncKeyId_v  profilebasicdetail.ikeyid%type;
     tempkeyId_v profilebasicdetail.ikeyid%type;
begin
      select nvl((select Max(ikeyId) as MaxKeyId from profilebasicdetail),0) into IncKeyId_v
      from dual ;
     for i in (select ikeyId--,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,iyear
            from profilebasicdetail
            where isubprofileid=Copyisubprofileid_v and itranno=itranno_v)
     loop
          IncKeyId_v = IncKeyId_v + 1;
          Insert into profilebasicdetail
               (ikeyid,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,itranno,iyear,isubprofileid)
               values(select IncKeyId_v,i.iprofileid,i.iquestionid,i.vquestionans,i.cstatusindi,i.dmodifyon,i.imodifyby,'1',
                    i.iyear,isubprofileid_v from profilebasicdetail where ikeyId=tempkeyId_v);
     end loop
End;
/ Regards
Singh

Similar Messages

  • Help me conver following SQL server script in to Oracle Script

    could any one help me to conver following script in to 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 MaxKeyId from profilebasicdetail)
         Declare TempInsert cursor for select ikeyId--,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,iyear
                   from profilebasicdetail where isubprofileid=@Copyisubprofileid and itranno=@itranno
         open TempInsert
         fetch from TempInsert into @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',
                             iyear,@isubprofileid from profilebasicdetail where ikeyId=@tempkeyId)
         fetch next from TempInsert into @tempkeyId
         End
    End
    Regards,
    Ajay

    Thanks Pavan Kumar
    i m new in oracle i don't know anything.
    i run following script on TOAD 9.5 n it gives me error
    could u suggest me how can i run this script means directly on oracle 10g or on TOAD
    if u r at india then could u give me ur mobile number so i can explain my query u clearly.
    Create or Replace Procedure Insert_profilebasicdetail
    p_isubprofileid IN NUMBER,
    p_Copyisubprofileid IN NUMBER,
    p_itranno IN NUMBER,
    As
    v_IncKeyID NUMBER;
    v_tempkeyId NUMBER;
    CURSOR TempInsert IS
    SELECT ikeyid, iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,iyear
    FROM profilebasicdetail
    WHERE isubprofileid=p_Copyisubprofileid and itranno=p_itranno
    Begin
    SELECT MAX(NVL(iKeyID,0))
    INTO v_IncKeyID
    FROM profilebasicdetail;
    FOR r in TempInsert LOOP
    v_IncKeyID = v_InceyID + 1;
    Insert into profilebasicdetail
    (ikeyid,iprofileid,iquestionid,vquestionans,cstatusindi,dmodifyon,imodifyby,itranno,iyear,isubprofileid)
    values(select v_IncKeyId,r.iprofileid,r.iquestionid,r,vquestionans,
    r.cstatusindi,r.dmodifyon,r.imodifyby,'1',
    r.iyear,p_Copyisubprofileid
    from profilebasicdetail
    where ikeyId=r.ikeyId);
    END LOOP;
    EXCEPTION
    WHEN others THEN
    raise;
    End;
    Regards,
    Ajay

  • How to migrate MS SQL Server OLAP data to Oracle 10g OLAP

    Hi,
    Anyone has any idea on whether migration workbench can migrate my MS SQL Server OLAP data to Oracle 10g (with OLAP option) ?
    Best Regards,
    Ian Ho

    Ian,
    What exactly do you mean by SQL*Server OLAP ? Is it just a 'normal' SQL*Server database which is used for an OLAP application ?
    The migration workbench migrates schema objects, triggers, and stored procedures and is not concerned with the application that uses those objects.
    And the same with the Oracle OLAP database. Once the data etc has been moved into the database you can then use it for whichever application you want.
    If you have concerns apart from moving the actual data then please give us more details.
    Regards,
    Mike

  • How can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path?
    Is there some way I can set a "Working folder" in SQL Plus??
    Thanks!
    Tom

    You can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
    scripts.
    I would like to use another directory than the oracle/bin...
    How can I do this ??
    Hello,
    U can do this by this way:
    Save odm_script.sql file to the default Oracle
    directory i.e. Oracle-Home/bin and Run following command
    through SQL Plus.
    SQL>@Script_Name
    I hope this will resolve ur problem.
    Regards,
    Omer Saeed Khan.

  • How Can I Run a SQL Loader Job from Schedular

    How Can I Run a SQL Loader Job from Schedular , So that It Runs every Day.

    Depends on a couple of factors.
    If you are on a UNIX platform, you can create a shell script and schedule it with cron.
    If you are on a Windows platform, you can create a batch file and schedule it with the Windows scheduler.
    Or, if you are on Oracle 9i or 10g, you could use the external table feature instead of SQL*Loader. Then you could write a stored procedure to process the external table and schedule it using the Oracle scheduler (DBMS_JOB). This would probably be my preference.

  • How can I connect to SQL Server CE?

    Hi!
    How can I connect to SQL Server CE ?
    Any idea?
    I found jdbc driver for SQL Server 6.5,7.0,2000.
    But no driver for SQL CE.
    Thanks for any suggestion....

    I am also searching for same answer.
    I wanna choose Access as a db. but I can't find that so I have a no choice to select SQL2000CE though.
    I am stuck in driver problem. I can't find that.
    Should I use Oracle Lite or PointBase?
    I am under a lot of stress... like you've been...
    I wish you find and post that....

  • Migrating from MS SQL Server 2005 database to Oracle 10g

    Hello,
    I wanted the full procedure or steps to Migrate the MS SQL Server 2005 database to Oracle 10g. Is there a known procedure to do this or is there a tool which is used?
    I have not done migration of database from MS SQL Server to Oracle. Any help is appreciated. Thanks a lot for the time.
    Regards,
    RPS

    Wrong forum, go to the database forum!
    cu
    Andreas

  • How to select data from Sql server 2005 database tableinto oracle database table

    Hi,
    I have table text1 in sql server database and text2 in oracle database (11g). Now how to move data from SQL Server table into oracle table. So please help me how to do it.
    Thanks a lot in advance.
    rk
    OS: Windows 7 professional

    Hi,
    you can use export/import wizard and specify sql server as a source and oracle as destination.
    I hope this is helpful.
    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid
    MCSE Data Platform
    MCITP: SQL Server 2008 Administration/Development
    MCSA SQL Server 2012
    MCTS: SQL Server Administration/Development
    MyBlog

  • Using SQL Server Script to create Oracle DB Schema

    Hi,
    I have a SQL Server script which does a few things such as creating databases (after dropping), creating tables etc. Now I want to replicate the SQL Server databases and their tables etc in an Oracle9i DB. How would a SQL Server script compare to an Oracle script? i.e. what differences are there? and how would I have to alter the script to have it work on Oracle?
    As an example, my SQL Server script would look something like this:
    DROP DATABASE test1;
    DROP DATABASE test2;
    CREATE DATABASE test1;
    CREATE DATABASE test2;
    GO;
    USE test1;
    CREATE TABLE Table1 (
    TableOneID INT IDENTITY PRIMARY KEY NOT NULL,
    Name VARCHAR(255) NOT NULL,
    PRIMARY KEY(TableOneID));
    CREATE TABLE Table2 (
    TableTwoID INT IDENTITY NOT NULL,
    TableOneID INT NOT NULL,
    PRIMARY KEY(TableTwoID, TableOneID),
    FOREIGN KEY(TableOneID) REFERENCES Table1(TableOneID));
    USE test2;
    CREATE TABLE ....
    etc...
    thanks!

    Also I think
    CREATE TABLE table1
    ( tableoneid INT PRIMARY KEY NOT NULL
    , name VARCHAR(255) NOT NULL
    , PRIMARY KEY(tableoneid) );should probably be
    CREATE TABLE table1
    ( tableoneid INT CONSTRAINT table1_pk PRIMARY KEY
    , name VARCHAR(255) NOT NULL );otherwise you specify the primary key twice (and PRIMARY KEY implies NOT NULL so the NOT NULL is redundant).
    Then TABLE2 might need to be something like:
    CREATE TABLE table2
    ( tabletwoid INT NOT NULL
    , tableoneid NOT NULL CONSTRAINT table2_table1_fk REFERENCES table1
    , CONSTRAINT table2_pk PRIMARY KEY(tabletwoid, tableoneid) );although the table-level constraint syntax could be used for the foreign keys if it meant less editing of your scripts. The "CONSTRAINT constraintname" clause of constraints is optional but recommended, as otherwise they will get system-generated names like "SYS_C005157". (Note that if you specify the FK inline as part of the column definition you do not need to include a datatype.)
    If the IDENTITY clause causes a sequential value to be assigned as a default, there is no direct equivalent to that in Oracle. The nearest thing would be a row-level BEFORE INSERT trigger.

  • Ways to import an Ms SQL Server 2005 tabel to Oracle 10g

    Hi all
    How can I import an ms sql server 2005 table to Oracel 10g?

    Depends on what's you plan to do. You can try
    SQL Developer Migration Workbench
    http://www.oracle.com/technology/tech/migration//workbench/index_sqldev_omwb.html
    Or use the ODBC method you were trying.

  • How can i load  microsoft SQL Server driver in the classpath ?

    Hi
    i need to have microsoft SQL Server driver in the classpath , how can i do that to run the following code :
    String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    Class.forName(driver);
    with best regards

    Just as information, if you need to load a JDBC driver dynamically without previously knowing its name (meaning you can't add it to the classpath manually in your startup batch), the following will not work:
    // register the SQL driver as necessary
    DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());
    // connect to the DB by using the driver.
    String connString = "my_dbserver:1433;databasename=my_database";
    String strDBConnect = "jdbc:microsoft:sqlserver://" + connString;
    conn = DriverManager.getConnection(strDBConnect, userName, passwd);
    This is because the DriverManager.getConnection checks if the loaded class was loaded by the same class loader than itself. And for dynamic scenarios, you need a new classloader for the new classes.
    Above, the class will be loaded correctly, but getConnection will fail.
    This behaviour costed me several hours while developing a dialog for adding drivers dynamically, until I saw the reason.
    But a solution has been posted in the forums, which goes like this:
    // jdbcLoader is my individual class loader, you can construct it with the driver url
    Class driverClass = Class.forName(driverName, true, jdbcLoader);
    currDriver = (Driver)driverClass.newInstance();
    // problem: classes which were loaded in custom class loader are not recognized by DriverManager. So the following would fail:
    // conn = DriverManager.getConnection(...)
    Properties prop = new Properties();
    prop.setProperty("user", (String)paras.get("youruser");
    prop.setProperty("password", (String)paras.get("yourpwd");
    conn = currDriver.connect((String)paras.get("yourURL", prop); // this one works for all classloaders
    But in your case, it seems to be enough to add the file manually, as was described in previous replies...
    Regards,
    Christian Sy

  • How can I  connect to SQL server database thru local network by using JSP?

    I'm currently doing a project by using JSP..And I need to display record from the SQL Server database in our school's local network. May I know how can I do that? How can I write the code so that I can able to access the SQL Server databsase Throught school's network by using JSP? Please tell me step by step how can I do that. I'm using Tomcat 4.1 as Web Server. And I had J2SE and J2EE installed in my computer.

    first you have to establish a ODBC DSN on your computer,
    that connects to the database...you can do that from your control pannel.
    i assume that the TOMCAT server is residing on your computer....(if the webserver is in other computer then you would have to create a System DSN on the data sources ODBC option in the settings>control pannel of that machine)
    then you can use that DSN name to connect to the data base from the class file....for further assistance on how to create the class that access the tutorials in sun site.
    regards
    G

  • How can I Connect to SQL Server or other RDBMS like Sybase from Form 6i

    I want to connect Connect to SQL Server or other RDBMS like Sybase from Form 6i. I kniow that I need some gateway product but I don't know the name of the product?Can i use some other technology to do the same like client software etc.
    I need this help urgently?

    Check the following link.
    http://www.oracle.com/technology/products/gateways/index.html

  • How can i connect to SQL Server 7.0 on Windons Using JDBC

    How can i connect to Microsoft SQL Server 7.0 on a windows enviroment ?
    in sql server 2000 some jar files are required that is
    What you need to do is actually add all three jar files to your class path individually. There are three jar files that come with this driver the msbase.jar, msutil.jar, and mssqlserver.jar. for sqlQ server 2000.
    now the problem is that i cant find these files on my system. firstly where these files will be located. secondly are they will be used to connect to SQL Server 7.0. thirdly if not what is the procedure.
    My next Problem is that I have Websphere Studio Application Developer. in which their is this facility of Database Webpages its like a wizard which makes automatically beans servlets and JSP but before that you need a Driver Name and and Class Name for to Connect to the Database.
    Can you tell what is the specific Driver Path for the Microsoft SQL Server 7.0 . secondly is this the class which is used to connect to SQL server 7.0 "com.microsoft.jdbc.sqlserver.SQLServerDriver" where can i find this one. for SQL server 7.0.
    please provide some guidance in this regard.

    You can search for the JDBC drivers at, http://industry.java.sun.com/products/jdbc/drivers
    All the three jars that you specified are part of MsSQL Server jdbc driver. You need them (in the classpath) to get connected to the database.
    "com.microsoft.jdbc.sqlserver.SQLServerDriver" is the class in mssqlserver.jar. This is the driver class which will be used to get connected to the database.
    You can search in this forum for writting jdbc code (for Sql Server). If you don't find these jars, give me your e-mail id.
    Sudha

  • Can I run microsoft sql server on my archlinux box?

    One of our office programs is showing its age, and I am looking at upgrading.  Unfortunately, they have changed their approach and it now requires a microsoft sql server.  Is there a way to run that on my arch server, through vmware or something like that?  I don't want to invest in a separate windows box just for this one program.
    No, there isn't an open source alternative.  I've looked.

    timm wrote:it now requires a microsoft sql server.
    You may try using Sybase ASE; for long time (until 6.0), MS SQL Server was just Sybase with MS branding and even today differences are not so big (depending, of course, on specific application's needs). I have never tried such a setup, but connecting to MSSQL with Sybase client libraries works OK, maybe you'd have luck in opposite direction.
    There is a document on migrating apps from MSSQL to ASE; I know this is not the case, but there are some valuable information about differences between those RDBMSs that may help you to decide whether there are chances to succeed or not.

Maybe you are looking for