PRO*C question??

Discussion in 'C' started by mich_elle, Aug 4, 2006.

  1. mich_elle

    mich_elle New Member

    Joined:
    Aug 4, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I have a .pc (proc program) with a function that should select from the database a student's email address and put it in a variable.

    This works correctly, except everytime, the first email address is blank,...I have double checked this and there is an email address for this person. Am I missing something silly?'
    Code:
    int getGoremalEmailAddress()
    {
            printf("Campus ID<%s>\n",campus_id);
            login_oracle();
            EXEC SQL SELECT goremal_email_address
                     INTO :email_address
                     FROM goremal
                     WHERE goremal_pidm = :campus_id;
            email_address.arr[email_address.len] = '\0';
            printf("E_MAIL<%s>\n",email_address.arr);
            logout_oracle();
            return 1;
    }
    Outputs:
    Campus ID<75799>
    E_MAIL<>
    Campus ID<2003142>
    E_MAIL<kabdull1@test.edu>
    Campus ID<2241834>
    E_MAIL<iabramek@test.edu>

    thanks in advance
     
    Last edited by a moderator: Aug 5, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Probably the CampusID 75799 does not have an email address.
     
  3. mich_elle

    mich_elle New Member

    Joined:
    Aug 4, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    It does have an email, I double checked this.

    It does this for every file I run with, It prints all except the very first one.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Then probably the 0th element of email_address.arr contains '\0' or a space or something like that. Use a printf statement in a for loop to print sufficient amount of data stored in email_address.arr and check
     
  5. mich_elle

    mich_elle New Member

    Joined:
    Aug 4, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I thought of that, so I actually set email_address = "NULL";
    and then do a printf of email_address and it prints out the word NULL

    then when I call the function, for email addressess,

    it always prints the first one blank, when I know for sure there is an email address (I manually use a select statement in pl/sql)
    and prints all the other addresssess???

    very weird error....

    thx.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    NO what I meant is email_address.arr is an array of characters but when you print them using %s in printf it prints till it finds the first '\o' if the zeroth element contans that '\0' then probably it will assume the array to be blank and so try printing characters from place 1 and see what it contains.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice