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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • chets

    #1

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

    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(cnt xt,user,paswd);

    strcpy((char *)query.arr,"UP DATE mytable SET
    mycolumn1='MADU RAI' WHERE myPK='11' ");
    query.len=strle n("UPDATE mytable SET mycolumn1='MADU RAI' 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;
    }

  • mark_bluemel@pobox.com

    #2
    Re: Problem in executing dynamic query with context in PRO *C program


    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.

    Comment

    • Flash Gordon

      #3
      Re: Problem in executing dynamic query with context in PRO *C program

      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

      Comment

      Working...