📄 orl.h
字号:
skrishna 06/06/95 - rename orln, orld, orlvs and orlva to orlnum, orldat, orlvstr and orlvary respectively skrishna 11/15/94 - remove orlnget() function skrishna 09/20/94 - modify orldbtw() to return number of days only skrishna 08/24/94 - change format string length type from ub4 to ub1 skrishna 07/19/94 - Rename orln2c & orlnc2n to orln2s & orlns2n skrishna 06/29/94 - Add blob interface; add examples skrishna 06/23/94 - Update comments and format skrishna 05/19/94 - update varray append comments skrishna 05/05/94 - Subsetting skrishna 11/24/93 - Creation*/#ifndef ORATYPES#include <oratypes.h>#endif#ifndef ORO_ORACLE#include <oro.h>#endif#ifndef ORT_ORACLE#include <ort.h>#endif#ifndef OCI_ORACLE#include <oci.h>#endif#ifndef ORL_ORACLE#define ORL_ORACLE/*---------------------------------------------------------------------------*//* SHORT NAMES SUPPORT SECTION *//*---------------------------------------------------------------------------*/#ifdef SLSHORTNAME/* the following are short names that are only supported on IBM mainframes with the SLSHORTNAME defined. With this all subsequent long names will actually be substituted with the short names here */#define OCIArray orlvary#define OCIColl orlcol#define OCICollAppend orlcapp#define OCICollAssign orlcasg#define OCICollAssignElem orlcase#define OCICollGetElem orlcget#define OCICollMax orlcmax#define OCICollSize orlcsiz#define OCICollTrim orlctrm#define OCICollIsLocator orlcilc#define OCIDate orldat#define OCIDateAddDays orldadd#define OCIDateAddMonths orldadm#define OCIDateCheck orldchk#define OCIDateCompare orldcmp#define OCIDateDD day_orldat#define OCIDateDaysBetween orldbtw#define OCIDateFromText orlds2d#define OCIDateLastDay orldlst#define OCIDateMM mon_orldat#define OCIDateNextDay orldndy#define OCIDateSysDate orldsys#define OCIDateTime time_orldat#define OCIDateYYYY gye_orldat#define OCIDateZoneToZone orldz2z#define OCIIter orlcitr#define OCIIterCreate orlccit#define OCIIterDelete orlcdit#define OCIIterGetCurrent orlcicur#define OCIIterInit orlciit#define OCIIterNext orlcinxt#define OCIIterPrev orlciprv#define OCINumber orlnum#define OCINumberAbs orlnabs#define OCINumberAdd orlnadd#define OCINumberArcCos orlnacos#define OCINumberArcSin orlnasin#define OCINumberArcTan orlnatan#define OCINumberAssign orlnasg#define OCINumberCeil orlncel#define OCINumberCos orlncos#define OCINumberDiv orlndiv#define OCINumberPower orlnbex#define OCINumberFloor orlnflr#define OCINumberFromInt orlni2n#define OCINumberFromReal orlnr2n#define OCINumberFromText orlns2n#define OCINumberHypCos orlncsh#define OCINumberHypSin orlnsnh#define OCINumberSetZero orlnini#define OCINumberSetPi orlnspi#define OCINumberInc orlninc#define OCINumberDec orlndec#define OCINumberIntPower orlnpwr#define OCINumberLn orlnln#define OCINumberLog orlnlog#define OCINumberMod orlnmod#define OCINumberMul orlnmul#define OCINumberNeg orlnneg#define OCINumberPart orlnpart#define OCINumberExp orlnexp#define OCINumberRound orlnrou#define OCINumberPrec orlnpre#define OCINumberShift orlnsft#define OCINumberSign orlnsgn#define OCINumberSin orlnsin#define OCINumberSqrt orlnsqr#define OCINumberSub orlnsub#define OCINumberTan orlntan#define OCINumberHypTan orlntnh#define OCINumberArcTan2 orlnatn2#define OCINumberToInt orln2i#define OCINumberToReal orln2r#define OCINumberToText orln2s#define OCINumberTrunc orlntru#define OCINumberCmp orlncmp#define OCINumberIsZero orlnzer#define OCINumberIsInt orlnint#define OCIRaw orlraw#define OCIRawAllocSize orlwasz#define OCIRawAssignBytes orlwabr#define OCIRawAssignRaw orlwarr#define OCIRawPtr orlwgrp#define OCIRawResize orlwrsz#define OCIRawSize orlwgsz#define OCIRefAssign orlrasg#define OCIRefClear orlrclr#define OCIRefFromHex orlrh2r#define OCIRefHexSize orlrhsz#define OCIRefIsEqual orlrequ#define OCIRefIsNull orlrnul#define OCIRefToHex orlr2h#define OCIString orlvstr#define OCIStringAllocSize orlvasz#define OCIStringAssign orlvass#define OCIStringAssignText orlvats#define OCIStringPtr orlvgsp#define OCIStringResize orlvrsz#define OCIStringSize orlvgsz#define OCITable orltbl#define OCITableDelete orltdel#define OCITableExists orltexi#define OCITableFirst orltfst#define OCITableLast orltlst#define OCITableNext orltnxt#define OCITablePrev orltprv#define OCITableSize orltsiz#define OCITime orldtm#define OCITimeHH orldtmhh#define OCITimeMI orldtmmm#define OCITimeSS orldtmss#define OCI_LOBMODE_READONLY ORLBMORO#define OCI_LOBMODE_READWRITE ORLBMORW#endif /* SLSHORTNAME *//*****************************************************************************//* NUMBER/FLOAT/DECIMAL TYPE *//*****************************************************************************/#define OCI_NUMBER_SIZE 22struct OCINumber{ ub1 OCINumberPart[OCI_NUMBER_SIZE];};typedef struct OCINumber OCINumber;/* * OCINumber - OCI Number mapping in c * * The OTS types: NUMBER, NUMERIC, INT, SHORTINT, REAL, DOUBLE PRECISION, * FLOAT and DECIMAL are represented by OCINumber. * The contents of OCINumber is opaque to clients. * * For binding variables of type OCINumber in OCI calls (OCIBindByName(), * OCIBindByPos(), and OCIDefineByPos()) use the type code SQLT_VNU. *//* EXAMPLE The following example shows how to manipulate an attribute of type oracle number. struct person { OCINumber sal; }; typedef struct person person; OCIError *err; person* joe; person* tom; person* debbie; OCINumber *joesal; OCINumber *tomsal; OCINumber *debsal; sword status; int inum; double dnum; OCINumber ornum; char buffer[21]; ub4 buflen; sword result; /o See oci.h for an example of how to initialize OCIError. o For this example, assume the OCIEnv and OCIError has been o initialized. o/ /o Pin joe, tom and debbie person objects in the object cache. See ori.h o for an example on pinning objects. For this example, assume that o joe, tom and debbie are pointing to pinned objects. o/ joesal = &joe->sal; tomsal = &tom->sal; debsal = &debbie->sal; /o initialize joe's salary to be $12,000 o/ inum = 12000; status = OCINumberFromInt(err, &inum, sizeof(inum), OCI_NUMBER_SIGNED, joesal); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberFromInt o/; /o initialize tom's salary to be same as joe o/ OCINumberAssign(err, joesal, tomsal); /o initialize debbie's salary to be 20% more than joe's o/ dnum = 1.2; status = OCINumberFromReal(err, &dnum, sizeof(double), &ornum); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberFromReal o/; status = OCINumberMul(err, joesal, &ornum, debsal); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberMul o/; /o give tom a 50% raise o/ dnum = 1.5; status = OCINumberFromReal(err, &dnum, sizeof(double), &ornum); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberFromReal o/; status = OCINumberMul(err, tomsal, &ornum, tomsal); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberMul o/; /o double joe's salary o/ status = OCINumberAdd(err, joesal, joesal, joesal); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberAdd o/; /o get joe's salary in integer o/ status = OCINumberToInt(err, joesal, sizeof(inum), OCI_NUMBER_SIGNED, &inum); if (status != OCI_SUCCESS)/o goto to handle error from OCINumberToInt o/; /o inum is set to 24000 o/ /o get debbie's salary in double o/ status = OCINumberToReal(err, debsal, sizeof(dnum), &dnum); if (status != OCI_SUCCESS)/o goto to handle error from OCINumberToReal o/; /o dnum is set to 14400 o/ /o print tom's salary as DEM0001`8000.00 o/ buflen = sizeof(buffer); status = OCINumberToText(err, tomsal, "C0999G9999D99", 13, "NLS_NUMERIC_CHARACTERS='.`' NLS_ISO_CURRENCY='Germany'", 54, &buflen, buffer); if (status != OCI_SUCCESS)/o goto to handle error from OCINumberToText o/; printf("tom's salary = %s\n", buffer); /o compare joe and tom's salary o/ status = OCINumberCmp(err, joesal, tomsal, &result); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberCmp o/; /o result is positive o/ /o read debbie's new salary from string o/ status = OCINumberFromText(err, "48`000.00", 9, "99G999D99", 9, "NLS_NUMERIC_CHARACTERS='.`'", 27, debsal); if (status != OCI_SUCCESS) /o goto to handle error from OCINumberFromText o/; /o debbie's salary is now 48000.00 o/*//*----------------------------- OCINumberInc --------------------------------*/#if !defined(__STDC__) && !defined(__cplusplus) /* K&R C - not ANSI C */sword OCINumberInc(/*_ OCIError *err, OCINumber *number _*/);#else /* ANSI C */sword OCINumberInc( OCIError *err, OCINumber *number );#endif/* NAME: OCINumberInc - OCINumber INCrement numbers PARAMETERS: err (IN/OUT) - error handle. If there is an error, it is recorded in 'err' and this function returns OCI_ERROR. The error recorded in 'err' can be retrieved by calling OCIErrorGet(). number (IN/OUT) a positive Oracle number to be incremented DESCRIPTION: Increment Oracle number in place. It is assumed that the input is an integer between 0 and 100^21-2. If the is input too large, it will be treated as 0 - the result will be an Oracle number 1. If the input is not a positive integer, the result will be unpredictable. RETURNS:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -