Medhavi Mahansaria
2015-01-02 08:34:04 UTC
Date: 2 January 2015 2:02:35 pm IST
Subject: Dynamic query use
Hi,
I am using the below program in SOCI for executing a dynamic query.
But it is giving me ORA-24333 : zero iteration count
Please let me know where i am going wrong or should i use another approach?
Sent from my iPhone.
Brevity may be excused.
Thank You.
Regards,
Medhavi Mahansaria.
Begin forwarded
Subject: Dynamic query use
Hi,
I am using the below program in SOCI for executing a dynamic query.
But it is giving me ORA-24333 : zero iteration count
Please let me know where i am going wrong or should i use another approach?
Sent from my iPhone.
Brevity may be excused.
Thank You.
Regards,
Medhavi Mahansaria.
Begin forwarded
int main()
{
int id_flag=1;
int h_id=333;
int k,j;
string query,query1,query2;
session sql(oracle, "service=orcl user=TEST_POC password=TEST_POC");
try
{
query1="select id,points from test where 1=1 ";
if (id_flag == 1)
{
query2=" AND id = :h_id";
}
else
{
query2+=" AND points = :h_id";
}
query= query1+query2;
query="\""+query+"\"";
query+=",into(k),into(j),use(h_id)";
cout<<query<<endl;
statement stmt=(sql.prepare<<query);
stmt.execute();
while(stmt.fetch())
{
cout <<"the value points = "<<j<<" and id ="<<k<<endl;
}
}
catch (exception const &e)
{
cerr << "Error: " << e.what() << '\n';
}
return 0;
}
{
int id_flag=1;
int h_id=333;
int k,j;
string query,query1,query2;
session sql(oracle, "service=orcl user=TEST_POC password=TEST_POC");
try
{
query1="select id,points from test where 1=1 ";
if (id_flag == 1)
{
query2=" AND id = :h_id";
}
else
{
query2+=" AND points = :h_id";
}
query= query1+query2;
query="\""+query+"\"";
query+=",into(k),into(j),use(h_id)";
cout<<query<<endl;
statement stmt=(sql.prepare<<query);
stmt.execute();
while(stmt.fetch())
{
cout <<"the value points = "<<j<<" and id ="<<k<<endl;
}
}
catch (exception const &e)
{
cerr << "Error: " << e.what() << '\n';
}
return 0;
}