on 05-21-2008 11:35 AM
Dear All,
I made a stored procedure in sql. I'd like to call it from B1. It's working fine when I call like this (I created an empty query in Query generator and paste this) :
exec stproc @projectFrom = '',
@projectTo = 'PRJ03',
@profitCodeFrom = '',
@profitCodeTo = 'uj',
The problem is, Could I call this procedure with parameters like normal queries (select ... where .. = [%0])? Can I pass parameters to it somehow?
Thanks a lot
Jani
Hello Janos,
You can do the following
{declare @param1 as <type>}
{select @param1=cardcode from OCRD where cardcode=[%0]}
{exec your_procedure @param1}
hope it helps
Kind regards
George Christodoulou
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot George for this help.
I have a similar problem :
First the following SQL treatment is working :
declare @offrenum nvarchar(100)
set @offrenum=400
IF NOT EXISTS(Select * from [dbo].[@TS_CONDBYQUOTATION] T25 where @offrenum = T25.U_Quotation )
BEGIN
SQL treatment
END
select * from [dbo].[@TS_CONDBYQUOTATION] where U_quotation = @offrenum
This one is also working :
declare @offrenum nvarchar(100)
select @offrenum=T1.docnum from oqut T1 where T1.docnum=[%docnum]
select @offrenum from ocrd
But if I try to do this one :
declare @offrenum nvarchar(100)
select @offrenum=T1.docnum from oqut T1 where T1.docnum=[%docnum]
IF NOT EXISTS(Select * from [dbo].[@TS_CONDBYQUOTATION] T25 where @offrenum = T25.U_Quotation )
BEGIN
SQL treatment
END
select * from [dbo].[@TS_CONDBYQUOTATION] where U_quotation = @offrenum
It doesn't work ... can you help me ???
HI Hugues,
I solved my problem like this:
--SELECT T0.[Project] FROM JDT1 T0 WHERE T0.[Project] >= AND T0.[Project] <= AND T0.[ProfitCode] >= AND T0.[ProfitCode] <= AND T0.[RefDate] >= '[%4]' AND T0.[RefDate] <= '[%5]' AND T0.[DueDate] >= '[%6]' AND T0.[DueDate] <= '[%7]' AND T0.[Account] >= '[%8]' AND T0.[Account] <= '[%9]'
exec stored_proc @projectFrom = '[%0]', @projectTo = '[%1]', @profitCodeFrom = '[%2]', @profitCodeTo = '[%3]', @refDateFrom = '[%4]', @refDateTo = '[%5]', @dueDateFrom = '[%6]', @dueDateTo = '[%7]', @accountFrom = '[%8]', @accountTo = '[%9]'
I know, it seems stupid, but it's working
Edited by: János Dubin on Jun 5, 2008 9:36 AM
Thanks a lot George for this help.
I have a similar problem :
First the following SQL treatment is working :
declare @offrenum nvarchar(100)
set @offrenum=400
IF NOT EXISTS(Select * from [dbo].[@TS_CONDBYQUOTATION] T25 where @offrenum = T25.U_Quotation )
BEGIN
SQL treatment
END
select * from [dbo].[@TS_CONDBYQUOTATION] where U_quotation = @offrenum
This one is also working :
declare @offrenum nvarchar(100)
select @offrenum=T1.docnum from oqut T1 where T1.docnum=[%docnum]
select @offrenum from ocrd
But if I try to do this one :
declare @offrenum nvarchar(100)
select @offrenum=T1.docnum from oqut T1 where T1.docnum=[%docnum]
IF NOT EXISTS(Select * from [dbo].[@TS_CONDBYQUOTATION] T25 where @offrenum = T25.U_Quotation )
BEGIN
SQL treatment
END
select * from [dbo].[@TS_CONDBYQUOTATION] where U_quotation = @offrenum
It doesn't work ... can you help me ???
After a lot of tries, unfortunatly it doesn't work ...
Here is my code :
DECLARE @return_value int
Declare @Fromdate datetime
declare @Todate datetime
declare @supp nvarchar(15)
SELECT * FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry where
T0.cardcode = '[%Supp]' and T0.DocDate <=[%FromDate]
and T0.DocDate >=[%ToDate]
EXEC @return_value=SQL2XMLforINV
@Fromdate= [%FromDate],
@ToDate= [%ToDate],
@Supp = '[%Supp]'
SELECT 'Return Value' = @return_value
And i get an error : incorrect syntax neer the keyword convert .... : I don't understand !!
Please help me !!!
Inside B1 :
DECLARE @return_value int
Declare @Fromdate datetime
declare @Todate datetime
declare @supp nvarchar(15)
SELECT * FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry where
T0.cardcode = '%Supp' and T0.DocDate <=%FromDate
and T0.DocDate >=%ToDate
EXEC @return_value=SQL2XMLforINV
@Fromdate= %FromDate,
@ToDate= %ToDate,
@Supp = '%Supp'
SELECT 'Return Value' = @return_value
And in SQL I have a stored procedure :
Starting like this :
PROCEDURE [dbo].[SQL2XMLforINV]
@Fromdate datetime,
@Todate datetime,
@supp nvarchar(15)
AS
DECLARE @bcpCommand AS varchar(3000)
declare @base nvarchar(50)
BEGIN
SET NOCOUNT ON;
And my error message is in B1 ....
Thanks in advance for your help ....
Try this one:
nside B1 :
DECLARE @return_value int
Declare @Fromdate datetime
declare @Todate datetime
declare @supp nvarchar(15)
--SELECT * FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry where
T0.cardcode = '%Supp' and T0.DocDate <='%FromDate'
and T0.DocDate >='%ToDate'
EXEC SQL2XMLforINV
@Fromdate= %FromDate,
@ToDate= %ToDate,
@Supp = '%Supp'
--SELECT 'Return Value' = @return_value
Maybe the problem was the datetime should also text type and you should put it between ' '
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.