Using generalized hypergeometric functions in several variables in a Bayesian context, we compute the exact minimum double-sample size (n1,n2) required in the Bernoulli sampling of two independent populations, so that the expected length (or the maximum length) of the highest posterior density credible interval of P=P1-P2 is less than a preset quantity, where P1 and P2 are two independent proportions. This precise and computer-intensive aproach permits the treatment of this Bayesian sample size determination problem under very general hypotheses and also provides a relationship between the minimal values of n1 and n2. Similar results are derived in an applied Bayesian decision theory context, with a quadratic loss function, and the criteria used are now the posterior risk, the Bayes risk and the expected value of sample information.