Jump to content
StavA

Unable to delete one row in database

Recommended Posts

Hi there!

I am a relatively new Labview user, and this is my First post on these forums. I posted an issue on the NI forums, but figured it wouldn't hurt to look elsewhere for help. Below is a link to my issue outlined on the NI forums, but i shall do so again.

Link to first thread:

http://forums.ni.com/t5/LabVIEW/Unable-to-delete-one-row-from-Database/m-p/3340518/highlight/false#M981003

Setup: postgresql database with table clust, in the public schema. This table has 3 columns; user, password, privilege. This table has 2 test entries; the first entry (alex, 123, 123) and second entry (mike, 456, 456)

What i am trying to do: delete one row from a table in my database.

What is happening: When i try to delete the entry alex, it deletes all the entries. When i try to delete mike, nothing happens.
Below are 2 images of an extremely simple VI running, and completing without error, except what i outlined above. Hopefully someone knows what is going on, as i really have no clue.

Thanks for reading,

StavA

 

deletequery.png

deletequeryfollowup.png

Edited by StavA

Share this post


Link to post
Share on other sites

try

DELETE FROM %s WHERE 'user' ILIKE '%%%s%%';

maybe the data has inadvertent spaces or capitlisation

Edited by ShaunR

Share this post


Link to post
Share on other sites

HI ShaunR, thank you for taking a look at my problem and providing a potential solution. Unfortunately, it was not successful. Here is a screenshot of the suggested change and the output, which runs fine. However the entry (mike, 456, 456) still remains in the database.

deleterow3.png

Share this post


Link to post
Share on other sites

Can you show the result of a query that returns all rows before and after you have tried to delete?

BTW. It is better to post a snippet or the actual VI you are using than normal images.

Share this post


Link to post
Share on other sites

If all you are doing is querying a DB you may not notice that you are implicitly inside a transaction.  To make changes that are available outside the current session you need to explicitly commit.

Share this post


Link to post
Share on other sites

Thanks for everyones responses to my query. I found out the problem. The problem isn't in Labview, it was in postgreSQL. Specifically, the column 'user' is a reserved key word, and it just so happened that the owner of the database is named alex. So what was happening was whenever i specified to delete from table where user = 'alex', it would delete everything that belonged to the owner, alex. The simple fix is to not use the keyword 'user', instead using name or userid. That resolved the issue. Basically, the stars aligned to cause me a world of grief.

Anyways, this post can be marked as resolved/closed/ended.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.