Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:25:10+00:00 2026-06-18T04:25:10+00:00

I have to generate a c program that can generate a dynamic update sql

  • 0

I have to generate a c program that can generate a dynamic update sql and execute it.
The table name, no of columns to be updated and columns in where clause are known
only during run time.So i split my program into 2 functions:

1)CheckTableExists – checks whether the table provided by user exists in db.
Successfully implemented.

2)UpdateFunc – generates the sql string from data provided by user and executes
the query.

I am having issues in second function.I accept no of columns,names and values to be
updated from user. I then use a for loop and append the names and values to my sql
string:

sqlstring = Update tabname set colname = colval,colname = colval where

Then i accept where clause data and append it to my string. So my final string is:

sqlstring = Update tabname set colname = colval,colname = colval where whcolname = whcolval

But when i execute it my program hangs.Can somebody just tell me what should be the
ideal approach to execute second function.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:25:12+00:00Added an answer on June 18, 2026 at 4:25 am

    strSQL will be a valid SQL statement without placeholders for binding. This is suitable for queries with numeric and varchar2 variables. For binary you may have to implement functions say bin2hex() and hex2bin() in Oracle.

    A simple function like:

    int Exec_Query(sql_context sqlCtx, char *strSQL)
    {
    
    //    struct sqlca sqlca;
    
        /* Sanity checks for sqlCtx and strSQL */
    
        EXEC SQL WHENEVER SQLERROR GOTO QueryErr;  
    
        /* Set the context */
        EXEC SQL CONTEXT USE :sqlCtx;  
    
        /* Execute the query */
        EXEC SQL EXECUTE IMMEDIATE :strSQL; 
    
        EXEC SQL COMMIT; 
    
        return 0;
    
    QueryErr:
        /* printf("Err: Failure in Executing Query\n"); */
        /* printf("Debug: <%s>",sqlca.sqlerrm.sqlerrmc); */
        return -1;
    }
    

    Which through a Pro*C compiler will give a working C file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program that auto dials phone numbers, it can generate sounds
At work, I have started working on a program that can potentially generate hundreds
I have a program that can generate video in real time. Now I would
I have a program that uses XSL-FO (org.apache.fop.apps.Driver) to generate a PDF print out
I have a C# program that uses a production grammar to generate 3D models
I have a program that generates a .shp file, and exports this as a
I have a program that generates/'rolls' two dice. I would like to output these
I have a program that generates a lot of data and puts it in
I have a Java program that generates Java classes for my application. Basically it
I have a Matlab program that generates a list x = 6.1692 8.1863 5.8092

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.