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

时间:2019-02-27 16:14:42

标签: sql sql-server oracle

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;

如何在不更改查询功能的情况下将此代码转换为我刚接触Oracle的SQL SERVER?我对数据类型和其他常规内容没什么问题,主要要考虑的是批量插入和表对象,例如category_table_obj category_record_table;

1 个答案:

答案 0 :(得分:1)

几乎每行都需要更改:

alpha_post = rnorm(n=1500,mean=1.1,sd = .15)
beta_post = rnorm(n=1500,mean=1.8,sd = .19)
X_lim = seq(from = -3,to = 2,by=.01)


for (i in 1:length(alpha_post)){
  print(i)
  y = exp(alpha_post[i] + beta_post[i]*X_lim)/(1+ exp(alpha_post[i] + beta_post[i]*X_lim) )

  if (i==1){plot(X_lim,y,type="l")}
  else {lines(X_lim,y,add=T)}
} 

在SQL Server中,所有这些都具有等效的语句,但是这需要大量工作(并且同时了解SQL Server TSQL和Oracle OSQL的人)。