I try to import a csv file in a table in PostgreSQL 13 and php form (beginner).
There are two foreign keys integer type in the table, one can be empty. So when I import the file I have the common message invalid input syntax for type integer
for one of them.
Following this post, NullIf() function seems to be a simple solution.
I can't find the right way to use it in :
$sql = "INSERT INTO activite.us (numus, gidgeo, gidaxe)
VALUES ('".$getData[0]."','".$getData[10]."', NULLIF('".$getData[11]."', '') " ;
The foreign key is the last variable.
- I tried to replace second arg with NULL ;
- I tried
'NULLIF("...")'
and some others false combo.
How to fix that ? Thanks.