Thread: How to use dynamic sql...?? in ECPG.....

How to use dynamic sql...?? in ECPG.....

From
"Ki won, Song"
Date:
In C programming... with ECPG tool...
I have some problem!!
How to use dynamic sql cursor??

void main()
{
      char sqlsentence[255];
      int flag;

        ....... Db Connection.....

     switch(flag) {
        case 1: {
                      sprintf(sqlsentence,"select id , name from testa where id = 1");
                      break;
                    }
        case 2: {
                      sprintf(sqlsentece," select tel, address from testb where key=22");
                       break;
                    }
    }

    EXEC SQL DECLARE cur1 CURSOR FOR :sqlsentence;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ==> ecpg pre compile error "parse error"!!!
        ==> How to use Dynamic sql with ECPG??

    ....... some process.....

}