/* **++ ** FACILITY: DIBOL 2 ORACLE Server 7/8/9 gateway ** ** MODULE DESCRIPTION: ** ** It's a simple test programe to demonstarate and testing the DIBOL/ORA Gateway API. ** ** AUTHORS: ** ** Ruslan R. Laishev ** ** CREATION DATE: 15-MAR-2002 ** ** ** BUILD: ** ** $CC /INCLUDE=([],ORA_RDBMS,ORA_OCI_DEMO) ** $LINK DBL_ORAGTWY_EXAMPLE.OBJ,SYS$INPUT/OPT ** dev:[dir]DBL_ORAGTWY.EXE/SHARE ** ^Z ** ** ** MODIFICATION HISTORY: ** ** {@tbs@}... **-- */ /* ** ** INCLUDE FILES ** */ #include #include #include #include #include /* ** ** DIBOL 2 ORACLE Server 7/8/9 gateway data and structures definitions ** */ #include "dbl_oragtwydef.h" /* ** ** DIBOL 2 ORACLE Server 7/8/9 gateway routines declarations ** */ #include "dbl_oragtwy.h" #define INIT_SDESC(dsc, len, ptr) {(dsc).dsc$b_dtype = DSC$K_DTYPE_T;\ (dsc).dsc$b_class = DSC$K_CLASS_S; (dsc).dsc$w_length = (len);\ (dsc).dsc$a_pointer = (ptr);} void main (void) { int status,i; $DESCRIPTOR(oracons,"tessco/tessco@ora5"); char sku[] = "MOTOROLA",sup[] = "646444"; char short_name[2048],feature_name[2048],config[] = "PTYPE-213"; struct ora_rec ora; char buf[1024]; struct dsc$descriptor buf_dsc; /* ** Initalize the DBL_ORAGTWY layer, this routine must be called only once ** before calling any other routines of the API. */ if ( status = dbl_oragtwy$init(&oracons) ) printf("dbl_oragtwy$init:ORA-%d\n",status); /* ** Some test stuff... */ printf("dbl_oragtwy$itemlist_*...\n"); /* ** Open an ORACLE cursor */ if ( status = dbl_oragtwy$itemlist_oc(1) ) { /* ** Obtain a detail diagnostic from the current ORACLE cursor */ INIT_SDESC(buf_dsc,sizeof(buf),buf); dbl_oragtwy$getoramsg(&buf_dsc,&buf_dsc.dsc$w_length); /* ** Display error message */ printf("dbl_oragtwy$*_oc:ORA/OCI-%d,%.*s\n",status,buf_dsc.dsc$w_length,buf_dsc.dsc$a_pointer); } /* ** Performing a data fetching 10 times */ for( i = 0;i < 10; i++) { /* ** Fetching data */ if ( status = dbl_oragtwy$itemlist_fd(&ora) ) { /* ** Obtain a detail diagnostic from the current ORACLE cursor */ INIT_SDESC(buf_dsc,sizeof(buf),buf); dbl_oragtwy$getoramsg(&buf_dsc,&buf_dsc.dsc$w_length); /* ** Display error message */ printf("dbl_oragtwy$*_fd:ORA/OCI-%d,%.*s\n",status,buf_dsc.dsc$w_length,buf_dsc.dsc$a_pointer); } /* ** Display a couple fields from fetched record */ printf("ORATYPE:'%.*s',ORAITEM:'%.*s'\n",sizeof(ora.ORATYPE),ora.ORATYPE, sizeof(ora.ORAITEM),ora.ORAITEM); } /* ** Close cursor */ if ( status = dbl_oragtwy$itemlist_cc() ) printf("dbl_oragtwy$*_cc:ORA-%d\n",status); printf("dbl_oragtwy$get_oracle_sku...\n"); if ( status = dbl_oragtwy$get_oracle_sku (sku,sizeof(sku)-1,sup,sizeof(sup)-1,&ora) ) { /* ** Obtain a detail diagnostic from the current ORACLE cursor */ INIT_SDESC(buf_dsc,sizeof(buf),buf); dbl_oragtwy$getoramsg(&buf_dsc,&buf_dsc.dsc$w_length); /* ** Display error message */ printf("dbl_oragtwy$get_oracle_sku:ORA/OCI-%d,%.*s\n",status,buf_dsc.dsc$w_length,buf_dsc.dsc$a_pointer); } printf("ORATYPE:'%.*s',ORAITEM:'%.*s'\n",sizeof(ora.ORATYPE),ora.ORATYPE, sizeof(ora.ORAITEM),ora.ORAITEM); printf("dbl_oragtwy$item_catlist_*...\n"); if ( status = dbl_oragtwy$item_catlist_oc(sku,sizeof(sku)-1,sup,sizeof(sup)-1) ) printf("dbl_oragtwy$*_oc:ORA-%d\n",status); if ( status = dbl_oragtwy$item_catlist_fd(short_name,sizeof(short_name)-1,feature_name,sizeof(feature_name)-1) ) printf("dbl_oragtwy$*_fd:ORA-%d\n",status); if ( status = dbl_oragtwy$item_catlist_cc() ) printf("dbl_oragtwy$*_cc:ORA-%d\n",status); printf("dbl_oragtwy$brand_catlist_*...\n"); if ( status = dbl_oragtwy$brand_catlist_oc(sku,sizeof(sku)-1,sup,sizeof(sup)-1,config,sizeof(config)-1) ) printf("dbl_oragtwy$*_oc:ORA-%d\n",status); if ( status = dbl_oragtwy$brand_catlist_fd(short_name,sizeof(short_name)-1,feature_name,sizeof(feature_name)-1) ) { /* ** Obtain a detail diagnostic from the current ORACLE cursor */ INIT_SDESC(buf_dsc,sizeof(buf),buf); dbl_oragtwy$getoramsg(&buf_dsc,&buf_dsc.dsc$w_length); /* ** Display error message */ printf("dbl_oragtwy$*_fd:ORA/OCI-%d,%.*s\n",status,buf_dsc.dsc$w_length,buf_dsc.dsc$a_pointer); } if ( status = dbl_oragtwy$brand_catlist_cc() ) printf("dbl_oragtwy$*_cc:ORA-%d\n",status); /* ** Deallocate resourses */ dbl_oragtwy$shut(); }