Create a. bat file to delete information from a given table in postgresql

Asked

Viewed 78 times

0

I am trying to perform a delete in postgre via bat file, I need it to be so due to a particularity of the system I am adjusting.
However, I run the file and it doesn’t delete, I tried including a commit even though it didn’t work. O . bat is as follows:

@echo off
set PGPASSWORD=#abc123#
cd "C:\Program Files\PostgreSQL\9.6\bin"
psql -h localhost -p 5432 -U postgres -d BANCO_TESTE -c "delete from wfiscal.wfiscal where section = 'Impressão de DARF';"
  • You have a wfiscal table inside a wfiscal schema?

  • Remove the @echo off to verify the error that occurs when executing the query, after verifying the error and making the correction put the @echo off back..

  • Yes, a wfiscal scheme and the wfiscal table within that scheme.

  • @Danizavtz I did the test that spoke, does not accuse error, it just informs DELETE 0

  • Guys, I found the problem, in the column the information has an accent in print, when performing the hit it does not recognize the special character, getting different, I did the test changing and removing the accent and it worked

  • Could you check again if the element was deleted on the first run? Another thing is that you pass the -d BANCO_TESTE parameter. The only conclusion I can come to is that it may be an encoding problem, because of the accent ã and because it is windows. I could do a test with a string that has no accent?

  • @Danizavtz is the same problem, I tested minutes before his answer, if I put a string without accentuation it deletes, I thought to use a like for Deleter, but then he does not recognize the % also by what I saw, I’ll have to get a form of rum update wheel before delete to remove this accent

  • Check if by setting the client encoding resolve, I found this answer that can help: https://answall.com/questions/321194/comordefinir-o-set-client-encoding-utf8-permanent, another alternative is to try to remove by an attribute integer)

  • I thought in Wheel rum update removing the accent, Focusing as I can filter through another column, I mounted another filter in delete excluding the lines based on a column that has no accent, so it worked out, anyway thanks a lot for the tips!

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.