Annotation of 42BSD/ingres/doc/other/equeldemo.q, revision 1.1

1.1     ! root        1: /*
        !             2: *  This is a sample EQUEL program. It assumes the
        !             3: *  presence of the EMPLOYEE relation inside the
        !             4: *  DEMO data base. To use the program, type an
        !             5: *  employee name and the program will either respond
        !             6: *  with the SALARY or with the message that
        !             7: *  the employee is not in the data base.
        !             8: *  Typing a '?' will result in the list of
        !             9: *  all names in the data base being printed.
        !            10: *
        !            11: *  Exit by typing a control-d
        !            12: *
        !            13: *  To compile and run this program do the following:
        !            14: *
        !            15: *  equel equeldemo.q
        !            16: *  cc    equeldemo.c -lq
        !            17: *  a.out
        !            18: */
        !            19: main()
        !            20: {
        !            21: ##     char    NAME[20];
        !            22: ##     int     SAL;
        !            23:        char    flag;
        !            24: 
        !            25: ##     ingres demo
        !            26: ##     range of e is employee
        !            27:        while (eread(NAME))
        !            28:        {
        !            29:                if(NAME[0] == '?')
        !            30:                {
        !            31: ##                     retrieve (NAME=e.name)
        !            32: ##                     {
        !            33:                                printf("%s\n",NAME);
        !            34: ##                     }
        !            35:                        continue;
        !            36:                }
        !            37:                flag = 0;
        !            38: ##             retrieve (SAL = e.salary) where
        !            39: ##             e.name = NAME
        !            40: ##             {
        !            41:                        printf("The salary of %s is %d\n",NAME,SAL);
        !            42:                        flag = 1;
        !            43: ##             }
        !            44:        if(!flag) printf("%s is not in the data base\n",NAME);
        !            45:        }
        !            46: ##     exit
        !            47: }
        !            48: 
        !            49: eread(p)
        !            50: char   *p;
        !            51: {
        !            52:        char    c;
        !            53:        printf("enter name:");
        !            54:        while(c = getchar())
        !            55:        {
        !            56:                if(c == '\n')
        !            57:                {
        !            58:                        *p = 0;
        !            59:                        return(1);
        !            60:                }
        !            61:                *p++ = c;
        !            62:        }
        !            63:        return(0);
        !            64: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.