cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

While Executing the Sp in Query manager Getting Error.

Former Member
0 Kudos
939

hi.

i need a small information.

I Created a small table in Sql 

ccodevarcharno250
cnamevarcharno250
ctypevarcharno250

---------------------------------------

My Stored Procedure at  Sql

i am inserting values in to the temporary table by using below one after passing the parameter

i am executing the parameter is

EXEC 'cardcode' ,'cardname' ,'c'

if i execute the stored procedure in sql values are inserting  same thing i want to do in sap b1 at query maanger

USE [WCTBRPLDB21-05-2014]

GO

/****** Object:  StoredProcedure [dbo].[uspGetAddress1]    Script Date: 8/1/2014 4:07:20 PM ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER Procedure [dbo].[uspGetAddress1]

@Cuscode varchar(250),

@customertName VARCHAR(250) ,

@custype varchar(250)

As

Begin

DECLARE @Cur_Product CURSOR

set @Cur_Product= cursor for select CardCode,CardName,CardType  from ocrd  where  CardCode =@Cuscode and   CardName= @customertName  and  cardtype =@custype

open @Cur_Product

       fetch next

       from @Cur_Product into @Cuscode,@customertName,@custype

       while @@FETCH_STATUS = 0

       begin

       insert into custupdate (ccode,cname,ctype) values (@Cuscode,@customertName,@custype)

       fetch next

       from @Cur_Product into @Cuscode,@customertName,@custype

       end

       close @Cur_Product

       deallocate @Cur_Product

    select * from custupdate

End

--------------------------

@Cuscode varchar(250),

@customertName VARCHAR(250) ,

@custype varchar(250),

select @Cuscode = T0.CARDCODE from OCRD T0 where T0.CARDCODE = '[%01]' AND

select @CARDNAME = T0.CARDNAME from OCRD T0 where T0.CARDNAME = '[%02]' AND

select @CARDTYPE = T0.CARDTYPE from OCRD T0 where T0.CARDTYPE = '[%03]'

uspGetAddress1 @Cuscode ,@CARDNAME ,@CARDTYPE

----------------------

The above one i pasted at query manager.

if i run it it is asking the parameters

but after execute it

i am getting the error that must declare the Scalar variable like that  it is showing.

but i am all ready giving the scalar variable but it is not running.

Any information plz update me

is there any declaration problem in query  manager.....................

View Entire Topic
Former Member
0 Kudos

Any Information plz update me..

former_member197621
Active Contributor
0 Kudos

hi,

Which part you are trying to execute in query manager?

Bcz in second part declaration variable is different from assign variable.

You are declaring the variable @customertName but you passing the variable @CARDNAME

former_member206488
Active Contributor
0 Kudos

Try below in query generator:

Declare @Cuscode varchar(250),

Declare @customertName VARCHAR(250) ,

Declare @custype varchar(250)

/*SELECT FROM [dbo].[OCRD] T0*/

/* WHERE */

SET @Cuscode = /* T0.CardCode */ '[%0]'

/*SELECT FROM [dbo].[OCRD] T0*/

/* WHERE */

SET @customertName = /* T0.CardName */ '[%1]'

/*SELECT FROM [dbo].[OCRD] T0*/

/* WHERE */

SET @custype = /* T0.CardType */ '[%2]'

EXEC uspGetAddress1 @Cuscode,@customertName,@custype

**Don't remove comments

Thanks

Navneet

former_member197621
Active Contributor
0 Kudos

Hi,

Try this below and let me know your feedback,


Declare @Cuscode varchar(250)

Declare @customertName VARCHAR(250)

Declare @custype varchar(250)

set @Cuscode =  (select  T0.CARDCODE from OCRD T0 where T0.CARDCODE = '[%0]' )

set @customertName = (select T0.CARDNAME from OCRD T0 where T0.CARDNAME = '[%1]')

set  @custype = (select max(T0.CARDTYPE) from OCRD T0 where T0.CARDTYPE = '[%3]')

EXEC uspGetAddress1 @Cuscode,@customertName,@custype