Problem in executing dynamic query with context in PRO *C program

C

chets

Hi All,
I am facing problem in executing one dynamic query in PRO *C program
on linux. I want to update table
mytable by data MADURAI for a column mycolumn1 where primary key is
myPK.I want to use
EXECUTE IMMEDIATE with context.But it is not working.
Following is my piece of code. Please help. Thanks in advance.

int main()
{
EXEC SQL BEGIN DECLARE SECTION;
sql_context cntxt;
VARCHAR hDbName[32];
VARCHAR query[2000];
EXEC SQL END DECLARE SECTION;

EXEC SQL CONTEXT ALLOCATE :cntxt;

//Connected with database in another function passing context
as one argument. By using :-

connect_fun(cntxt,user,paswd);

strcpy((char *)query.arr,"UPDATE mytable SET
mycolumn1='MADURAI' WHERE myPK='11' ");
query.len=strlen("UPDATE mytable SET mycolumn1='MADURAI' WHERE
myPK='11' ");


EXEC SQL CONTEXT USE:cntxt;

//EXEC SQL AT :hDbName EXECUTE IMMEDIATE :query;
If I use this statement than ORA error is "statement handle not
prepared".

//EXEC SQL EXECUTE IMMEDIATE :query;
If I use this statement than ORA(1012) error is "not logged
on".

EXEC SQL AT :hDbName COMMIT;

return 0;

}


int connect_fun(sql_context cntxt,char *user, char *paswd)
{

EXEC SQL CONTEXT USE:cntxt;

EXEC SQL CONNECT :user IDENTIFIED BY :paswd AT :hdbname USING
:hdbname;

return 0;
}
 
M

mark_bluemel

chets said:
I am facing problem in executing one dynamic query in PRO *C program
on linux.

Then you'd do better asking on an appropriate newsgroup. This one is
about the C programming language...

A newsgroup in the comp.databases.oracle hierarchy would be _much_ more
appropriate.
 
F

Flash Gordon

chets said:
Hi All,
I am facing problem in executing one dynamic query in PRO *C program
on linux. I want to update table
mytable by data MADURAI for a column mycolumn1 where primary key is
myPK.I want to use
EXECUTE IMMEDIATE with context.But it is not working.
Following is my piece of code. Please help. Thanks in advance.

int main()
{
EXEC SQL BEGIN DECLARE SECTION;

<snip>

I'm afraid that the bulk of this is not C but the major extensions that
Pro *C provides for handling SQL. We only deal with standard C not
something that uses C as a wrapper around vast quantities of other
stuff. You will have to ask somewhere that Pro *C is topical, and I'm
sure that there will be mailing lists dedicated to it if you look. You
could also try looking at SQL groups or groups dedicated to whatever SQL
engine it is that Pro *C works with, but check to see if Pro *C is
topical before posting to such groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top