I’m coding a C++ application that needs to interact with a postgres DB.
I would like to initialize the table datas using a COPY statement.
Here’s the code :
EXEC SQL BEGIN DECLARE SECTION ;
const char * fileData_name = file_data_name ;
EXEC SQL END DECLARE SECTION ;
EXEC SQL COPY datas
FROM :fileData_name
WITH (FORMAT text, DELIMITER '|') ;
Here’s the error message from ecpg :
ERROR: syntax error at or near ":fileData_name"
According to the postgres documentation :
This style of inserting C variables in SQL statements works anywhere a value expression is expected in an SQL statement.
If COPY stuff FROM field, then my guess is that field is not a value expression.
Any help ?
thx 🙂
Well, it’s not possible to do that… according to this post. But it’s possible to use prepared statements :