Re: Select from esql/c-2
Posted in 1998
You need to do as following:
$char[8] inputDate;
inputDate="19971126"
You selection will be correct.
At 02:44 PM 4/23/98 +0400, Irina Kotlova wrote:
>Hello!
>
>Unknown problems with cursor (OnLine 5.0 under Solaris 2.5.1). Could anybody
>advise anything? There are 13 records in DB, satisfying the condition and
>seeing in "dbaccess", but no records are retrieved neither by the user, nor
>by "root". The code is bellow.
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>#define NUMBERMESSAGESSENT_ANNOUNCE "records were discovered by \\"snap\\""
> /* includes for SQL */
>$include sqlca;
>int main()
>{
> /* Declare variables for SQL query */
> $int InputDate, tag, transkind;
> int MessNumber = 0;
> char buffer[15]; /* record buffer */
>
> /* Date setting */
> InputDate = 19971126;
> $database school;
> $declare scursor cursor for
> select tag
> into $tag
> from user_transactions
> where tdate = $InputDate and $transkind = 3;> $begin work;
> $open scursor;
> for(;;)
> {
> $fetch scursor;
> if (sqlca.sqlcode != 0) break;
> sprintf(buffer, "%d", tag);
> printf("%s\\n", buffer);
> MessNumber++;
> }
> $close scursor;
> $commit work;
> printf("\\n%d %s\\n", MessNumber, NUMBERMESSAGESSENT_ANNOUNCE);
> exit(0);
>}
>
>Irina Kotlova
>
>
>
>
Paul Hsu
SKECHERS USA
228 Manhattan Beach Blvd
Manhanttan Beach, CA 90266
Phone : (310) 3183100 X 1287
Fax : (310) 3185019
E-mail: paulh@skechers.com