hidrau
asked on
Passing values to run a store procedure
Hello guys,
I have a store procedure that will be run retrieving me a query. But before it retrieves me a query, some operation it will run and after the query is created. This query must be passed by parameter to be assemble.
I am getting error to pass this query,
This is the query:
'SELECT * FROM (
SELECT Contas, Descricao, Totaliza,
TOTAL =
IsNull(A.sete,0) ,
IsNull(A.sete,0) as ''setembro''
FROM ( Select *,
''sete''= Isnull((select Sum(ContSalContValor) from contsaldoanalitico WHERE
SubString(ContSalContCodig o,1,Len(Co ntas)) = Contas and
SubString(Convert(char(10) ,ContSalCo ntData,112 ),1,6) = ''200609''),0)
From #TbRel) A
) B
WHERE B.TOTAL<>0
ORDER BY B.CONTAS'
Here I try to pass the query
ADOStoredProc1.Parameters. ParamByNam e('@Sql'). Value := Str;
ADOStoredProc1.Open;
I have a store procedure that will be run retrieving me a query. But before it retrieves me a query, some operation it will run and after the query is created. This query must be passed by parameter to be assemble.
I am getting error to pass this query,
This is the query:
'SELECT * FROM (
SELECT Contas, Descricao, Totaliza,
TOTAL =
IsNull(A.sete,0) ,
IsNull(A.sete,0) as ''setembro''
FROM ( Select *,
''sete''= Isnull((select Sum(ContSalContValor) from contsaldoanalitico WHERE
SubString(ContSalContCodig
SubString(Convert(char(10)
From #TbRel) A
) B
WHERE B.TOTAL<>0
ORDER BY B.CONTAS'
Here I try to pass the query
ADOStoredProc1.Parameters.
ADOStoredProc1.Open;
what is the error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It don't run.
Sorry, but I had to give up this thread.
I need to close it
Sorry, but I had to give up this thread.
I need to close it
ASKER
BlackTigerX , it is a storeprocedure, I should pass by parameter this query.
but I had to give up :(
but I had to give up :(
you are passing the text of a query as a parameter to a stored procedure?
not a good idea, you might as well just execute the query directly on your code
not a good idea, you might as well just execute the query directly on your code
I agree with BlackTigerX here. Passing SQL code to a stored procedure is one of the worst developing errors that you can make in my opinion. Whomever came up with that idea should be [edit], [edit] and finally [edit] and never be allowed near any computer again...
ASKER
Ok Workshop_Alex , I changed my mind about it.
Thanks
Thanks
You're welcome. Glad I could help. :-) But BlackTigetX deserves the credits...