Question : Effects of row locking using a SQL JOIN query and table permissions?

I have a situation where I need to be able to selectively lock specific rows in a table, while allowing the remaining rows to be updated. The data I want be able to lock is currently in a single SQL Server 2005 table and is viewed by an Access 2003 MDB application via a table link.

I was given the suggestion to create 2 identical tables and 1 stored procedure. One table would have read/write/update permissions for our user base and would contain only rows that can still be edited, whereas and the 2nd table would only have read permissions, except for the stored procedure, which would only have write permissions to the 2nd table. If a row needs to be locked, then the stored procedure would copy the row to be locked from the 1st table to the 2nd one.

My question is this: if I read the data from these two tables as a JOIN query to create a single view in the MDB app, will the SQL row locking remain for the rows that came from table 2?


Answer : Effects of row locking using a SQL JOIN query and table permissions?

Using command line tools to export data from a MySQL database into a CSV file is quite easy. Here's how:

mysql -uexampleuser -pletmein exampledb -B -e "select * from \`person\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv

Here is some sample output of the above:

"id","username","group","password"
"1","tux","admin","5f4dcc3b5aa765d61d8327deb882cf99"
"2","tlugian","admin","5f4dcc3b5aa765d61d8327deb882cf99"
"3","saiyuki","admin","5f4dcc3b5aa765d61d8327deb882cf99"
"4","fred","staff","5f4dcc3b5aa765d61d8327deb882cf99"
"5","barney","staff","5f4dcc3b5aa765d61d8327deb882cf99"
"6","wilma","admin","5f4dcc3b5aa765d61d8327deb882cf99"

And now for the explanation:

Starting with the MySQL command. I wont explain the -u and -p options they are straight forward (if in doubt man mysql). The -B option will delimit the data using tabs and each row will appear on a new line. The -e option denotes the command to run once you have logged into the database. In this case we are using a simple SELECT statement.

Onto sed. The command used here contains three seperate sed scripts:

s/\t/","/g;s/^/"/        <--- this will search and replace all occurences of 'tabs' and replace them with a ",".

;s/$/"/;    <--- This will place a " at the start of the line.

s/\n//g    <---- This will place a " at the end of the line.

After running the result set through sed we redirect the output to a file with a .csv extension.
Random Solutions  
 
programming4us programming4us