How to convert SQL server stored procedures to Oracle 11g

Hi Experts,
In SQL server 30 stored procedures are there how to convert all the stored procedure
from SQL server to Oracle 11g.
Please help me,
Thanks.

ramya_162 wrote:
In SQL server 30 stored procedures are there how to convert all the stored procedure
from SQL server to Oracle 11g.
The single most fundamental concept you need to understand (grok in its fullness) is:
ORACLE IS NOT SQL-SERVER
There is very little, to NOTHING, in common between T-SQL (a language extension to SQL) and PL/SQL (integration of SQL with the language Ada, part of ALGOL family of languages that includes Pascal and C++).
So taking a T-SQL procedure and porting it as is to PL/SQL is plain stupid.
Why?
Oracle sucks at trying to be SQL-Server.
So how do you migrate from SQL-Server to Oracle?
By taking the REQUIREMENTS that the T-SQL procedures address, and addressing these requirements using Oracle SQL and PL/SQL.

Similar Messages

  • Converting SQL Server Stored Procedure to Oracle

    Hi there,
    I tried to use SwisSQL to convert my SQL Server stored procedure to Orcale without much success.
    Is there anyone who could help me out with this?
    My SQL Server Stored Procedure is:
    CREATE PROCEDURE [dbo].[SP_BackgroundCheckRequest]
         --MASTER Table
         @MASTER_ID int,
         @PERSONNEL_ID int = NULL,
    @DATE_OF_BIRTH datetime = NULL,
         @GENDER varchar(1) = NULL,
         @COUNTRY_OF_BIRTH varchar(3) = NULL,
    @TOWN_OF_BIRTH varchar(100) = NULL,
         @STATE_OF_BIRTH varchar(50) = NULL,
         @CHECK_CATEGORY varchar(10) = NULL,
         @CHECK_TYPE varchar(10) = NULL,
         @PRIORITY varchar(10) = NULL,
         @PRIORITY_REASON varchar(100) = NULL,
         @SCREENING_LEVEL nchar(1) = NULL,
         @POSITION nchar(50) = NULL,
         @REQUEST_SOURCE varchar(60) = NULL,
         --NAME_TYPE Table
         @NAME_TYPE varchar(5) = NULL,
         @FAMILY_NAME varchar(50) = NULL,
         @FIRST_NAME varchar(50) = NULL,
         @MIDDLE_NAME varchar(50) = NULL,
         @TITLE varchar(10) = NULL,
         @PREFFERED_NAME varchar(40) = NULL,
         @PREVIOUS_NAME varchar(140) = NULL,
         --ADDRESS_TYPE Table
         @ADDRESS_TYPE varchar(10) = NULL,
         @ADDRESS_LINE_1 varchar(30) = NULL,
         @ADDRESS_LINE_2 varchar(30) = NULL,
         @ADDRESS_LINE_3 varchar(30) = NULL,
         @COUNTRY varchar(3) = NULL,
         @SUBURB varchar(50) = NULL,
         @STATE varchar(50) = NULL,
         @POSTCODE varchar(15) = NULL,
         @START_DATE varchar(10) = NULL,
         @END_DATE varchar(10) = NULL,
         --LICENSE_TYPE Table
         @LICENSE_TYPE varchar(5) = NULL,
         @LICENSE_AGENCY varchar(15) = NULL,
         @LICENSE_NUMBER varchar(100) = NULL,
         @LICENSE_SIGHTED varchar(1) = NULL,
         --PHONE_TYPE Table
         @TELEPHONE_TYPE varchar(5) = NULL,
         @TELEPHONE_NUMBER varchar(20) = NULL,
         @MOBILE_TYPE varchar(5) = NULL,
         @MOBILE_NUMBER varchar(20) = NULL,
         @EXTENSION_TYPE varchar(5) = NULL,
         @EXTENSION_NUMBER varchar(20) = NULL,
         --PASSPORT_TYPE Table
         @PASSPORT_TYPE varchar(5) = NULL,
         @PASSPORT_NUMBER varchar(50) = NULL,
         @PASSPORT_COUNTRY varchar(3) = NULL,
         @PASSPORT_SIGHTED varchar(1) = NULL
    AS
    BEGIN TRANSACTION
    INSERT into MASTER (MASTER_ID, PERSONNEL_ID, DATE_OF_BIRTH, GENDER, COUNTRY_OF_BIRTH,
         TOWN_OF_BIRTH, STATE_OF_BIRTH, CHECK_CATEGORY, CHECK_TYPE, PRIORITY, PRIORITY_REASON,
         SCREENING_LEVEL, POSITION, REQUEST_SOURCE)
         VALUES (@MASTER_ID, @PERSONNEL_ID, @DATE_OF_BIRTH, @GENDER, @COUNTRY_OF_BIRTH,
         @TOWN_OF_BIRTH, @STATE_OF_BIRTH, @CHECK_CATEGORY, @CHECK_TYPE, @PRIORITY, @PRIORITY_REASON,
         @SCREENING_LEVEL, @POSITION, @REQUEST_SOURCE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into MASTER table!', 16, 1)
         RETURN
    END
    INSERT into NAME_TYPE (MASTER_ID,NAME_TYPE,FAMILY_NAME,FIRST_NAME,MIDDLE_NAME,TITLE)
         VALUES (@MASTER_ID,@NAME_TYPE,@FAMILY_NAME,@FIRST_NAME,@MIDDLE_NAME,@TITLE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into NAME_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into ADDRESS_TYPE (MASTER_ID,TYPE,ADDRESS_LINE_1,ADDRESS_LINE_2,ADDRESS_LINE_3,
              COUNTRY,SUBURB,STATE,POSTCODE,START_DATE,END_DATE)
         VALUES (@MASTER_ID,@ADDRESS_TYPE,@ADDRESS_LINE_1,@ADDRESS_LINE_2,@ADDRESS_LINE_3,
              @COUNTRY,@SUBURB,@STATE,@POSTCODE,@START_DATE,@END_DATE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into ADDRESS_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into LICENSE_TYPE (MASTER_ID,TYPE,AGENCY,NUMBER,SIGHTED_YN)
         VALUES (@MASTER_ID,@LICENSE_TYPE,@LICENSE_AGENCY,@LICENSE_NUMBER,@LICENSE_SIGHTED)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into LICENSE_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
         VALUES (@MASTER_ID,@TELEPHONE_TYPE,@TELEPHONE_NUMBER)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting Telephone number into PHONE_TYPE table!', 16, 1)
         RETURN
    END
    IF ((@MOBILE_TYPE <> NULL) AND (@MOBILE_NUMBER <> NULL))
    BEGIN
         INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
              VALUES (@MASTER_ID,@MOBILE_TYPE,@MOBILE_NUMBER)
         IF @@ERROR <> 0
         BEGIN
              ROLLBACK
              RAISERROR ('Error inserting Mobile number into PHONE_TYPE table!', 16, 1)
              RETURN
         END
    END
    IF ((@EXTENSION_TYPE <> NULL) AND (@EXTENSION_NUMBER <> NULL))
    BEGIN
         INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
              VALUES (@MASTER_ID,@EXTENSION_TYPE,@EXTENSION_NUMBER)
         IF @@ERROR <> 0
         BEGIN
              ROLLBACK
              RAISERROR ('Error inserting Extension number into PHONE_TYPE table!', 16, 1)
              RETURN
         END
    END
    INSERT into PASSPORT_TYPE (MASTER_ID,NUMBER,COUNTRY,SIGHTED_YN)
         VALUES (@MASTER_ID,@PASSPORT_NUMBER,@PASSPORT_COUNTRY,@PASSPORT_SIGHTED)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into PASSPORT_TYPE table!', 16, 1)
         RETURN
    END
    COMMIT

    First, a basic concept. That also illustrates how different Oracle is (and PL/SQL) from SQL-Server (and T-SQL).
    PL/SQL integrates two different languages. The PL language. The SQL language. It allows you to code SQL source code natively inside the PL language. The PL compiler is clever enough to do the rest - make calls to the SQL engine to create SQL cursors, bind PL variable values to bind variables in the SQL code. Etc.
    PL is a "proper" programming language. It is much like Pascal (it is based on Ada, a close family member of Pascal). It is nothing at all like T-SQL.
    Okay, now for the very basic rule for Oracle development.
    Maximize SQL. This means using the SQL language to crunch data. It is the "closest" to the data. It is designed and optimised for dealing with data. Do your data processing using SQL.
    Minimize PL/SQL. This means using the PL language not to crunch data, but to provide the conditional logic. Implement business rules. And then have the SQL language crunch the data as the data processing language.
    Attempting to directly translate T-SQL code into PL/SQL is flawed. It is like trying to make coffee with teabags. Yeah, the tea may have caffeine it, but it is not coffee.
    To do what that T-SQL script does, insert a row into a table, a typical PL/SQL equivalent will look as follows:
    create or replace procedure InsertMaster( masterRow master%rowtype ) authid definer is
    .. types and variables declared here
    begin
      -- masterRow is a record structure that matches the actual MASTER table
      .. apply business rules and validation to the data.. raising user exceptions as needed
      -- e.g. the POSITION column must be upper case
      masterRow.position := upper(masterRow.position);
      -- after the business logic and data validation we can add the row to the table
      -- (PL will make the INSERT call to the SQL engine)
      insert into master values masterRow;
    end;No commit. The caller does the business transaction. It needs to decide when to commit to maintain the integrity of the data in the database. It may need to do several more calls, before committing.
    With this approach, we can give the application schema (the caller) execute privs on this procedure. This procedure is defined with definer rights. This means it runs with the privs of owner of that procedure and MASTER table. It is trusted code. It does all the correct stuff to add a valid and checked row to the MASTER table. So we give the app schema execute privs on the procedure and no insert priv on the MASTER table.
    The only way the caller can add row to the MASTER table is via this trusted procedure of ours.
    And this is a typical approach in Oracle - using the PL/SQL (both PL language and SQL language) code to create an interface to a logical database in Oracle. Abstracting the complexities of SQL from the caller. Moving business and validation into PL. Allowing us the flexibility of modifying business and validation logic, without touching a single byte of caller/client code. Allowing us to manage and tune SQL performance without dealing with (badly designed and coded) SQL from a client - as the SQL resides in PL/SQL packages and procedures and functions.

  • How to call a sql server stored procedure from oracle

    Hi all,
    Please anybody tell me how to call a sql server stored procedure from oracle.
    I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
    "dbo"."CreateReceipt"@hsa
    where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
    my database version is 10g
    Please help me how can i call it... I need to pass some parameters too to the SP
    thanking you

    hi,
    thank you for the response.
    when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
    my code is,
    declare
    c INTEGER;
    nr INTEGER;
    begin
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
    DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
    nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
    end;
    Create_Receipt is the sp which requires two parameters.
    please give me a solution
    thanking you
    sreejith

  • How to Execute SQL Server stored procedure through SQL Developer?

    Hi,
    I was successful in connecting SQL Server database using SQL Developer. I am able to see all the objects such Tables,Views & Procedure and also can query data using sql Query. But when it comes to executing procedure there's no option to achieve this. I tried "Exec |<Execute Procedure> Proc_name" but unfortunately both statement threw Errors.
    Please suggest about other alternates.
    Thanks in Advance,
    AP

    Hi,
    I was successful in connecting SQL Server database using SQL Developer. I am able to see all the objects such Tables,Views & Procedure and also can query data using sql Query. But when it comes to executing procedure there's no option to achieve this. I tried "Exec |<Execute Procedure> Proc_name" but unfortunately both statement threw Errors.
    Please suggest about other alternates.
    Thanks in Advance,
    AP

  • SQL Server Stored Procedure to Oracle

    Hi All,
    I have a store procedure in SQL Server(2005 onwards)...I need to convert that in Oracle. As I am new to Oracle. Please guide me.
    I have two tables MetaDatabase and MetaEntity. The store procedure loads the MetaDatabase and MetaEntity based on MetaDatabase...As of now it is hardcoded in SP...
    MetaDatabase
    CREATE TABLE MetaDatabase
    ID INT NOT NULL,
    Alias VARCHAR(64) NOT NULL,
    VersionMajor smallint NOT NULL,
    VersionMinor smallint NOT NULL,
    VersionRevision smallint
    INSERT INTO MetaDatabase VALUES(1, 'DB1', 1, 1, 1);
    INSERT INTO MetaDatabase VALUES(2, 'DB1', 1, 1, 2);
    INSERT INTO MetaDatabase VALUES(3, 'DB2', 1, 2, 1);
    MetaEntity
    CREATE TABLE MetaEntity
    ID INT NOT NULL,
    MetaDatabaseID INT NOT NULL,
    Name VARCHAR(64) NOT NULL
    INSERT INTO MetaEntity VALUES(1, 1, 'TABLE11');
    INSERT INTO MetaEntity VALUES(2, 1, 'TABLE12');
    INSERT INTO MetaEntity VALUES(3, 2, 'TABLE21');
    INSERT INTO MetaEntity VALUES(4, 2, 'TABLE22');
    INSERT INTO MetaEntity VALUES(5, 3, 'TABLE31');
    INSERT INTO MetaEntity VALUES(6, 3, 'TABLE32');Here is the SP as of now I am loading 2 MetaDatabase out of 3.
    CREATE Procedure myProc
    AS
         DECLARE @tmpDictionaries  TABLE ( Alias varchar(64),
                                          VersionMajor smallint,
                                          VersionMinor smallint,
                                          VersionRevision smallint )
         DECLARE @tmpMetaDatabase  TABLE ( ID int PRIMARY KEY )
         DECLARE @tmpMetaEntity    TABLE ( ID int PRIMARY KEY )
        /* Load these 2 MetaDatabase */
        INSERT INTO @tmpDictionaries (Alias,VersionMajor,VersionMinor,VersionRevision) VALUES ('DB1',1,1,1)
        INSERT INTO @tmpDictionaries (Alias,VersionMajor,VersionMinor,VersionRevision) VALUES ('DB2',1,2,1)
        /* Make sure that all passed in dictionaries actually exist */
        IF (SELECT COUNT(*) FROM @tmpDictionaries t WHERE NOT EXISTS(SELECT ID FROM MetaDatabase md WHERE md.Alias=t.Alias AND md.VersionMajor=t.VersionMajor AND md.VersionMinor=t.VersionMinor AND md.VersionRevision=t.VersionRevision)) > 0 BEGIN
          RAISERROR ('Not all dictionaries requested exist', 16, 1) WITH SETERROR
          RETURN
        END
        /* remember the MetaDatabase records */
        INSERT INTO @tmpMetaDatabase    SELECT ID FROM MetaDatabase md  WHERE EXISTS(SELECT *  FROM @tmpDictionaries t  WHERE md.Alias=t.Alias AND md.VersionMajor=t.VersionMajor AND md.VersionMinor=t.VersionMinor AND md.VersionRevision=t.VersionRevision)
        /* remember all related MetaEntity records */
        INSERT INTO @tmpMetaEntity      SELECT ID FROM MetaEntity me    WHERE EXISTS(SELECT ID FROM @tmpMetaDatabase t  WHERE t.ID=me.MetaDatabaseID)
        /* return all MetaDatabase */
        SELECT md.* FROM MetaDatabase md WHERE EXISTS(SELECT ID FROM @tmpMetaDatabase WHERE ID=md.ID)
        /* return all related MetaEntity records */
        SELECT me.* FROM MetaEntity me WHERE EXISTS(SELECT ID FROM @tmpMetaEntity WHERE ID=me.ID)Here is the output I get..It returns 2 resultsets one for each SELECT in SP.
    EXEC myProc
    1     DB1     1     1     1
    3     DB2     1     2     1
    1     1     TABLE11
    2     1     TABLE12
    5     3     TABLE31
    6     3     TABLE32I need same in Oracle..where I can parse the resultset returned from SP. Any help will be greatly appreciated.
    Edited by: [email protected] on Jun 10, 2010 2:34 PM

    [email protected] wrote:
    I have a store procedure in SQL Server(2005 onwards)...I need to convert that in Oracle. Not really a good idea - as T-SQL has very little in common with PL/SQL.
    PL/SQL is two languages:
    - a procedural language called Programming Logic - which has its roots in the Ada and Pascal family of procedural languages.
    - the SQL language.
    These are tightly integrated to allow you to use SQL natively inside PL. In other words, you can mix SQL source inside PL source code, reference PL variables in SQL source and the PL compiler and run-time is clever enough to know what code is PL and what code is SQL and how to glue the SQL into the PL.
    Bottom line - PL is not a macro/scripting language for running SQL. It is equivalent to to Java, C#, Visual Basic and others ito features and how one designs and uses the language.
    So your question of how to covert a T-SQL proc to PL/SQL is equivalent of asking how to change a T-SQL proc to C/C++ using the Pro*C (embedded SQL) compiler.
    So please - forget any notion that PL/SQL is like T-SQL. Or even that Oracle is at all like SQL-Server. Oracle is "+that darn good+" not because it emulates SQL-Server.. but because it is not like SQL-Server. It is the differences in the feature set of Oracle from SQL-Server that sells Oracle.
    I need same in Oracle..where I can parse the resultset returned from SP. Any help will be greatly appreciated.Oracle does not work this way. There are also no "result sets" in terms of a temporary data set that's created in the server and stored in memory. This type of approach does not scale if you have a 1000 users all running the same application code and all attempting to create "result sets" in server memory at the same time.
    The norm for client-server code using PL/SQL as the server side interface into database data, is for the PL/SQL code to create a SQL cursor and return a pointer (called a reference cursor handle or simple a reference cursor) to the client.
    The client (e.g. VB/Java/C#/Delphi/etc) can then fetch data from the SQL cursor (a "program" in server memory that finds and retrieves the relevant rows).
    To understand and "enjoy" Oracle, one needs to empty one's cup of SQL-Server/DB2/Informix/whatever in order to fill that cup with the Oracle brew. Only then can one really taste and enjoy Oracle. So, think twice before assuming Oracle is like SQL-Server and PL/SQL is like T-SQL. You will save yourself a lot of frustration, wasted effort, and run into fewer (very hard and very painful) brick walls as a result.

  • Conversion from SQL Server Stored Procedures to Oracle Procedures

    We are having an ERP Package which runs on SQL Server 7.0. For the Reports and Transaction windows, we are using the stored procedures extensively.Now , we want to convert it to Oracle Procedures.Where can i find the resource for this subject.
    Please mail me to [email protected]
    Regards,
    Buhari

    Oracle provides a tool, called the Migration Workbench, that can do an automated conversion. In the newest release of SQL Developer, Oracle's PL/SQL development GUI, the Migration Workbench is built in.
    Be aware, though, that there are limits to what an automated tool is capable of doing. In all probability, you'll want to manually adjust at least a handful of the procedures after any automated tool converts them in order to make things more efficient or to adjust logic that may depend on database-specific behavior. If you have code, for example, that assumes that writers block readers, that code will no longer block in Oracle, which might require re-assessing your algorithm. In addition, there are numerous approaches to developing procedures that are very common in SQL Server (the use of temp tables, for example), that while possible in Oracle generally aren't the most efficient approach.
    Justin

  • How To Call SQL Server SP's in Oracle 11G

    Hi
    I have sucessfuly established the connectivity between Oracle 11G and SQl Server 2008 and I am able to select the data from views or tables of sql server in oracle.
    but now I have 1 issue I am not able to call or execute the SP's or function of sql server in oracle 11G.
    Can you please suggest or help me.
    Thanks
    Regards
    Anant.

    Anant,
    Which gateway are you using to connect to SQL*Server ? Is it the Database Gateway for SQL*Server (DG4MSQL) or Database Gateway for ODBC (DG4ODBC) ?
    If it is DG4MSQL then have a look at this note in My Oracle Support -
    Different Methods For Calling MS SQL Server Procedures Using DG4MSQL (Doc ID 197192.1)
    If you still have problems using DG4MSQL then post an example of what you are trying to do and the errors you receive.
    If you are using DG4ODBC then this does not support calling remote stored procedures.
    Regards,
    Mike
    Edited by: mkirtley on Aug 8, 2012 3:32 PM

  • How to run a SQL Server Stored Procedure

    I need to run a SQL Server Stored Procedure in answer, the stored procedure use a hash table (temporary table) and I nedd to pass a parameter to stored procedure
    anyone know if is it possible in OBIEE, if yes how.
    thank you
    max

    thank you, but I'm not understand what you mean. I need to run this command in answer "direct access database"
    exec storedprocedure 1,1,1
    if I run this I receive thi error:
    error : [nQSError: 16001] ODBC error state: S0002 code: 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server]object name '#TempList' not valid.. [nQSError: 16002] Cannot obtain number of columns for the query result. (HY000).
    here is the code of stored procedure:
    ROC [dbo].[GetOrderListmax]
    @OrderList varchar(500)
    AS
    BEGIN
    SET NOCOUNT ON
    CREATE TABLE #TempList
    OrderID int
    DECLARE @OrderID varchar(10), @Pos int
    SET @OrderList = LTRIM(RTRIM(@OrderList))+ ','
    SET @Pos = CHARINDEX(',', @OrderList, 1)
    IF REPLACE(@OrderList, ',', '') <> ''
    BEGIN
    WHILE @Pos > 0
    BEGIN
    SET @OrderID = LTRIM(RTRIM(LEFT(@OrderList, @Pos - 1)))
    IF @OrderID <> ''
    BEGIN
    INSERT INTO #TempList (OrderID) VALUES (CAST(@OrderID AS int)) --Use Appropriate conversion
    END
    SET @OrderList = RIGHT(@OrderList, LEN(@OrderList) - @Pos)
    SET @Pos = CHARINDEX(',', @OrderList, 1)
    END
    END
    SELECT o.OrderID, CustomerID, EmployeeID, OrderDate
    FROM dbo.Orders AS o
    JOIN
    #TempList t
    ON o.OrderID = t.OrderID
    END

  • Can a SQL Server stored procedure call an SAP function module?

    Can a SQL Server stored procedure call an SAP function module.? The stored procedure will be called via a trigger when data records are added to a Z table.

    You have two options:
    - the other software can use the RFC SDK and call directly in the system
    - the other software can use a database connect
    Markus

  • How to convert SQL Server hierarchical query (CTE) to Oracle?

    How to convert SQL Server hierarchical query (CTE) to Oracle?
    WITH cte (col1, col2) AS
    SELECT col1, col2
    FROM dbo.[tb1]
    WHERE col1 = 12
    UNION ALL
    SELECT c.col1, c.col2
    FROM dbo.[tb1] AS c INNER JOIN cte AS p ON c.col2 = p.col1
    DELETE a
    FROM dbo.[tb1] AS a INNER JOIN cte AS b
    ON a.col1 = b.col1

    See: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#i2129904
    Ah, just spotted it's a delete statement - you won't be able to do it using subquery factoring in Oracle.
    I had a go at trying to convert for you, but notice that you reference the cte from inside the cte... I can only assume you have a table called cte too...
    DELETE FROM dbo.tb1
    WHERE col1 = 12
    OR col2 IN (SELECT col1 FROM cte)
    Edited by: Boneist on 22-Jun-2009 09:19

  • Converting MS Sql server stored proc to Oracle stored procedure

    I need to convert this MS SQL Server 200 stored procedure to Oracle stored procedure. Any help great appreciated.
    Thank you,
    set nocount on
    declare @sp varchar(100)
    set @sp = '<< stored procedure name goes here >>'
    declare @oid int
    select @oid = o.id from sysobjects o where o.name = @sp
    declare @last int
    -- function signature
    select @last = max(c.colid)
    from dbo.syscolumns c
    where c.id = @oid
    select case c.colid
    when 1 then '[ SqlCommandMethod(CommandType.StoredProcedure) ]'
    + char(13) +
    'public static SqlCommand ' + @sp + '(' + char(13) +
    ' [ NonCommandParameter ] SqlConnection
    ' connection '
    + char(13) +
    else ''
    end
    + ' ' +
    case t.name
    when 'char' then
    '[ SqlParameter(' + convert(nvarchar(10), c.length) + ')  '
    when 'varchar' then
    '[ SqlParameter(' + convert(nvarchar(10), c.length) + ') ] '
    when 'nchar' then
    '[ SqlParameter(' + convert(nvarchar(10), c.length / 2) + ') ] '
    when 'nvarchar' then
    '[ SqlParameter(' + convert(nvarchar(10), c.length / 2) + ') ] '
    else ''
    end
    +
    case t.name
    when 'char' then 'string'
    when 'nchar' then 'string'
    when 'varchar' then 'string'
    when 'nvarchar' then 'string'
    when 'bit' then 'bool'
    when 'datetime' then 'DateTime'
    when 'float' then 'double'
    when 'real' then 'float'
    when 'int' then 'int'
    else 'object /* ' + t.name + ' */'
    end
    + ' ' + lower(substring(c.name, 2, 1)) + substring(c.name, 3, 100)
    +
    case c.colid
    when @last then ')' + char(13) + '{'
    else ','
    end
    from dbo.syscolumns c
    left outer join dbo.systypes t on c.xusertype = t.xusertype
    where c.id = @oid
    order by c.colid
    -- call to generator
    select case c.colid
    when 1 then
    ' return SqlCommandGenerator.GenerateCommand(connection,' +
    char(13)
    else ''
    end
    + ' ' + lower(substring(c.name, 2, 1)) + substring(c.name,
    3, 100)
    +
    case c.colid
    when @last then ');' + char(13) + '}'
    else ','
    end
    from dbo.syscolumns c
    where c.id = @oid
    order by c.colid

    It would have helped if you had posted your code.
    To create tables in procedures, you can use EXECUTE IMMEDIATE. For example, if within a procedure, you want to:
    CREATE TABLE table_name
    (column1 NUMBER,
    column2 VARCHAR2 (30),
    column3 DATE);
    Then, from within a procedure you can:
    CREATE OR REPLACE PROCEDURE procedure_name
    AS
    BEGIN
    EXECUTE IMMEDIATE 'CREATE TABLE table_name
    (column1 NUMBER,
    column2 VARCHAR2 (30),
    column3 DATE)';
    END procedure_name;
    EXEC procedure_name
    For the procedure to count the number of business days between two input dates, see the following link:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:91212348059

  • How to convert sql server procedure in to plsql procedure

    hi guys
    i have requirement where in i have to convert sql server procedure into plsql procedure.
    can some one help me out .
    thanks,
    Vamshi.D

    Hi Vamshi,
    As you want to convert sql server procedure in to plsql procedure
    i.e SQL SERVER ->ORACLE Right
    FYI
    SQL SERVER Proc. Syntax are totally different as compared to ORACLE Proc.
    So, better you study Logic of SQL-SERVER Proc and convert into
    Oracle Procedure.
    Thanks,
    Samadhan

  • Can't convert SQL Server 7 procedures

    When I create the Oracle Model, I get this error for every SQL Server 7 procedure that has parameters. I have a few procedures that don't have parameters, and they convert fine. Any help would be appreciated.
    [SPCONV-ERR(1)]:[Parsing()],oracle.mtg.sqlserver7.parser.ParseException: Parse error at line 1, column 1.
    Encountered: CREATE PROCEDURE
    Example:
    CREATE PROCEDURE just4.BS_AccountLoginSelect
    @Username as varchar(20)
    AS
    BEGIN
    SELECT LoginDate
    FROM ab.just4.bs_usernamelogins
    WHERE Username = @Username
    ORDER BY LoginDate desc
    END

    Hi,
    Try wrapping the parameter list in round brackets as shown below :
    CREATE PROCEDURE just4.BS_AccountLoginSelect(
    @Username as varchar(20) )
    AS
    BEGIN
    SELECT LoginDate
    FROM ab.just4.bs_usernamelogins
    WHERE Username = @Username
    ORDER BY LoginDate desc
    END
    Then, reparse the procedure.

  • SQL Server Stored Procedures

    Is there a way of firing up SQL Server stroed procedures from
    Flash 8?
    If so could someone explain how to do it please, as I would
    like to pass parameters from choices made via drop down lists
    (populated from xml pages) to query a SQL Server 2000 database.
    Any help appreciated.
    Thanks

    Yes, I understand. But Flash doesn't talk directly to your
    SQL API.
    The SQL interface is only available through ASP (in your
    case, or any number of server-side technologies). That's why you
    use getUrl() (or other http request) to send data to an ASP script
    which then executes the SQL statement 'execute <blah>
    <blah> <blah>'.
    You then take the results of that SQL, format it, and return
    something to Flash all as part of the one and only HTTP request.
    Does this make sense?

  • How to convert sql server database to SQL Server Express LocalDB??

    How do I convert sql server database 2008 to SQL Server Express LocalDB??
    Thanks
    Aru

    Hello,
    Please read the following article:
    http://msdn.microsoft.com/en-us/library/hh873188.aspx
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

Maybe you are looking for

  • Problem with VPN timeout on Cisco ASA5505

    Hi i'm sorry if it's vague, but i'm coming here without any  config simply because i don't have access. At work we have 1 Cisco ASA5505 which is used for IPSEC VPN only. We have 4-5 users that work 100% from the VPN (8h per day 40h per week) The prob

  • PO validation for date

    Need the control to change PO line items based on PO document creation date, User can change PO line items quantity only before 14 days from PO creation date & should not allow to change after 14 days from data of creation PO.This control should be a

  • Putaway strategy K: near picking bin

    Hi guys, I am experimenting putaway strategy K with 2 storage types, fixed bins & reserve. In my setup when capacity check is enabled in fixed storage type and no capacity left, the system searches for another bin from reserve and it works fine. Howe

  • Mobile Internet NOT WORKING on my Motorola Devour ... no 3G icon

    Please help...phone will not connect to internet, unless using Wi-Fi. I can send/receive both text and phone calls...just cannot connect to internet. I have tried *288 option 2 and 1, pulled the battery, power cycled the phone, stopping/starting the

  • We can´t change the class in Material Master classification Tab (MM02)

    When i trying to delete the class in the Classification tab in PRD System, it triggers the following message 'Assignment (# material) (classname) can not be deleted' because If you use classification data for selection of components of the BOM. Or if