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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include "stdafx.h"
#include "ocilib.h"
#pragma comment(lib, "ociliba.lib")
typedef void (*POCI_ERROR) (OCI_Error *err);
int main(void)
{
OCI_Connection *cn;
OCI_Statement *st;
OCI_Resultset *rs;
if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
return EXIT_FAILURE;
cn = OCI_ConnectionCreate("XE", "system", "azerty", OCI_SESSION_DEFAULT);
if (cn != NULL)
{
printf(OCI_GetVersionServer(cn));
printf("Server major version : %i\n", OCI_GetServerMajorVersion(cn));
printf("Server minor version : %i\n", OCI_GetServerMinorVersion(cn));
printf("Server revision version : %i\n", OCI_GetServerRevisionVersion(cn));
printf("Connection version : %i\n", OCI_GetVersionConnection(cn));
/*
st = OCI_StatementCreate(cn);
OCI_ExecuteStmt(st, "SELECT * FROM DISTANCE");
rs = OCI_GetResultset(st);
while (OCI_FetchNext(rs))
printf("id1: %i, id2: %i,dist: %i \n ", OCI_GetInt2(rs, "IDSTATION1") , OCI_GetInt2(rs, "IDSTATION2"), OCI_GetInt2(rs, "distance"));
printf("\n%d row(s) fetched\n", OCI_GetRowCount(rs));*/
st = OCI_StatementCreate(cn);
OCI_ExecuteStmt(st, "delete from station where idStation=1");
if (cn == NULL)
{
OCI_Error *err = OCI_GetLastError();
printf("errcode %d, errmsg %s", OCI_ErrorGetOCICode(err), OCI_ErrorGetString(err));
}
if (st == NULL)
{
OCI_Error *err = OCI_GetLastError();
printf("errcode %d, errmsg %s", OCI_ErrorGetOCICode(err), OCI_ErrorGetString(err));
}
printf("%d row deleted\n", OCI_GetAffectedRows(st));
OCI_Commit(cn);
OCI_StatementFree(st);
}
OCI_Cleanup();
return system("PAUSE");
} |
Partager