0 votes
ago in SoSci Survey (dt.) by s316871 (150 points)

Hi ! How can I delete the database for contents for ONLY IN THE CONDITION that the database for contents previously had some data in it ? If the database for contents is already without any data then I do not want to delete anything as there is nothing there.
So for example if a user uploads some files multiple times, I only want the data from the newest file or the latest uploaded file. The database for contents should just contain the last uploaded data and everything else should be deleted.
I thought of an if statement which goes like :

if (database for contents == something)
dbDelete ( '' );
else (leave the database as it is)

Please let me know if it makes sense otherwise I can explain further.

ago by SoSci Survey (344k points)
Are we talking about "there is a specific entry" or "there is any entry" in the database for contents?

This is important, because the database is valid for the whole project, not just for a single respondent.
ago by s316871 (150 points)
Hi ! I am just talking about any single entry in the database. If a respondent is uploading multiple files , I just want the data(in Database for Contents) from the newest file they upload.

1 Answer

0 votes
ago by SoSci Survey (344k points)
selected ago by s316871
 
Best answer

I am just talking about any single entry in the database. If a respondent is uploading multiple files , I just want the data(in Database for Contents) from the newest file they upload.

Thank you for the clarification. I assume you have some respondent ID (such as the SERIAL) to identify unique respondents.

There are three approaches for your use case:

(1) Use dbGet() - if the result is NULL then there is no entry yet.

(2) Simply use dbSet(), it will overwrite the existing entry by default, so you'll always have the latest entry in the database.

(3) Do not use the database at all, but panelRecords() to eventually retrieve the most recent data for a person.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...