Home » Developer & Programmer » Precompilers, OCI & OCCI » Multithreading/Pro*C Insert Issue
Multithreading/Pro*C Insert Issue [message #503437] Fri, 15 April 2011 10:31
Emma1970
Messages: 1
Registered: April 2011
Junior Member
I am wondering if someone can help and see what is wrong with the following.

In a nutshell position1, position 2 and position 3 get output to the terminal but position 4 and position 5 do not and therefore the INSERT is not taking place. Passing threads=yes to proc precompiler and using Pro*C/C++: Release 11.2.0.1.0.

Even if the EXEC SQL CONNECT is put in the the threaded function the same thing seems to happen so i moved it out to its own function to see if it would work but it made no difference.

Thanks in advance


EXEC SQL BEGIN DECLARE SECTION;
char uid[21];
char pwd[21];
sql_context ctx1;
EXEC SQL END DECLARE SECTION;


int main(int argc, char *argv[])

{
pthread_t thread1;

EXEC SQL ENABLE THREADS;
EXEC SQL CONTEXT ALLOCATE :ctx1;

strcpy(uid, "SCOTT"); strcpy(pwd, "TIGER");

pthread_create(&thread1, NULL, function1, NULL);

exit (0);
}

void *function1(void *)

{

int result;

fprintf(stdout,"position 1\n");
EXEC SQL CONTEXT USE :ctx1;
fprintf(stdout,"position 2\n");
result = connect();
fprintf(stdout,"position 5\n");

EXEC SQL
INSERT INTO TABLEA
(COL1)
VALUES
(100);

EXEC SQL COMMIT;
EXEC SQL CONTEXT FREE :ctx1;

}

int connect()

{

fprintf(stdout,"pos3\n");
EXEC SQL CONNECT :uid IDENTIFIED BY :pwd;
fprintf(stdout,"pos4\n");

return (0);

}
Previous Topic: Retrieve collection of user-defined object in OCCI
Next Topic: OCIStmtFetch2 problem when fetched rows = 0
Goto Forum:
  


Current Time: Sat Nov 23 18:16:04 CST 2024