Home » Developer & Programmer » Precompilers, OCI & OCCI » EXEC SQL 'hangs' on insert
EXEC SQL 'hangs' on insert [message #93710] Sun, 27 October 2002 13:45 Go to next message
Rajesh Dorairajan
Messages: 1
Registered: October 2002
Junior Member
I've two questions. I'll be grateful if someone can answer them for me (SOS) ASAP.

1. I've a simple insert SQL in my Pro*C code. When I execute the control just hangs there. There's no error code. The cursor just keeps blinking. Nothing happens. The code:

EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--n");

EXEC SQL AT DB_NAME INSERT INTO GRADE (LAST, FIRST, CODE, Q1) VALUES(:grade_rec.Gradelast, :grade_rec.Gradefirst, :score_code, :grade_rec.Gradequiz1);

Structure of grade:
typedef struct {
VARCHAR Gradelast[[21]];
VARCHAR Gradefirst[[21]];
char Gradecode[[6]];
int Gradequiz1;
int Gradequiz2;
int Gradequiz3;
int Gradequiz4;
int Gradequiz5;
int Gradeproject1;
int Gradeproject2;
int Gradeproject3;
int Grademidterm;
int Gradefinal;
int Gradetotal;
} Grade;

schema of grade in db:
CREATE TABLE GRADE (
last VARCHAR(20),
first VARCHAR(20),
code CHAR(5),
q1 INTEGER default(0),
q2 INTEGER default(0),
q3 INTEGER default(0),
q4 INTEGER default(0),
q5 INTEGER default(0),
p1 INTEGER default(0),
p2 INTEGER default(0),
p3 INTEGER default(0),
m INTEGER default(0),
f INTEGER default(0),
total INTEGER default(0),
primary key(last, first, code),
foreign key(last, first) references STUDENT,
foreign key(code) references COURSE
);

Other insert statements in the code work just fine.

2. My second question is, Is there any way to substitute a column name in EXEC SQL with an input:

for example let's say, I've

EXEC SQL insert into person (lastname, firstname, address) values ('somebody', 'joe', '123 somecity');

can I do something like:
printf("Enter column name: ");
scanf("%s", c_name);

EXEC SQL insert into person (lastname, firstname, "c_name") values ('somebody', 'joe', '123 somecity');

In other words is it possible for me to input a column name at runtime and specify it in my query?

Needless to say Any help will be deeply appreciated...

Rajesh
Re: EXEC SQL 'hangs' on insert [message #93770 is a reply to message #93710] Sun, 05 January 2003 09:22 Go to previous messageGo to next message
A .shiva kumar
Messages: 3
Registered: January 2003
Junior Member
hai rajesh sir,
iam shiva
sorry i donot know the answer, but i would like to
know from where we can get this pro *c pre compiler
kindly tell me about that iam dying for that.

sorry again,
i will be thank ful if u can give me the answer
Re: EXEC SQL 'hangs' on insert [message #93787 is a reply to message #93710] Sun, 19 January 2003 10:51 Go to previous messageGo to next message
Thotakura
Messages: 9
Registered: January 2003
Junior Member
hai rajesh,

for that u have to use dynamic SQL concept that is use prepare,execute and execute immediate statements.

if u want more details mail me.
Re: EXEC SQL 'hangs' on insert [message #93792 is a reply to message #93787] Tue, 21 January 2003 08:08 Go to previous message
A .shiva kumar
Messages: 3
Registered: January 2003
Junior Member
hai,
i want the details how to access the database through c++
for that we need some header files ,how to down load them .
Previous Topic: Urgent : Setting Null value of a COBOL variable
Next Topic: Pro *C error PCC-S-02015
Goto Forum:
  


Current Time: Mon May 27 10:50:55 CDT 2024