Home » Developer & Programmer » Precompilers, OCI & OCCI » no soft parsing with Query
no soft parsing with Query [message #94095] Fri, 06 February 2004 23:29
Mr.Kang
Messages: 1
Registered: February 2004
Junior Member
DML SQL can prepared only ONCE, and execute multiple times in order to avoid soft parsing.
But, Query SQL can't. This produces 'invalid cursor' error.
why? Can't prepared only once? if so, How can I avoid soft parsing in Query SQL(select SQL)

here is my example.
For simplicity, Not use bind variables.

char dummy_stmt1[[]]  = "insert into test values(1,'dummy')";
char dummy_stmt2[[]]  = "update test set name = 'dummy'";
char dummy_stmt3[[]]  = "select sysdate from dual";

func1()
{
 static int parsed = 0;
 
 if( parsed == 0 )
 {
  printf("parsedn");
  EXEC SQL PREPARE dummy_stmt1 FROM :dummy_stmt1;
  EXEC SQL PREPARE dummy_stmt2 FROM :dummy_stmt2;
  EXEC SQL PREPARE dummy_stmt3 FROM :dummy_stmt3;
  EXEC SQL DECLARE c_dummy CURSOR for dummy_stmt3;
 }
 
 EXEC SQL EXECUTE dummy_stmt1;
 EXEC SQL EXECUTE dummy_stmt2;

 ...
 
 EXEC SQL OPEN c_dummy;
 EXEC SQL FETCH c_dummy INTO :db_today;
 ..
 EXEC SQL CLOSE c_dummy;
 
}

main()
{
 ..
 func1(); /* This fucntion executes multiple times*/
 ..
}
Previous Topic: Pro *c pre compilation
Next Topic: Getting TNS Error
Goto Forum:
  


Current Time: Sun Mar 03 03:06:53 CST 2024