I need to open one query in run time whit dynamic parameter binding, but it dosn't work and no record exist in result set .(similar code works whit BDE and some records in result set). furthermore similar query whit no parameters (static parameter binding in sql command) works in my code.
my query has one parameter whit String type.
please tell me your advise and expriments.
Parameter binding problem
more detailes (Hamid)
for example this scrips has no result set:
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("SELECT f1,f2 FROM t1 where f3=:1");
OraSelQ->Params->Items[0]->DataType = ftString;
OraSelQ->Params->Items[0]->AsString = "ABC";
OraSelQ->Open(); ==> this dataset is empty
but this two scripts have some records in result set :
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("SELECT f1,f2 FROM t1 where f3='ABC' ");
OraSelQ->Open(); ==> this dataset has some records
or this one:
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("SELECT f1,f2 FROM t1 where f3 like :1 ");
OraSelQ->Params->Items[0]->DataType = ftString;
OraSelQ->Params->Items[0]->AsString = "ABC%";
OraSelQ->Open(); ==> this dataset has some records
all of this samples works whit BDE components and have some records.
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("SELECT f1,f2 FROM t1 where f3=:1");
OraSelQ->Params->Items[0]->DataType = ftString;
OraSelQ->Params->Items[0]->AsString = "ABC";
OraSelQ->Open(); ==> this dataset is empty
but this two scripts have some records in result set :
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("SELECT f1,f2 FROM t1 where f3='ABC' ");
OraSelQ->Open(); ==> this dataset has some records
or this one:
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("SELECT f1,f2 FROM t1 where f3 like :1 ");
OraSelQ->Params->Items[0]->DataType = ftString;
OraSelQ->Params->Items[0]->AsString = "ABC%";
OraSelQ->Open(); ==> this dataset has some records
all of this samples works whit BDE components and have some records.
I couldn't reproduce your problem, I have tested it on C++Builder 5 and 6, ODAC 5.50.1.18 against Scott.EMP table and always got satisfactory results, the test sample was
Please specify your exact ODAC version, IDE version, Oracle Client/Server version and send us small sample that demonstrates your problem with scripts to create server objects.
Code: Select all
// TOraQuery *OraSelQ;
OraSelQ->Close();
OraSelQ->SQL->Clear();
OraSelQ->SQL->Add("select mgr, empno from emp where ename=:1");
OraSelQ->Params->Items[0]->DataType = ftString;
OraSelQ->Params->Items[0]->AsString = "JONES";
OraSelQ->Open();