2015년 1월 26일 월요일

[Power Builder] datawindow.Update() option Example

오랜시간 PowerBuilder 사용하고 있으나 실상을 뒤집어 보면 아는게 별로 없는 허접한 개발자 맞다. 이제서야 정확한 이 옵션의 의미를 이해 했다는 것은 편의성이 가져다 주는 오만함을 심어 줬던것은 아니었을까. 역시나 내 무식함을 오늘도 한번 다시 느낀다.

Reference URL
http://infocenter.sybase.com/archive/index.jsp?topic=/com.sybase.help.pb_10.5.pbug/html/pbug/BHBHDIEG.htm


Example
Consider this situation: a DataWindow object is updating the Employee table, whose key is Emp_ID; all columns in the table are updatable. Suppose the user has changed the salary of employee 1001 from $50,000 to $65,000. This is what happens with the different settings for the WHERE clause columns:

If you choose Key Columns for the WHERE clause, the UPDATE statement looks like this:

UPDATE Employee
SET Salary = 65000
WHERE Emp_ID = 1001
This statement will succeed regardless of whether other users have modified the row since your application retrieved the row. For example, if another user had modified the salary to $70,000, that change will be overwritten when your application updates the database.

If you choose Key and Modified Columns for the WHERE clause, the UPDATE statement looks like this:

UPDATE Employee
SET Salary = 65000
WHERE Emp_ID = 1001
   AND Salary = 50000
Here the UPDATE statement is also checking the original value of the modified column in the WHERE clause. The statement will fail if another user changed the salary of employee 1001 since your application retrieved the row.

If you choose Key and Updatable Columns for the WHERE clause, the UPDATE statement looks like this:

UPDATE Employee
SET Salary = 65000
WHERE Emp_ID = 1001
   AND Salary = 50000
   AND Emp_Fname = original_value
   AND Emp_Lname = original_value
   AND Status = original_value

댓글 없음:

댓글 쓰기

언제 부터 였던가 생각해보니 아르바이트 겸 외부 컨설팅을 의뢰 받고 맥북 프로를 처음 써봤을 때 부터 였던 것 같다. 지금은 거의 대부분의 작업을 맥으로 작업을 하다 보니 윈도우에서만 실행되는 일부 프로그램들 때문과 회사 내부 ERP프로그램이 윈도우 ...