 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Cenk Guest
|
Posted: Sat Jul 01, 2006 1:59 pm Post subject: SP problem |
|
|
hi,
i have a SP like below;
CREATE Procedure test1
@price as varchar(50),
@table as varchar(50)
AS
Declare @SQL_INS VarChar(1000)
SELECT @SQL_INS = 'select ['+@price+'] from ['+@table+']'
Exec (@SQL_INS)
and i have a code segment like this in BCB;
TStoredProc *Stp;
Stp= new TStoredProc (this);
Stp->DatabaseName = "Raw";
Stp->StoredProcName = "test1";
Stp->Params->Clear();
Stp->ParamByName("price")->AsString = "CLOSE"; -----> Gives ERROR
parameter price NOT FOUND?
Stp->ParamByName("table")->AsString = "MINUTE1(EUR/USD)";
Stp->Open();
for (int i = 0;i<rowtemp ;i++)
{
arr.push_back(Stp->ParamByName(price)->AsFloat);
Stp->Next();
}
What should i do? |
|
| Back to top |
|
 |
Leif Suonvieri Guest
|
Posted: Fri Jul 07, 2006 12:02 am Post subject: Re: SP problem |
|
|
Why do you use a stored procedure which contains dynamic SQL?
The SQL command you are trying to execute in the example seems to be
something like:
SELECT [CLOSE] FROM [MINUTE1(EUR/USD)]
Is that correct? Do you really have a table named MINUTE1(EUR/USD) which
contains a field named CLOSE? (sounds a bit odd to me)
Why are you reading the parameter afterwards in the loop?
The SP doesn't modify it, so I don't see the point.
It feels like you've left out some information, or doing it wrong.
How do the table look like (the field defs...)
In a bigger view, what are you trying to accomplish?
I would like more information to be able to help you...
/Leif |
|
| Back to top |
|
 |
Leif Suonvieri Guest
|
Posted: Fri Jul 07, 2006 12:39 am Post subject: Re: SP problem |
|
|
I'll give it a try anyway:
I suppose you have to create the parameter(s) by code, since you create
the SP object by code.
use something like:
Stp->Params->CreateParam(ftString, "@price", ptInput);
Stp->Params->CreateParam(ftString, "@table", ptInput);
If I understand your code correctly the result should be availiable as
records in the Stp object.
In that case use something like this to read the records:
Stp->FieldByName("CLOSE")->AsString; |
|
| Back to top |
|
 |
Cenk Guest
|
Posted: Fri Jul 07, 2006 7:25 pm Post subject: Re: SP problem |
|
|
I have couple of DBs and tables and user selects whatever one he wants,
thats why i need to use dynamic SQL. The result of my SP will return, lets
say 124 datas as an example. I get those data into a vector, thats not our
issue here.Anyways, i changed the code according to your advises but now i
gives "error creating cursor handle" at Stp->Open (); statement. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|