[Solved] Mysql error handling if user doesn't have privilege

dBase, Calc, CSV, MS ACCESS, MySQL, PostgrSQL, OTHER
Post Reply
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

[Solved] Mysql error handling if user doesn't have privilege

Post by ponlerd »

Hi, I have a Mysql database linked to Base. I have also set that some users cannot update a specific column in a table.
Problem is, when I run the macro to update the table, if the user that does not have the permission to update runs it, there is an error and the user will see the BASIC editor.

Is there a way to prevent this happening? some kind of error handling?

Thanks for all help(again)
Ponlerd
Last edited by ponlerd on Thu May 06, 2010 4:15 am, edited 1 time in total.
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Mysql error handling when user does not have privilege

Post by RPG »

Hello

I think make a basic error handler.

You
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

Re: Mysql error handling when user does not have privilege

Post by ponlerd »

Sorry for the question, got it, actually it's a basic error handler like you said. I just missed the part that the On Error goto statement has to be at the most beginning line of the sub.
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: [Solved] Mysql error handling if user doesn't have privi

Post by RPG »

Hello

In HSQLDB you can asked what user is activ. When you asked the username you can maybe change the state of u buttun for the current user.
I did only think later to this.
I think it is better work in this way then waiting on the error.

Code: Select all

call current_user
call user()
I think there is no reason to have the on error statement on the first line of the sub. It must before the statement want is the reason of the error.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
ponlerd
Posts: 56
Joined: Sun Nov 15, 2009 6:22 pm
Location: Bangkok, Thailand

Re: [Solved] Mysql error handling if user doesn't have privi

Post by ponlerd »

Yep, i thought about the idea of changing the button status also, i did one database on Access using this method, so i had to have a table containing the username and kind of like types of users (admin, user) , this time i tried setting the privileges on mysql, since i think it's more secure, because someone with knowledge can get inside the code and easily see what is happening.
But once you mentioned about workflow, maybe you're right, if i don't want a user to do something just disable the button so he can't press it.
So i guess i might do both!(have to put in some more effort...)

I tried not putting the on error statement on the first line, and it didn't work. maybe i was doing something wrong, but i got this info from the wiki page i think
http://wiki.services.openoffice.org/wik ... r_Handling
It does not explicitly say it, but in the example code at the end, it says ' ' Define error handler at the start of the function

Code: Select all

Sub Example
  ' Define error handler at the start of the function 
  On Error Goto ErrorHandler   
    ' ... Here is the actual program code
  On Error Goto 0           ' Deactivate error handling
    ' End of regular program implementation
  Exit Sub
 
 ' Start point of error handling
 ErrorHandler:                
   ' Check whether error was expected
    If Err = ExpectedErrorNo Then   
      ' ... Process error
    Else
      ' ... Warning of unexpected error
    End If
 On Error Goto 0            ' Deactivate error handling 
End Sub
OOo 3.2 Ubuntu 9.04 / OOo 3.2 Windows7 / Migrating from Access
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: [Solved] Mysql error handling if user doesn't have privi

Post by RPG »

Hello

I donot know if you have found this information. The macro is made by Sliderule
I knew it is for HSQLDB but I think MySQL does have maybe the same possibilities. Maybe all the information is already in your database.

I have use the onerror in the middle of a sub whithout problems.

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
Post Reply