PRO*C question??

mich_elle's Avatar, Join Date: Aug 2006
Newbie Member
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: C
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 shabbir; 5Aug2006 at 14:32.. Reason: Code formating.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Probably the CampusID 75799 does not have an email address.
0
mich_elle's Avatar, Join Date: Aug 2006
Newbie Member
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.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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
0
mich_elle's Avatar, Join Date: Aug 2006
Newbie Member
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.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
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.