2016-07-15 78 views
0

我已經創建在Sybase錯誤的語法不正確

create procedure prcrms_crms_cust_id_verify_ins(@customer_code numeric(12,0),@id_type tinyint,@verification_status varchar(12),@verification_response varchar(255),@verification_date datetime,@add_user varchar(21)) as 
begin 
declare @check_id_exists int 
    select @check_id_exists = count(*) from crms_customer_id_verification where (('customer_code'[email protected]_code) and ('id_type'[email protected]_type)) 
    if(@check_id_exists > 0) 
    begin 
    update crms_customer_id_verification set [email protected]_status,[email protected]_response,[email protected]_date where (('customer_code'[email protected]_code) and ('id_type'[email protected]_type)) 
    return @@rowcount 
    end 
    if((@check_id_exists <> null) or (@check_id_exists <> 0)) 
    begin 
    insert into crms_customer_id_verification(customer_code,id_type,verification_status,verification_response,verification_date,add_user) values(@customer_code,@id_type,@verification_status,@verification_response,@verification_date,@add_user) 
     return @@rowcount 
    end 
end 

一個過程,當我嘗試執行過程

exec prcrms_crms_cust_id_verify_ins(3344,0,"VERIFIED",'{test:test}','1998-09-09 12:12:12.000','Admin') 

這表明附近有語法錯誤 '3344'。

回答

0
/* 
create procedure prcrms_crms_cust_verify_ins(@customer_code varchar(255),@id_type varchar(255) ,@verification_status varchar(12),@verification_response varchar(255),@verification_date varchar(255),@add_user varchar(21))as 
/* 
** ------------------------------------ 
** Created By : Bibil Mathew Chacko 
** Created On : Jul 16 2016 
** Description : insert in crms_customer_id_verification if id_type and customer exist.Update table if customer and id_type exist. 
** ------------------------------------- 
*/ 
begin 
declare 

    @check_id_exists int, 
    @cc    numeric, 
    @id_t    tinyint, 
    @vd    datetime    


    select @cc = convert(numeric(12,0),@customer_code) 
    select @id_t = convert(tinyint,@id_type) 
    select @vd = convert(datetime,@verification_date) 

    select @check_id_exists = count(*) from crms_customer_id_verification where (([email protected]) and ([email protected]_t)) 
    if(@check_id_exists > 0) 
    begin 
    update crms_customer_id_verification set [email protected]_status,[email protected]_response,[email protected] where ([email protected] and [email protected]_t) 
    return @@rowcount 
    end 
    if((@check_id_exists <> null) or (@check_id_exists <> 0)) 
    begin 
    insert into crms_customer_id_verification(customer_code,id_type,verification_status,verification_response,verification_date,add_user) values(@cc,@id_t,@verification_status,@verification_response,@vd,@add_user) 
     return @@rowcount 
    end 
end 

*/ 
/*exec prcrms_crms_cust_verify_ins '3344','0',"VERIFIED",'{test:test}','1998-09-09 12:12:12.000','Admin'*/ 

應該使用VARCHAR類型作爲參數和程序應該有轉換成所需類型的支持。我做的另一個錯誤是Sybase程序沒有括號。

+0

唯一的問題是括號。我不知道爲什麼你需要使用'varchar'(至少從問題和這個答案都不清楚)。 –