简体   繁体   English

将存储过程从oracle移动到sql server

[英]Moving stored procedure from oracle to sql server

PROCEDURE populate_boj_deposit_tab(asatdate IN VARCHAR2, in_sol   IN VARCHAR2)   AS 
test_cnt      BINARY_INTEGER; 
startdate     DATE; 
codefound     BINARY_INTEGER := 0; 
counter       BINARY_INTEGER := 0; 
ex_indx       BINARY_INTEGER := 1;  
excludeAcct   BINARY_INTEGER := 1; 
arr_indx      BINARY_INTEGER := 1; 
deposit_table_obj                      deposit_record_table;
category_table_obj    category_record_table;
exclusion_table_obj   exclusion_record_table := exclusion_record_table();
report_array reports := reports();

INSERT /*+ APPEND */ INTO boj_deposit_portfolio
    SELECT 
      customer_id,
      SUM(GENERALFUNCTIONS.FN_ConvertAmountAsOfDate(asAtDate, currency,'JMD',sanctioned_ato,'REV')) AS sanctioned_ato
    FROM 
      boj_raw_accounts_data
    GROUP BY customer_id;

    COMMIT;

    --Find and populate exclusion table
    EXECUTE IMMEDIATE 'TRUNCATE TABLE boj_deposits_exclusion';                    
    --Get loans accounts for each report that does not match    
    SELECT 
    transaction_balance, acid, borrower_category_code, sector_code, sub_sector_code, 
    rep_date, customer_id, cust_code
    BULK COLLECT INTO
    deposit_table_obj
    FROM bojdeposit_tab;

How can I convert this code to SQL SERVER I'm new to using Oracle without changing the functionality of the query?如何在不更改查询功能的情况下将此代码转换为 SQL SERVER 我是使用 Oracle 的新手? I'm okay with the data types and the other general stuff, the main concern is the bulk insert and table objects, for example, category_table_obj category_record_table;我对数据类型和其他一般东西没问题,主要关注的是批量插入和表对象,例如,category_table_obj category_record_table;

Almost every line needs to be changed:几乎每一行都需要改变:

There is no type ** BINARY_INTEGER  in SQL Server.
Assginment in SQL Server is done with an = sign not a := sign.

You can remove the commit - SQL Server starts a transaction with a begin transaction
General_functions in sql server would be interpreted as a schema name not package.
There is no execute immediate statement in SQL Server or bulk collect statement in SQL Server.

There are equivalent statements for all of these in SQL Server but it would require a lot of work (and someone who knows both SQL Server TSQL and Oracle OSQL). SQL Server 中所有这些都有等效的语句,但需要大量工作(并且需要同时了解 SQL Server TSQL 和 Oracle OSQL 的人)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM