| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 9368 人关注过本帖
标题:翻译pb9的帮助文档
取消只看楼主 加入收藏
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
 问题点数:0 回复次数:11 
翻译pb9的帮助文档

我是学pb的新手,发现pb的帮助文件很有用,可惜是英文的,就试着翻译了一点,贴出来大家交流交流,欢迎大家指正。声明下,我不是英语专业的,而且是pb菜鸟,水平有限,望大家指教。

搜索更多相关主题的帖子: 文档 翻译 
2006-10-10 19:47
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

SetTransObject原文
Description
Causes a DataWindow control or DataStore to use a programmer-specified transaction object. The transaction object provides the information necessary for communicating with the database.

Controls
DataWindow type Method applies to
PowerBuilder DataWindow control, DataWindowChild object, DataStore object

Syntax
PowerBuilder
integer dwcontrol.SetTransObject ( transaction transaction )

Argument Description
dwcontrol A reference to a DataWindow control, DataStore, or child DataWindow in which you want to use a programmer- specified transaction object rather than the DataWindow control's internal transaction object.
transaction The name of the transaction object you want to use in the dwcontrol.

Return value
Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is NULL, in PowerBuilder and JavaScript the method returns NULL.

Usage
Transaction objects in PowerBuilder
A programmer-specified transaction object gives you more control over the database transactions and provides efficient application performance. You control the database connection by using SQL statements such as CONNECT, COMMIT, and ROLLBACK.
Since the DataWindow control does not have to connect to the database for every RETRIEVE and UPDATE statement, these statements run faster. You are responsible for committing and rolling back transactions after you call the Update method, using code like the following:
IF dw_Employee.Update()>0 THEN
COMMIT USING emp_transobject;
ELSE
ROLLBACK USING emp_transobject;
END IF
You must set the parameters required to connect to your DBMS in the transaction object before you can use the transaction object to connect to the database. PowerBuilder provides a global transaction object called SQLCA, which is all you need if you are connecting to one database. You can also create additional transaction objects, as shown in the examples.
To use SetTransObject, write code that does the following tasks:
1 Set up the transaction object by assigning values to its fields (usually in the application's Open event).
2 Connect to the database using the SQL CONNECT statement and the transaction object (in the Open event for the application or window).
3 Call SetTransObject to associate the transaction object with the DataWindow control or DataStore (usually in the window's Open event).
4 Check the return value from the Update method and follow it with an SQL COMMIT or ROLLBACK statement, as appropriate.

If you change the DataWindow object associated with the DataWindow control (or DataStore) or if you disconnect and reconnect to a database, the connection between the DataWindow control (or DataStore) and the transaction object is severed. You must call SetTransObject again to reestablish the connect.

example:
This statement causes dw_employee to use the default transaction object SQLCA:
dw_employee.SetTransObject(SQLCA)

This statement causes dw_employee to use the programmer-defined transaction object emp_TransObj. In this example, emp_TransObj is an instance variable, but your script must allocate memory for it with the CREATE statement before you use it:
emp_TransObj = CREATE transaction
... // Assign values to the transaction object
dw_employee.SetTransObject(emp_TransObj)

This example has two parts. The first script, for the application's Open event, reads database parameters from an initialization file called MYAPP.INI and stores the values in the default transaction object (SQLCA). The Database section of MYAPP.INI has the same keywords as PowerBuilder's own PB.INI file. The parameters shown are for a SQL Server or ORACLE database. The second script, for the window's Open event, establishes a connection and retrieves data from the database.
The application's Open event script populates SQLCA:
SQLCA.DBMS = ProfileString("myapp.ini", "database", "DBMS", " ")
SQLCA.Database = ProfileString("myapp.ini", "database", "Database", " ")
SQLCA.LogId = ProfileString("myapp.ini", "database", "LogId", " ")
SQLCA.LogPass = ProfileString("myapp.ini", "database", "LogPassword", " ")
SQLCA.ServerName = ProfileString("myapp.ini", "database", "ServerName", " ")
SQLCA.UserId = ProfileString("myapp.ini", "database", "UserId", " ")
SQLCA.DBPass = ProfileString("myapp.ini", "database", "DatabasePassword", " ")
SQLCA.lock = ProfileString("myapp.ini", "database", "lock", " ")
The Open event script for the window that contains the DataWindow control connects to the database, assigns the transaction object to the DataWindow, and retrieves data:
long RowsRetrieved
string LastName
// Connect to the database.
CONNECT USING SQLCA;
// Test whether the connect succeeded.
IF SQLCA.SQLCode <> 0 THEN
MessageBox("Connect Failed", "Cannot connect to database " + SQLCA.SQLErrText)
RETURN
END IF
// Set the transaction object to SQLCA.
dw_employee.SetTransObject(SQLCA)
// Retrieve the rows.
LastName = ...
RowsRetrieved = dw_employee.Retrieve(LastName)
// Test whether the retrieve succeeded.
IF RowsRetrieved < 0 THEN
MessageBox("Retrieve Failed", "Cannot retrieve data from the database.")
END IF

[此贴子已经被作者于2006-10-10 19:49:11编辑过]

2006-10-10 19:48
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

SetTransObject翻译

SetTransObject
描述
为了使一个数据窗口控件或数据仓库使用一个programmer-specified 事务对象。该事务对象提供了连接数据库所必需的信息。
控件
数据窗口类型: 该方法应用于:
PowerBuilder 数据窗口控件,数据窗口子对象?,数据仓库对象
Web ActiveX 数据窗口控件,数据窗口子对象
语法
PowerBuilder:
integer dwcontrol.SetTransObject ( transaction transaction )
Web ActiveX:
number dwcontrol.SetTransObject ( transaction transaction )
参数 描述
dwcontrol 一个关于数据窗口控件,数据仓库对象或数据窗口子对象的参数,该参数用在当你想使用programmer-specified事务对象而不是数据窗口内部事务对象的时候。
ransaction 你想使用数据窗口控件的事务对象的名字。
返回值
成功返回1,错误返回-1。如果任何一个参数值为null,返回null。
用法
programmer-specified会话对象提供了对数据库会话更强大的控制,并提供了更高效的请求功能。你可以使用诸如connect,commit和rollback等sql命令来控制数据库。
因为数据窗口对象并不是在执行每个retrieve和update命令时都会连接数据库,因此这些命令执行的速度会更快。在使用了update命令后,你还要使用commit或者rollback来是结果生效。如下代码所示:
IF dw_Employee.Update()>0 THEN
COMMIT USING emp_transobject;
ELSE
ROLLBACK USING emp_transobject;
END IF
在你能够使用事务对象连接数据库之前,你必须设置参数来连接该事务对象的DBMS。pb提供了一个全局事务对象SQLCA,它能够连接你需要的所有数据库。
为了使用SetTransObject,所写代码完成如下功能:
1,通过在内存中为会话对象分配值而建立该会话对象。
2,通过使用connect这个sql命令和该事务对象而与数据库建立连接。(in the Open event for the application or window).
3,调用SetTransObject函数来建立数据窗口控件(或数据仓)与事务对象的连接。
4,检查update命令的返回值并且酌情执行commit或rollback。
如果你改变了与数据窗口控件(或数据仓库)连接的数据窗口对象或如果你断开并重新连接到数据库,在
数据窗口控件(或数据仓库)与事务对象之间的连接会断开,你必须调用SetTransObject函数来重新建立连接。

例:
这个命令使de_employee使用缺省的事务对象SQLCA:
dw_employee.SetTransObject(SQLCA)
这个命令使de_employee使用programmer-defined 事务对象emp_TransObj。在该例子中,emp_TransObj是一个实例变量,但是你在使用它前必须使用脚本CREATE命令为它分配内存:
emp_TransObj = CREATE transaction
... // Assign values to the transaction object
dw_employee.SetTransObject(emp_TransObj)
这个例子有两个部分。第一部分的脚本从事先建立好的一个叫MYAPP.INI的文件中读取数据库参数并存储在缺省事务对象SQLCA中。数据库中MYAPP.INI的部分有和pb自己的PB.INI文件相同的关键字。显示的参数适用于SQL Server或ORACLE。第二部分的脚本建立了一个与数据库的连接并检索数据。
该请求open事件脚本构成了SQLCA:
SQLCA.DBMS = ProfileString("myapp.ini", &"database", "DBMS", " ")
SQLCA.Database = ProfileString("myapp.ini", &"database", "Database", " ")
SQLCA.LogId = ProfileString("myapp.ini", &"database", "LogId", " ")
SQLCA.LogPass = ProfileString("myapp.ini", &"database", "LogPassword", " ")
SQLCA.ServerName = ProfileString("myapp.ini", &"database", "ServerName", " ")
SQLCA.UserId = ProfileString("myapp.ini", &"database", "UserId", " ")
SQLCA.DBPass = ProfileString("myapp.ini", &"database", "DatabasePassword", " ")
SQLCA.lock = ProfileString("myapp.ini", &"database", "lock", " ")
该open事件脚本包括了将数据窗口控件连接到数据库,分配会话对象给数据窗口,并检索数据:
long RowsRetrieved
string LastName
// Connect to the database.
CONNECT USING SQLCA;
// Test whether the connect succeeded.
IF SQLCA.SQLCode <> 0 THEN
MessageBox("Connect Failed", &"Cannot connect to database " &+ SQLCA.SQLErrText)
RETURN
END IF
// Set the transaction object to SQLCA.
dw_employee.SetTransObject(SQLCA)
// Retrieve the rows.
LastName = ...
RowsRetrieved = dw_employee.Retrieve(LastName)
// Test whether the retrieve succeeded.
IF RowsRetrieved < 0 THEN
MessageBox("Retrieve Failed", &
"Cannot retrieve data from the database.")
END IF

[此贴子已经被作者于2006-10-11 18:25:23编辑过]

2006-10-10 19:50
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

Retrieve原文
Description
Retrieves rows from the database for a DataWindow control or DataStore. If arguments are included, the argument values are used for the retrieval arguments in the SQL SELECT statement for the DataWindow object or child DataWindow.

Syntax
PowerBuilder
long dwcontrol.Retrieve ( { any argument, any argument . . . } )

Return value
Returns the number of rows displayed (that is, rows in the primary buffer) if it succeeds and -1 if it fails.

Usage
After rows are retrieved, the DataWindow object's filter is applied. Therefore, any retrieved rows that do not meet the filter criteria are immediately moved to the filter buffer and are not included in the return count.

example:

This statement causes dw_emp1 to retrieve rows from the database.
dw_emp1.Retrieve()

This example illustrates how to set up a connection and then retrieve rows in the DataWindow control. A typical scenario is to establish the connection in the application's Open event and to retrieve rows in the Open event for the window that contains the DataWindow control.
The following is a script for the application open event. SQLCA is the default transaction object. The ProfileString function is getting information about the database connection from an initialization file:
// Set up Transaction object from the INI file
SQLCA.DBMS = ProfileString("myapp.ini", "Database", "DBMS", " ")
SQLCA.DbParm = ProfileString("myapp.ini","Database", "DbParm", " ")
// Connect to database
CONNECT USING SQLCA;
// Test whether the connect succeeded
IF SQLCA.SQLCode <> 0 THEN
MessageBox("Connect Failed", "Cannot connect to database." + SQLCA.SQLErrText)
RETURN
END IF
Open(w_main)
To continue the example, the open event for w_main sets the transaction object for the DataWindow control dw_main to SQLCA and retrieves rows from the database. If no rows were retrieved or if there is an error (that is, the return value is negative), the script displays a message to the user:
long ll_rowsdw_main.SetTransObject(SQLCA)
ll_rows = dw_main.Retrieve()
IF ll_rows < 1 THEN MessageBox( "Database Error", "No rows retrieved.")

This example illustrates the use of retrieval arguments. Assume :Salary and :Region are declared as arguments in the DataWindow painter and dw_emp has this SQL SELECT statement:
SELECT Name, emp.sal, sales.rgn From Employee, Sales WHERE emp.sal > :Salary and sales.rgn = :Region
Then this statement causes dw_emp1 to retrieve employees from the database who have a salary greater than $50,000 and are in the northwest region:
dw_1.Retrieve(50000, "NW")

This example also illustrates retrieval arguments. Assume dw_EmpHist contains this SQL SELECT statement and emps is defined as a number array:
SELECT EmpNbr, Sal, Rgn From Employee WHERE EmpNbr IN (:emps)
These statements cause dw_EmpHist to retrieve Employees from the database whose employee numbers are values in the array emps:
Double emps[3]
emps[1] = 100
emps[2] = 200
emps[3] = 300
dw_EmpHist.Retrieve(emps)

The following example illustrates how to use Retrieve twice to get data meeting different criteria. Assume the SELECT statement for the DataWindow object requires one argument, the department number. Then these statements retrieve all rows in the database in which department number is 100 or 200.
The script for the RetrieveStart event in the DataWindow control sets the return code to 2 so the rows and buffers of the DataWindow control will not be cleared before each retrieval:
RETURN 2
The script for the Clicked event for a Retrieve CommandButton retrieves the data with two function calls. The Reset method clears any previously retrieved rows, normally done by Retrieve. Here, Retrieve is prevented from doing it by the return code in the RetrieveStart event:
dw_1.Reset( )
dw_1.Retrieve(100)
dw_1.Retrieve(200)

2006-10-10 19:51
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

Retrieve翻译
Retrieve method (DataWindows)
描述
为数据窗口控件从数据库中检索数据行。如果包含条件,则条件值被用于数据窗口控件的select命令中的检索条件。
语法
pb:
long dwcontrol.Retrieve ( { any argument, any argument . . . } )
参数 描述
dwcontrol 应用于数据窗口控件,数据仓库,子数据窗口
argument 一个或多个值。该值是你想在定义好的dwcontrol中使用select命令的检索条件。
返回值:
如果成功,返回显示的行数,如果失败,返回-1。
用法:
在检索数据行后,数据窗口对象的过滤开始应用。因此,任何不符合过滤标准的检索行立即被送到过滤缓冲区,并且在不会被包括在返回行数中。
通常情况下,当你检索数据的时候,已经存在数据窗口控件中的数据行将被丢弃或被新的数据行取代。

例子:
这个命令使dw_emp1从数据库中检索数据行:
dw_emp1.Retrieve()
这个例子说明了如何在数据窗口中建立连接并检索数据。一个典型的情节是在application's Open event建立连接并在窗口的 Open 事件中检索数据。

下面的脚本用在请求open事件中。SQLCA是缺省的事务对象。ProfileString函数从建立好的文件中取得数据库信息。
// Set up Transaction object from the INI file
SQLCA.DBMS = ProfileString("myapp.ini", "Database", "DBMS", " ")
SQLCA.DbParm = ProfileString("myapp.ini", "Database", "DbParm", " ")
// Connect to database
CONNECT USING SQLCA;
// Test whether the connect succeeded
IF SQLCA.SQLCode <> 0 THEN
MessageBox("Connect Failed", "Cannot connect to database." + SQLCA.SQLErrText)
RETURN
END IF
Open(w_main)
继续该例子,w_main 的open事件用SQLCA为数据窗口控件建立一个事务对象并从数据库中检索行。如果没有行被检索到或出现错误,脚本传递给使用者一个信息。
long ll_rows
dw_main.SetTransObject(SQLCA)
ll_rows = dw_main.Retrieve()
IF ll_rows < 1 THEN MessageBox( "Database Error", "No rows retrieved.")

下面这个例子说明了如何使用参数检索。salsry和region已经作为参数在数据窗口画板中被声明,且dw_emp已经使用了select命令。
SELECT Name, emp.sal, sales.rgn From Employee, Sales WHERE emp.sal > :Salary and sales.rgn = :Region
然后这个命令使dw_emp1从数据库中检索salary超过50000并且在西北的雇员。
dw_1.Retrieve(50000, "NW")
这个例子也说明了如何使用参数检索。dw_emphist包括如下select命令
SELECT EmpNbr, Sal, Rgn From Employee WHERE EmpNbr IN (:emps)
这些命令使dw_emphist从数据库中检索那些雇员号在emps数组中的雇员。
Double emps[3]
emps[1] = 100
emps[2] = 200
emps[3] = 300
dw_EmpHist.Retrieve(emps)
下面的例子说明如何两次使用retrieve而得到满足不同标准的数据。假设select命令需要department number这个参数。然后该命令从数据库中检索所有满足department number是100或200的数据行。
该脚本使返回值为2,以便数据行和缓冲区不会在检索前清空。
RETURN 2
下面这个为clicked事件写的脚本通过使用两个函数检索数据。reset方法清空了以前由retrieve检索的数据,这里,通过在retrievestart中的返回值使retrieve到的数据被保存起来。
dw_1.Reset( )
dw_1.Retrieve(100)
dw_1.Retrieve(200)

[此贴子已经被作者于2006-10-11 18:27:21编辑过]

2006-10-10 19:51
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

多谢夸奖,又来了
Description

The SQL Select painter (also called the Select painter) is used in a variety of ways. You use the Select painter when you:

Choose the SQL Select data source when creating a new DataWindow or data pipeline
Edit the data source of a DataWindow object or data pipeline
Paste SQL in a script or function or in the Interactive SQL view in the Database painter
Create a view (of the data in one or more tables) in the Database painter

Using the painter

In the SQL Select painter, you can select one or more database tables to be used in a DataWindow object or data pipeline; select table columns to be retrieved from the database; join tables; define retrieval arguments; specify sorting, selection, and grouping criteria; and in some cases, save your work as a SQL query.

Table Layout view
In the Table Layout view, the Selection List shows the columns you select from the table(s) displayed. To add a column, select its name. To add all the columns in a table, choose Select All from the table's popup menu. To add a computed column, select the Compute tab to use the Compute view. Drag and drop columns to change their order.

Other views
Use the Sort, Where, Group, Having, Compute, and Syntax views at the bottom of the workspace to construct SQL statements.

描述
SQL Select painter(同样被称作Select painter)有多种使用方法。在如下环境下你可以使用:
当你创建数据窗口或者数据管道的时候选择SQL Select数据源
编辑数据窗口或者数据管道的数据源
将sql粘贴到脚本,函数或者数据库画板中的sql交互视图上
在数据库画板里创建一个视图(其数据来源于一个或者多个表)
使用数据画板
在SQL Select painter中,你可以选择一个或多个在数据窗口对象或者数据管道中使用的数据表;选择从数据库中检索的表列;联合表;定义检索参数;阐述排序方法,选择和分组标准;并且在某些情况下,将你的工作以sql查询的方式保存。
表的布局视图
在表的布局视图中,选择列表显示了你所选择的数据表。通过选择列名来添加它们。若要添加表中所有的列,选择表菜单上的“Select All ”。若要增加一个计算列,请通过使用Compute view来选择一个 Compute tab。拖动或放弃列来改变它们的顺序。
其它视图
通过使用workspace底部的Sort, Where, Group, Having, Compute, and Syntax 视图来构件sql命令

2006-10-10 21:46
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 
大家看有有哪些不准确的地方给我指出来啊.
2006-10-10 21:47
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

比如说programmer-specified和programmer-defined如何翻译?transaction object 翻译为"会话对象"合适么?

2006-10-10 21:57
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 
"不过transaction object 好像被叫做事务对像"

谢谢,已经改过来了啊.
2006-10-11 18:29
第三只眼睛
Rank: 1
等 级:新手上路
帖 子:49
专家分:0
注 册:2006-4-7
收藏
得分:0 

SetFilter

Description
Specifies filter criteria for a DataWindow control or DataStore.

Syntax
PowerBuilder
integer dwcontrol.SetFilter ( string format )

Return value
Returns 1 if it succeeds and -1 if an error occurs. The return value is usually not used.

Usage
A DataWindow object can have filter criteria specified as part of its definition. After data is retrieved, rows that don't meet the criteria are immediately transferred from the primary buffer to the filter buffer.
The SetFilter method replaces the existing filter criteria梚f any are defined for the DataWindow object梬ith a new set of criteria. Call the Filter method to apply the filter criteria and transfer rows that do not meet the filter criteria to the filter buffer.
The filter expression consists of columns, relational operators, and values against which column values are compared. Boolean expressions can be connected with logical operators AND and OR. You can also use NOT, the negation operator. Use parentheses to control the order of evaluation.
Sample expressions are:
item_id > 5
NOT item_id = 5
(NOT item_id = 5) AND customer > "Mabson"
item_id > 5 AND customer = "Smith"
#1 > 5 AND #2 = "Smith"
The filter expression is a string and does not contain variables. However, you can build the string in your script using the values of script variables. Within the filter string, string constants must be enclosed in quotation marks (see the examples).
Removing a filter To remove a filter, call SetFilter with the empty string ("") for format and then call Filter. The rows in the filter buffer will be restored to the primary buffer and positioned after the rows that already exist in the primary buffer.
example:
This statement defines the filter expression for dw_Employee as the value of format1:
dw_Employee.SetFilter(format1)
The following statements define a filter expression and set it as the filter for dw_Employee. With this filter, only those rows in which the cust_qty column exceeds 100 and the cust_code column exceeds 30 are displayed. The final statement calls Filter to apply the filter:
string DWfilter2
DWfilter2 = "cust_qty > 100 and cust_code >30"
dw_Employee.SetFilter(DWfilter2)
dw_Employee.Filter( )
The following statements define a filter so that emp_state of dw_Employee displays only if it is equal to the value of var1 (in this case ME for Maine). The filter expression passed to SetFilter is emp_state = ME:
string Var1
Var1 = "ME"
dw_Employee.SetFilter("emp_state = '"+ var1 +" '")

2006-10-11 18:30
快速回复:翻译pb9的帮助文档
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030365 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved