Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Posts
    4

    Question Unanswered: Syabase Stored procedure---help needed

    Hi ALL,


    create procedure test_sp
    (
    @acct_arr varchar(17)
    ) as

    begin

    declare @acct int

    select @acct = convert(int,@acct_arr)

    select count(emp_id)
    from account
    where acct_no in (@acct)

    return(0)


    end
    go


    For the above SP when I pass the command line args as '1,2'..It throws an error like this,

    Msg 249, Level 16, State 1:
    Syntax error during explicit conversion of VARCHAR value '1,2' to a INT field.
    (return status = -6)

    Could any one please help me out with this problem.. Is there any other way to approach this?..Thanks in advance...

    Thanks,
    Poka..

  2. #2
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    The @var won't get expanded the way you hope. You can probably get around this by using an execute immediate clause:

    create procedure test_sp
    (
    @acct_arr varchar(17)
    ) as

    begin
    declare @cmd varchar(200)

    select @cmd = 'select count(emp_id) from account where acct_no in (' + @acct_arr + ')'

    exec(@cmd)

    return(0)


    Michael

  3. #3
    Join Date
    Dec 2005
    Posts
    5
    Quote Originally Posted by pokks
    Hi ALL,


    create procedure test_sp
    (
    @acct_arr varchar(17)
    ) as

    begin

    declare @acct int

    select @acct = convert(int,@acct_arr)

    select count(emp_id)
    from account
    where acct_no in (@acct)

    return(0)


    end
    go


    For the above SP when I pass the command line args as '1,2'..It throws an error like this,

    Msg 249, Level 16, State 1:
    Syntax error during explicit conversion of VARCHAR value '1,2' to a INT field.
    (return status = -6)

    Could any one please help me out with this problem.. Is there any other way to approach this?..Thanks in advance...

    Thanks,
    Poka..
    Pass the cmd line args as 1 or 2 only not two args..
    chk out once..your procedure is correct only

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •