1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| #include "ocilib.h"
int main()
{
OCI_Connection *cn;
OCI_Statement *st;
int code;
char value[20];
if (OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT) == FALSE)
return EXIT_FAILURE;
cn = OCI_CreateConnection("db", "user", "pass", OCI_SESSION_DEFAULT);
st = OCI_CreateStatement(cn);
OCI_Prepare(st, "insert into my_table values(:code, :value)");
OCI_BindInt(st, ":code", &code);
OCI_BindString(st, ":value", value, 20);
for (code = 1; code < 1000; code++);
{
sprintf(value, "value %i", code);
OCI_Execute(st);
}
OCI_Commit(cn);
OCI_ConnectionFree(cn);
OCI_Cleanup();
return EXIT_SUCCESS;
} |
Partager