By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

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

P: n/a
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;
}

Oct 9 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

chets wrote:
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.

Oct 9 '06 #2

P: n/a
chets wrote:
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.
--
Flash Gordon
Oct 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.