Consider a scheme $X$ which is: noetherian, regular, integral. All these properties should be enough to ensure the isomorphism: $\operatorname{Cl }(X)\cong \operatorname{Pic (X)}$. If something is missing, please add the conditions you like on $X$. Here it's important to point out that we formally don't have the equality between $L$ and $\mathcal O_X(D)$.
Now fix an invertible sheaf $L$ on $X$, and suppose that $D$ is a (Cartier or Weil, here it doesn't matter) divisor on $X$ such that $\mathcal O_X(D)\cong L$. In other words $\mathcal O_X(D)$ and $L$ induce the same element in $\operatorname{Pic (X)}$.
Can we always find a rational section of $L$ such that $\operatorname{div}(s)=D$?
Glossary:
- $\mathcal O_X(D)$ is the invertible sheaf associated to the divisor $D$.
- A rational section of $L$ is an element $s\in H^0(X,L\otimes K(X))$. Even if $L$ might not have global sections, rational sections always exist.
- $\operatorname{div}(s)$ is the divisor associated to the rational section $s$. This is a standard contruction similar to the construction of divisors on Riemann surfaces associated to meromorphic functions.
Many thanks
I'll show that given a completely arbitrary scheme $X$ and a completely arbitrary Cartier divisor $D$, the locally free sheaf $\mathcal O(D)$ has a rational section whose associated divisor is precisely $D$.
1) First let me show how, given a locally free sheaf of rank one $\mathcal L$ on $X$, we associate to a rational section $\sigma \in \Gamma_{\operatorname {rat}}(X,\mathcal L)$ a Cartier divisor $D=D_\sigma$:
Choose an open covering $(U_i)$ on which we have trivialisations $\mathcal L\vert U_i\cong \mathcal O_X\vert U_i$ and transport $\sigma \vert U_i \in \Gamma_{\operatorname {rat}}(U_i,\mathcal L)$ to $s_i\in \Gamma_{\operatorname {rat}}(U_i,\mathcal O_X)=Rat(U_i)$.
The collection $(U_i, s_i)$ then defines the Cartier divisor $D_\sigma\in \operatorname {CaDiv(X)}$
2) Let us apply this to the case where we start with a Cartier divisor $D\in \operatorname {CaDiv(X)}$ given by the open covering $(U_i)$ of $X$ and the rational functions $f_i\in Rat(U_i)$.
The locally free sheaf $\mathcal O(D)$ then comes with the trivialisations $$\mathcal O(D)\vert U_i\cong \mathcal O_X\vert U_i:g\mapsto g\cdot f_i$$ The required rational section $\sigma_D$ of $\mathcal O(D)$ is then just the constant function $1$ seen as the section $\sigma_D =1 \in \Gamma_{\operatorname {rat}}(X,\mathcal O(D))\subset \Gamma_{\operatorname {rat}}(X,Rat )$
(Recall that by definition $\mathcal O(D)\subset Rat$, the sheaf of rational functions on $X$).
Indeed in the displayed trivializations the sections $\sigma _D\vert U_i=1\in \Gamma_{\operatorname {rat}}(U_i,\mathcal O(D))$ get transported to the rational functions $1\cdot f_i\in Rat(U_i)$ and the associated divisor $D_{\sigma_D}$ given by the family $(U_i,f_i)$ is exactly the divisor $D$ we started with .
Conclusion: $\sigma_D$ is the rational section of $\mathcal O(D)$ with divisor $D$ which you required