Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   PRO*C question?? (http://www.go4expert.com/forums/proc-question-t1125/)

mich_elle 5Aug2006 02:15

PRO*C question??
 
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

shabbir 5Aug2006 14:37

Re: PRO*C question??
 
Probably the CampusID 75799 does not have an email address.

mich_elle 7Aug2006 17:49

Re: PRO*C question??
 
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.

shabbir 7Aug2006 18:19

Re: PRO*C question??
 
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

mich_elle 7Aug2006 18:31

Re: PRO*C question??
 
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.

shabbir 7Aug2006 21:20

Re: PRO*C question??
 
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.


All times are GMT +5.5. The time now is 02:20.