Esqlc - data headaches
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Working with Online 7.10 UC3, and Esqlc and totally puzzled about the following two problems. 1. I occasionally get a string where a character is expected from a char (1) field in the database. My translation to esqlc goes something like -- $string single[2] ; fetch ... into $single; fprintf( stdout, "%c" , *single ) ; I've tried other ways, like declaring it as a fixchar single[1], but no luck there either. 2. I've used host indicator variables for shorts, using the indicators to test for null, and occasionally getting what appears to be large integers back in my short host vars. Some sample very streamlined code: declarations: short myvar, myindicator; declare mycursor for select var into $myvar:myindicator from mytable where ..... ; open cursor fetch cursor test: if ( myindicator == 0 ) fprintf( stdout, "%d", myvar ) ; else fprintf( stdout, "0" ); The test appears to work but the host variable returns large integer values when there is valid short data. It looks like there may be an errant pointer, but I'd think this would blow the program up. Any clues? Thanks, Nick
In article <7b1ksj$8vg$1@news.xmission.com>, Nick Nobbe <nnob@loc.gov> writes > > >Working with Online 7.10 UC3, and Esqlc and totally puzzled about >the following two problems. > >1. I occasionally get a string where a character is expected from a > char (1) field in the database. My translation to esqlc goes something > like -- > > $string single[2] ; > > fetch ... into $single; > > fprintf( stdout, "%c" , *single ) ; > > I've tried other ways, like declaring it as a fixchar single[1], but > no luck there either. > >2. I've used host indicator variables for shorts, using the indicators > to test for null, and occasionally getting what appears to be large > integers back in my short host vars. Some sample very streamlined code: > > declarations: > short myvar, myindicator; > > declare mycursor for select var into $myvar:myindicator > from mytable where ..... ; > > open cursor > > fetch cursor > > test: > > if ( myindicator == 0 ) > fprintf( stdout, "%d", myvar ) ; %hd to print shorts... > else > fprintf( stdout, "0" ); > > The test appears to work but the host variable returns large integer > values when there is valid short data. > > It looks like there may be an errant pointer, but I'd think this would > blow the program up. Any clues? > > Thanks, > Nick > > > -- David Williams