# Codim 2 subvariety Cartier on a hypersurface containing it

This is a follow up question to my previous one, thanks to Karl and Angelo for their answers, and to the commenters: Smooth variety contained in another smooth variety

If $X$ is a local complete intersection (irreducible) subvariety of codimension two in $\mathbb P^n$ (we may assume $X$ is smooth if it helps, but I don't think it's necessary) then we know by Bertini's theorem there exists an irreducible hypersurface $Y$ containing $X$. Can we choose $Y$ such that $X$ is a Cartier divisor on $Y$ ?

• It is necessary for $X$ to be smooth, see page 179 of Hartshorne. – Christopher Perez Feb 23 '12 at 13:12
• I had an answer below, but I misread the question (I didn't see the word local). It has been deleted. – Karl Schwede Feb 23 '12 at 14:43

The Grothendieck-Lefschetz theorem implies that if $Y$ is complete intersection in $\mathbb P^n$ of dimension at least 3, any Cartier divisor on $Y$ is obtained by intersecting with a hypersurface ($Y$ does not have to be smooth). So if $Y$ exists $X$ is a complete intersection, and the previous discussion applies.