星期四, 六月 28, 2007

Oracle连接不识别的格式问题

经常我们直接手动编辑c:\oracle\ora92\network\ADMIN\tnsname.ora后会有报错不能分解服务器。比如:

 SERVICE =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hostaddress.com)(PORT = 1234))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = SERVICE)
    )
  )

以下是解决方法(斜体字的部分用实际的域名等代替):

 

方法之一是先看看是不是在c:\oracle\ora92\network\ADMIN\sqlnet.ora下面设置了domain,

NAMES.DEFAULT_DOMAIN = domain.net

如果有,把这一行用#号注释掉。有时候这样就可行了。

 

方法二:如果不行,试试以下方法:

先用命令窗口打 tnsping SERVICE

如果出现不能分解的报错,说明是真的不能连接,否则可能是其它代码错误(尤其是用bat连oracle的时候)。

那么用UltraEdit或者记事本打开tnsname.ora,看看

 SERVICE =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = hostaddress.com)(PORT = 1234))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = SERVICE)
    )
  )

这样的设置每一个SERVICE = 前面是不是都顶格的,正确格式SERVICE前不能有空格!很多不能连接都是因为,你在手动回车添加一个service的时候,UltraEdit给自动加了一个空格在行首。用Oracle自带的配置工具就不会有这个问题。

方法三:所以,如果方法二仍旧不能解决,那就用Oracle自带的配置向导,开始-》程序-》Oracle - Oracle Home92 -》 Configuration and Migration Tools-> Net Manager -> 本地-》服务命名

如果服务命名里面一个都显示不出来,那就把你的tnsname.ora里面不能连上的service删掉,留下能连上的,保存,重新点击“服务命名”,就会出来服务名,然后点左边的绿加号,鼠标放上去会显示“创建”的,就会有向导教你添加了。添加的时候关闭tnsname.ora,添完打开,就可以看到系统自动按照以上的格式把service添加进去了。

星期二, 六月 26, 2007

PLSQL tips

is not null

null should use "is", not "="

(taught, but easy to forget, and important!!!)

 

group functions like AVG, SUM... will dismiss the NULL values

 

NVL (colA, -1) replace all NULL values by -1 when selection

NVL2 (colA, -1, 2) replace all NULL values by -1 when selection, and replace others by 2. 

NULLIF (A, B, C) returns NULL if A = B, else returns C

 

Oracle password is not case sensitive, and should not use characters like "&"

 

row_number() function

can solve the select numbers of lines with each restrict

 

LIKE 'Clear%' 

'%' can stand for many characters, and if '%' happens on the beginning, INDEX is no use.

'_' can stand for one characters

 

rownum

don't write:

select ... where rownum = 2;

because the first row is not selected, so the second row's rownum is still 1...

 

CONCAT is the same as '||'

 

LPAD, RPAD

add some characters to the left or right part of a string

 

CEIL, FLOOR

CEIL (4.1) = 5

FLOOR (4.9) = 4

TRUNC and used on number, time...

 

CASE in SQL

SELECT ... CASE

WHEN ... THEN ...

WHEN ... THEN ...

END

 

in OUT JOIN

LEFT OUT JOIN should mention the difference between:

LEFT OUT JOIN ... ON (... AND ...)

LEFT OUT JOIN ... ON ... WHERE ...

 

SELECT * INTO valueA WHERE ...

if there's nothing returns from SELECT, there will be ERROR, coz no value given to valueA .

but if

SELECT COUNT (*) INTO valueA WHERE

then it is ok, coz COUNT (*) returns zero.

 

update tableA

set colA = XXX

where exist

select ...

from tableA and tableB 

where tableA.x = tableB.x 

星期四, 六月 21, 2007

WinRunner和QTP比较

原文 http://www.rickyzhu.com/2007/03/14/winrunner-vs-qtp/

很多初入行的朋友使用测试工具进行功能测试的时候,总是会遇到QTP和WinRunner的选择问题,为什么同样一家公司会出两个功能类似的工具哪? 下面是一篇关于这两个工具的对比介绍,其实从我自己的经验来看,WinRunner虽然推出较早,但是因为一些功能的缺陷,导致后期很难推广,而 Quick Test Professinal(QTP)虽然没有师兄WinRunner出道早,然后内功深厚,所以很受欢迎,而且Mercury公司以后的主要发展策略是 QTP,虽然文章中说并没有计划Phase out WR,但是已经不再出新版本了. 针对这两个工具的3年左右的使用经验,我的感受是WR比QTP的逊色的地方主要是几点:

1. WR的对象管理不如QTP那么有效

2. WR的语言主要是基于类C的TSL,是Mercury发明的语言,明显不如基于VBScript的QTP强

3. WR的稳定性不行,而且无意人为的干扰可能导致回放的失败

4. WR对Java的支持也不如QTP那么强

WinRunner vs. QuickTest Pro

Quick Comparison


11



Overview

Today Mercury has two functional testing tools – WinRunner (WR) and QuickTest Professional (QTP). WinRunner has been around since about 1995 while QuickTest Pro has been available since about 2002. We have lots of companies asking us “What’s the difference between WinRunner and QuickTest Pro?” and “If they are both functional testing tools from the same company, then which one of the tools should we use?” This document was developed as a short simple reference in helping to understand the basics about the tools in order to answer these two questions.

Mercury’s position on the two tools is this:

* The strategic direction for Mercury and its customers for Functional Testing is product integration. The new releases of QTP and WR improve already existing integration where customers can leverage complete WinRunner assets (scripts/functions) from QuickTest Pro without any modification to these assets.

* QuickTest Pro 8 has recently been released and WinRunner version 8.0 is planned for November 2004. There are no plans to phase out WinRunner.

* QuickTest Pro remains Mercury’s prime product for best customer satisfaction and experience. For customers who need both products, Mercury continues to offer Mercury Functional Testing as a combined package of both product offerings. The Business Process Testing system will be extended to incorporate components designed in WinRunner for the WinRunner 8.0 release in November.



WinRunner Compared to QuickTest Pro

Environment Coverage Comparison:

* Common environments shared by both WinRunner and QuickTest Pro:

Web-Related Environments

IE, Netscape, AOL

JDK, Java Foundation Classes, AWT

Symantec Visual Café

ActiveX Controls

ERP/CRM

Oracle: Jinitiator, 11i, NCA

Custom Client Server

Windows

C++/C

Visual Basic

Operating Systems

Windows 98, 2000, NT, ME, XP

Legacy

3270, 5250 Emulators

VT100

* WinRunner Only Environments:

Custom Client/Server

PowerBuilder

Forte

Delphi

Centura

Stingray

SmallTalk

ERP/CRM

Baan

PeopleSoft Windows

Siebel 5, 6 GUI Clients

Oracle GUI Forms

* QuickTest Pro Only Environments:

ERP/CRM

SAP

Siebel 7.x

PeopleSoft 8.x

.Net

WinForms

WebForms

.Net controls

Web Services

XML, HTTP

WSDL, SOAP

J2EE, .Net

Multimedia

RealAudio/Video

Flash

Feature Comparison:

* Common features found in both WinRunner and QuickTest Pro:

Record/Replay

ODBC & Excel Connectivity

Code Editor & Debugger

Recovery Manager

Shared Object Repository

Rapid Object Import

Numerous Checkpoints

Analog

Script & Function Libraries

* WinRunner Only Environments:

Function Generator

Database Integration

Run Wizard

TSL

MDI

* QuickTest Pro Only Environments:

ActiveScreen

TestGuard

Tree View

ScriptFusion

Data Table

VBScript

Function Generator*

(coming in v7.0)

Run Wizard*

(coming in v7.0)



What We Recommend

QuickTest Pro is our functional testing tool of choice!

Most customers are in either of two situations:

* Existing WinRunner customers asking “Should we switch to QuickTest Pro?”

* New customers asking “Which should we get, WinRunner or QuickTest Pro?”

We have been implementing Mercury’s products since 1992 and have senior level expertise in WinRunner. We have been implementing WinRunner since the very first version of it. So like many existing WinRunner customers we have a huge knowledge investment in WinRunner ourselves. However we have worked on the Mercury development team on the QuickTest Pro 6.0 and 6.5 releases, and have solid real-world experience in implementing QuickTest Pro since the 6.0 release. We have found it to be a great tool to use and recommend it to all customers! Overall, we recommend using QuickTest Pro unless for some reason you have to use WinRunner due to an unsupported environment not existing in QuickTest Pro.

Overall, QuickTest Pro is easier to use and implement for both technical and non-technical testers in comparison to WinRunner. QTP offers many features that are found in WinRunner, but are easier to use. QTP also offers many features not found in WinRunner that make test script creation, enhancement and maintenance easier.

Let’s quickly discuss some key issues:

* The WinRunner interface forces the user to look directly at TSL code. TSL is the WinRunner programming language developed by Mercury. It is based on the “C” programming language and therefore looks very similar. For testers who do not have a technical background, they are not always comfortable with having to always look at code. However QuickTest Pro offers a “Tree View” which is an icon-based view of the script. This is very easy to get used to and non-technical people adapt to it quicker and feel more comfortable working with it. For the technical user, they can always switch over to the “Expert View” in QuickTest and look directly at code, and program away using VBScript.

* WinRunner uses TSL which is a proprietary language of Mercury. These types of languages can be very restrictive and you are limited on available resources. QuickTest Pro use the Microsoft programming language VBScript which is very powerful, has lots of capabilities and there are lots of resources available.

* We feel that there are many more “point and click” features in QuickTest Pro than WinRunner. This makes its use easier.

* All the same features found in WinRunner are found in QuickTest Pro plus more.

* Data Table integration is much easier and simpler with QuickTest Pro.

* Data Driven Testing is easier with more options in QuickTest Pro.

* Script enhancements are typically easier with QuickTest Pro because it has the Active Screen where the windows and objects in your application are captured for later use. Using a “point and click” capability you can easily interface with objects, their definitions and create checkpoints after having recorded a script – without having to navigate back to that location in your application like you have to with WinRunner. This greatly speeds up script development.

* QuickTest Pro currently has built in integration with WinRunner in order to be able to call existing scripts, which is great for customers who already have a large test script investment with WinRunner. Likewise WinRunner 8.0 is to have the ability to also call QuickTest Pro scripts. This eases the transition from WinRunner to QuickTest Pro for existing customers.

* Parameterization is much easier in QuickTest Pro and basically anything in QuickTest Pro can be parameterized (statements, checkpoints and the Object Repository).

* Capturing various output values is easier and simpler with QuickTest Pro. Using this capability with parameterization enables you to easily develop scripts that can do more in regards to testing.

* We have been implementing QuickTest Pro in real-world environments and have found it much easier to use, advance features are easier to implement and the script development is quicker. We really enjoy using QuickTest Pro and highly recommend it as the functional testing tool to use.

QuickTest Pro is our functional testing tool of choice!


WinRunner

Summary:

This product is a mature tool that has been around since approximately 1995. It interfaces with most of the leading development toolkits using the WindowsAPI and toolkit DLLs to interface with the “Application Under Test”.

WinRunner offers a recording feature that will watch the individual tester and generate a test script to simulate the same actions just performed. The script is displayed as a program which can be enhanced with checkpoints, logic and special coding/programming.

WinRunner also has integration with Excel spreadsheets for data driven testing and the ability to write data out in Excel format or in simple text files.

Here is the description from the Mercury “Features and Benefits” section of the WinRunner web page:

Significantly increase power and flexibility of tests without any programming: The Function Generator presents a quick and error-free way to design tests and enhance scripts without any programming knowledge. Testers can simply point at a GUI object, and WinRunner will examine it, determine its class and suggest an appropriate function to be used.

Use multiple verification types to ensure sound functionality: WinRunner provides checkpoints for text, GUI, bitmaps, URL links and the database, allowing testers to compare expected and actual outcomes and identify potential problems with numerous GUI objects and their functionality.

Verify data integrity in your back-end database: Built-in Database Verification confirms values stored in the database and ensures transaction accuracy and the data integrity of records that have been updated, deleted and added.

View, store and verify at a glance every attribute of tested objects: WinRunner’s GUI Spy automatically identifies, records and displays the properties of standard GUI objects, ActiveX controls, as well as Java objects and methods. This ensures that every object in the user interface is recognized by the script and can be tested.

Maintain tests and build reusable scripts: The GUI map provides a centralized object repository, allowing testers to verify and modify any tested object. These changes are then automatically propagated to all appropriate scripts, eliminating the need to build new scripts each time the application is modified.

Test multiple environments with a single application: WinRunner supports more than 30 environments, including Web, Java, Visual Basic, etc. In addition, it provides targeted solutions for such leading ERP/CRM applications as SAP, Siebel, PeopleSoft and a number of others.

Simplify creation of test scripts: WinRunner’s DataDriver Wizard greatly simplifies the process of preparing test data and scripts. This allows for optimal use of QA resources and results in more thorough testing.

Automatically identify discrepancies in data: WinRunner examines and compares expected and actual results using multiple verifications for text, GUI, bitmaps, URLs, and databases. This ensures stable functionality and execution of business transactions when the application is released into production.

Validate applications across browsers: WinRunner enables the same test to be used to validate applications in Internet Explorer, Netscape, and AOL. This saves testing time and reduces the number of scripts that must be developed and maintained.

Automatically recover tested applications from a crash: Unexpected events, errors, and application crashes during a test run can disrupt the testing process and distort results. WinRunner’s Recovery Manager enables unattended recovery and provides a wizard that guides the process of defining a recovery scenario.

Leverage investments in other testing products: WinRunner fully integrates with our other testing solutions, including LoadRunner for load testing and TestDirector for global test management. Moreover, organizations can reuse WinRunner test scripts with QuickTest Professional.

- WinRunner “Features and Benefits” webpage from Mercury:

http://www.mercury.com/us/products/quality-center/functional-testing/winrunner/features.html

Pros:

  • Mature product that has been around since about 1995.
  • Simple interface.
  • Many features.
  • Many consultants and user group/forums for support.
  • Decent built in help.
  • Fewer features to have to learn and understand compared to QuickTest Pro.
  • Interfaces with the Windows API.
  • Integrates with TestDirector.

Cons:

  • Has basically been superceded by QuickTest Pro.
  • Looking at “program code” for the test case.
  • Coding is done in a proprietary language (TSL).
  • Very few resources available on TSL programming (it is based on the C programming language, but is not C).
  • Need to be able to program to a certain extent in order to gain flexibility and parameterization.
  • Need training to implement properly.
  • The GUI Map can be difficult to understand and implement.


QuickTest Pro

Summary:

QuickTest Professional provides an interactive, visual environment for test development.

Here is the description from the Mercury Interactive “How it Works” section of the QuickTest Pro web page:

Mercury QuickTest Professional™ allows even novice testers to be productive in minutes. You can create a test script by simply pressing a Record button and using an application to perform a typical business process. Each step in the business process is automated documented with a plain-English sentence and screen shot. Users can easily modify, remove, or rearrange test steps in the Keyword View.

QuickTest Professional can automatically introduce checkpoints to verify application properties and functionality, for example to validate output or check link validity. For each step in the Keyword View, there is an ActiveScreen showing exactly how the application under test looked at that step. You can also add several types of checkpoints for any object to verify that components behave as expected, simply by clicking on that object in the ActiveScreen.

You can then enter test data into the Data Table, an integrated spreadsheet with the full functionality of Excel, to manipulate data sets and create multiple test iterations, without programming, to expand test case coverage. Data can be typed in or imported from databases, spreadsheets, or text files.

Advanced testers can view and edit their test scripts in the Expert View, which reveals the underlying industry-standard VBScript that QuickTest Professional automatically generates. Any changes made in the Expert View are automatically synchronized with the Keyword View.

Once a tester has run a script, a TestFusion report displays all aspects of the test run: a high-level results overview, an expandable Tree View of the test script specifying exactly where application failures occurred, the test data used, application screen shots for every step that highlight any discrepancies, and detailed explanations of each checkpoint pass and failure. By combining TestFusion reports with Mercury Quality Management, you can share reports across an entire QA and development team.

QuickTest Professional also facilitates the update process. As an application under test changes, such as when a “Login” button is renamed “Sign In,” you can make one update to the Shared Object Repository, and the update will propagate to all scripts that reference this object. You can publish test scripts to Mercury Quality Management, enabling other QA team members to reuse your test scripts, eliminating duplicative work.

QuickTest Professional supports functional testing of all popular environments, including Windows, Web, .Net, Visual Basic, ActiveX, Java, SAP, Siebel, Oracle, PeopleSoft, terminal emulators, and Web services.

- QuickTest Pro “How it Works” webpage from Mercury:
http://www.mercury.com/us/products/quality-center/functional-testing/quicktest-professional/works.html

We like QuickTest Pro and now prefer implementing it over WinRunner. When you get into advance testing scenarios, QuickTest Pro has more options and they are easier to implement compared to WinRunner in our opinion.

Do to the similarities in concept and features, an experienced WinRunner user can easily convert to QuickTest Pro and quickly become an efficient Test Automation Engineer!

We recommend that existing customers begin all new development with QuickTest Pro and use the built-in feature of calling WinRunner scripts from QuickTest Pro for all existing WinRunner scripts that they already have. As older scripts require updates and time permits, we recommend replacing them with QuickTest Pro scripts. Eventually you will be able to convert your test script library with all QuickTest Pro scripts.

Pros:

  • Will be getting the initial focus on development of all new features and supported technologies.
  • Ease of use.
  • Simple interface.
  • Presents the test case as a business workflow to the tester (simpler to understand).
  • Numerous features.
  • Uses a real programming language (Microsoft’s VBScript) with numerous resources available.
  • QuickTest Pro is significantly easier for a non-technical person to adapt to and create working test cases, compared to WinRunner.
  • Data table integration better and easier to use than WinRunner.
  • Test Run Iterations/Data driving a test is easier and better implement with QuickTest.
  • Parameterization easier than WinRunner.
  • Can enhance existing QuickTest scripts without the “Application Under Test” being available; by using the ActiveScreen.
  • Can create and implement the Microsoft Object Model (Outlook objects, ADO objects, FileSystem objects, supports DOM, WSH, etc.).
  • Better object identification mechanism.
  • Numerous existing functions available for implementation – both from within QuickTest Pro and VBScript.
  • QTP supports .NET development environment (currently WinRunner 7.5 does not).
  • XML support (currently WinRunner 7.5 does not).
  • The Test Report is more robust in QuickTest compared to WinRunner.
  • Integrates with TestDirector and WinRunner (can kick off WinRunner scripts from QuickTest).

Cons:

  • Currently there are fewer resources (consultants and expertise) available due to QTP being a newer product on the market and because there is a greater Demand than Supply, thus fewer employee/consulting resources.
  • Must know VBScript in order to program at all.
  • Must be able to program in VBScript in order to implement the real advance testing tasks and to handle very dynamic situations.
  • Need training to implement properly.
  • The Object Repository (OR) and “testing environment” (paths, folders, function libraries, OR) can be difficult to understand and implement initially.

软件测试人员月薪8000 zz

原文 http://www.rickyzhu.com/2007/05/29/software-testing-salary/

其实月薪8000元很高?在这个物价上涨,通货膨胀的年代8000早已经不是什么高薪了,在深圳甚至连一个平方都买不到!但是确实很多从事测试行业朋友梦寐以求的高薪,到底什么样的公司或者或者单位能提供如此薪水?测试行业的总体薪资分布到底如何?测试从业人员应该如何规划自己的测试职业生涯?

这里转载一篇文章,我认为总结的非常全面,而且有一定深度,对测试人员的职业发展有一定的指导意义。认清自己,给自己一个准确定位,并结合自身的实际情况制定一个切实可行的职业发展计划,对每个人来说都是至关重要的。

这听起来是个很有诱惑力的话题;也的确是个很有诱惑力的话题。 很多做测试的朋友千万次的问,测试行业能挣到高薪吗?从事测试工作有发展吗?我能够忍受枯燥无聊的测试工作吗?

这里我不想谈所有问题,只谈谈如何获得高薪,获得高薪需要哪些素质,那 些条件,多少年的工作经验等。

我认为的测试人员分类

测试人员在软件开发中基本由两大类:一类是起步就做测试,一类做过开发 后来转为测试。

最近在网上同一些朋友聊天,经常聊到测试人员是否需要开发经验这样一个话题。我个人认为,又开发经验更好。我也倾向于由开发经验的测试人员可以获 得更好的发展。但这都是一个动态的过程,起步就做测试的人可能后来也慢慢 掌握开发经验。

测试人员的成长阶段

测试人员基本上可以分为如下几个阶段,手工测试阶段、工具辅助阶段、定制 工具阶段、初级管理阶段、高级管理阶段、业务测试专家(此阶段在等同于在 管理方面发展的初级、高级管理阶段,这个阶段的测试人员熟悉测试的各个方 面,逐步专项某个领域的测试)。

手工测试阶段

处于此阶段的测试人员一般是刚刚进入这一行,或者刚刚换了一个公司(新来 的吗)。这个时候是很重要的积累时期,自动此时工具只是一个辅助,重要的 时你要有如何测试一个软件的思想。

工具辅助阶段

这个阶段的测试人员对各个类型的测试都有所了解,为了提高测试效率,开始使用测试工具;或者为了以后的职业发展开始关注自动测试,并主动或被动的 学习测试工具。这时候自己心里一定要有数,那些测试工具会对职业生涯有帮助。目前国内的测试人员都在学习一些大厂商的测试工具,这些工具的确不错 ,但是不一定都对以后的职业发展有利。一般来说这个时候首先要确定自己在功能测试方向发展还是在性能测试方向发展。这样可以有针对性地学习各类别 的工具。当让有时间和精力可以多学习一些,多多益善。另外还有一些白盒测
试工具,如果想在白盒测试方向发展可以多多研究。

定制工具阶段

这是工具辅助阶段的延续,一般定制工具分为两种,一种是对第三方厂商的工具进行插件开发或利用工具的脚本语言开发可重用的类库;另一种是开发公司内部 使用的工具。第二中情况难度较大,需要测试人员有较高的开发水平。一般来说只有在商业测试工具不能满足测试要求时才开发自己的测试工具。当然有时候不 需要使用庞大的商业测试工具的时候也可以自己开发一些小的、能够满足测试要求的工具。这一般使用产品开发所使用的语言或者Perl、Python等。对于使用 Java开发的产品可以使用BeanShell等脚本语言。

业务测试专家

此阶段的测试人员已经熟练的掌握了多种工具,或者已经具备了为产品定制测试工具的能力。这个时候的测试人员应该做长期的职业生涯考虑,如果从事某个领 域的产品测试时间较久,可以继续深入研究此领域里的相关技术,逐步能够提出对产品开发有建设性的建议。一般来说这个阶段的测试人员会在产品规划的前期 作为高级测试人员参与进去,为产品的需求搜集和设计提供建设性意见。

初级管理阶段

一般来说这个阶段是指你处于项目组长位置的时候。这时可以制定测试计划,组 织组内人员编写、修改测试用例。这个阶段的人员一般一般可以考虑向业务测试 专家方向或者高级管理人员发展。

高级管理阶段

经历初级管理阶段后,积累了初步的测试管理经验。这时候一般会参与测试计划 的制定、人力资源调配、各种资源分配等。

各阶段的薪资状况

就目前国内市场来看,按照测试人员所在的公司类型大致可分为如下几类:

1。国内中小企业
2。国内大企业
3。测试外包公司
4。国外企业

同一个等级的职位在不同类型的公司可能有不同的定义,比如在国内的小企业 可能就以两个测试人员,那你可能身兼多职,既是项目组长,又是项目经理。 国内大企业一般来说同国外的企业的职位基本对应,但是一般来说国内大企业 的测试经理到国外的公司也只能是个测试组长。

测试外包公司在这几个类别中是个另类,在这种公司工作,基本就是技术类, 很少有管理类的。

如何获取高薪?

一般来说在国内的中小公司做测试一般在1500-3000人民币每月。个别也有高的。在国内大公司高级人员一般可以拿到6000-8000人民币每月,初级人员大 概在3000-5000之间。外包公司给的比较多,有经验的人员可以拿到6k到8k。在国外的大公司工作,就目前了解,初级人员在4k到7k之间,高级人员(有 多年的测试经验)可以到8k-10k左右。

如果你是刚刚毕业,那么能够进入大公司或国外的大公司,可以起步较高。 如果你有几年工作经验,那么可以进入国外大公司,逐渐往管理职位发展,不过一般来说这很难。不过国外的大公司,一般提供技术和管理两条路供选择。 毕竟管理职位有限,在国外的某些大公司,有经验的技术人员和一般的管理人员的薪资基本持平。

[TSL Script] 在WinRunner中应用DB语句 zz

原文地址 http://www.cntesting.com/hphtml/?thread-71.html

在TCL中经常使用DB数据库语句增加测试比对、数据抽取、测试用例其他一些应用,由于WinRunner自带的语句包装不够,所以自升级一些DB支持语句是非常必要的,下面是Amit Kulkarni提供的一些这方面支持语句:
1. GetDBColumnValue(in strSql, in strColumn, out strVal),这个方法取得某数据列值,前提是这个数据列只有唯一的值,不能出现多列。
例如:
strSQL = "Select count(1) from PRODUCT_MASTER";
strColumn = "COUNT";
rc = GetDBColumnValue(strSql, strColumn, strVal);
2. GetDBRow(in strSql, out strHeader, out nHeaderCount, out strRow ),这个方法取得某数据行值,前提是这个数据列只有唯一的行,不能出现多行。
3. GetDBColumnAllValues(in strSql, in strColumn, out strVal[], out nRecord),这个方法取得某数据所有列值。
4. GetDBAllRows(in strSql,out strHeader, out nHeaderCount, out strRow[], out nRecord),这个方法取得某数据所有行值。

#--------------------------------------------------------------------------------------
public function GetDBColumnValue(in strSql, in strColumn, out strVal)
#--------------------------------------------------------------------------------------
{
     # Reference to the Connection String Constant
     extern gstrConnString;
     # Holds The result 0 is success any thing other than 0 is failed
     auto rc;
     # Holds the Error that is returned by the ODBC...
     auto strLastError;
     # Holds the Number of rows that is returned by strSQL      
     auto nRecord;
     # Setting strLastError to Null
     strLastError ="";
     # Setting the rc to unsuccessfull      
     rc = -9999;
     # Attempt to connect...
     rc = db_connect("obDatabase",gstrConnString);
     if (rc!=0)
           {
                 # If failed then return...error_code
                 report_msg("Could not Connect To database.");
                 return rc;
           }
     # Attempt the query execution....
     rc = db_execute_query("obDatabase", strSql,nRecord);
     if (rc!=0)
           {
                 # If failed then return code
                 db_disconnect("obDatabase");
                 report_msg("db_execute_query returned error.");
                 return rc;
           }
     if (nRecord == 0)
     {
           # If the records returned is 0 then....
           rc = 1;
           db_disconnect("obDatabase");
           report_msg ("SQL: " & strSql & ". Returned Zero Rows !!!");
           return rc;
     }
     # Attempt to get the field value...
     strVal = db_get_field_value ("obDatabase","#0",strColumn);
     if (strVal=="")
     {
           # Case strVal is null ... Check whether any error has occured
           db_get_last_error("obDatabase", strLastError);
           if (strLastError!="")
           {
                 # If error has occured then... return
                 db_disconnect("obDatabase");
                 rc = 2;
                 report_msg("Last DB Error: " & strLastError);
                 return rc;
           }
           # if there is no error then the field is having null as value
     }
     # Attempt to disconnect
     rc = db_disconnect("obDatabase");
     if (rc!=0)
     {
           # If error then return...
           report_msg("Could not disconnect.");
           return rc;
     }
     # Empty every thing and quit...
     strSql = "";
     strColumn ="";
     strLastError ="";
     return rc;
}

#----------------------------------------------------------------------------------------
public function GetDBRow(in strSql, out strHeader, out nHeaderCount, out strRow )
#----------------------------------------------------------------------------------------
{
     # Reference to the Connection String Constant
     extern gstrConnString;
     # Holds the result set      
     auto rc;
     # Holds the Error that is returned by the ODBC...
     auto strLastError;
     # Holds the Number of records that are returned by query....
     auto nRecord;
     # Set the strLastError to null.
     strLastError ="";
     # Set rc as unsuccessful
     rc = -9999;
     # Attempt to establish a connection
     rc = db_connect("obDatabase",gstrConnString);
     if (rc!=0)
           {
                 # On error return the error code.
                 report_msg("Could not Connect To database.");
                 return rc;
           }
     # Attempt to execute the query...
     rc = db_execute_query("obDatabase", strSql, nRecord);
     if (rc!=0)
           {
                 # On error return the error code
                 db_disconnect("obDatabase");
                 report_msg("db_execute_query returned error.");
                 return rc;
           }
     # Case the number of records returned is zero then
     if (nRecord == 0)
     {
           rc = 1;
           db_disconnect("obDatabase");
           report_msg ("SQL: " & strSql & ". Returned Zero Rows !!!");
           return rc;
     }
     # Attempt to get the Row
     rc = db_get_row("obDatabase", "#0", strRow);
     if (rc!=0)
           {
                 # Case error
                 db_disconnect("obDatabase");
                 report_msg("db_get_row returned error.");
                 return rc;
           }      
     # Attempt to get Headers
     rc = db_get_headers("obDatabase",nHeaderCount, strHeader);
     if (rc!=0)
           {
                 # Case error then
                 db_disconnect("obDatabase");
                 report_msg("db_get_headers returned error.");
                 return rc;
           }
     # if strRow is null then check if any error has occured
     if (strRow =="")
     {
           db_get_last_error("obDatabase", strLastError);
           if (strLastError!="")
           {
                 # If strLastError is not null then return the error.
                 rc = 2;
                 db_disconnect("obDatabase");
                 report_msg("Last DB Error: " & strLastError);
                 return rc;
           }
     }
     # Disconnect the db
     rc = db_disconnect("obDatabase");
     if (rc!=0)
     {
           report_msg("Could not disconnect.");
           return rc;
     }
     strSql = "";
     strLastError ="";
     return rc;
}

#--------------------------------------------------------------------------------------
public function GetDBColumnAllValues(in strSql, in strColumn, out strVal[], out nRecord)
#--------------------------------------------------------------------------------------
{
     # Reference to the Connection String Constant
     extern gstrConnString;
     # Holds The result 0 is success any thing other than 0 is failed
     auto rc;
     # Holds the Error that is returned by the ODBC...
     auto strLastError;
     # Holds index of the strVal array.      
     auto i;
     # Setting strLastError to Null
     strLastError ="";
     # Setting the rc to unsuccessfull      
     rc = -9999;
     # Attempt to connect...
     rc = db_connect("obDatabase",gstrConnString);
     if (rc!=0)
           {
                 # If failed then return...error_code
                 report_msg("Could not Connect To database.");
                 return rc;
           }
     # Attempt the query execution....
     rc = db_execute_query("obDatabase", strSql,nRecord);
     if (rc!=0)
           {
                 # If failed then return code
                 db_disconnect("obDatabase");
                 report_msg("db_execute_query returned error.");
                 return rc;
           }
     if (nRecord == 0)
     {
           # If the records returned is 0 then....
           rc = 1;
           db_disconnect("obDatabase");
           report_msg ("SQL: " & strSql & ". Returned Zero Rows !!!");
           return rc;
     }
     i = 1;
     do
     {
           # Attempt to get the field value...
           strVal = db_get_field_value ("obDatabase","#" & (i-1),strColumn);
           if (strVal=="")
           {
                 # Case strVal is null ... Check whether any error has occured
                 db_get_last_error("obDatabase", strLastError);
                 if (strLastError!="")
                 {      # If error has occured then... return
                       db_disconnect("obDatabase");
                       rc = 2;
                       report_msg("Last DB Error: " & strLastError);
                       return rc;
                 }
                 # if there is no error then the field is having null as value
           }
           i++;      
     }
     while (i <= nRecord);
     # Attempt to disconnect
     rc = db_disconnect("obDatabase");
     if (rc!=0)
     {
           # If error then return...
           report_msg("Could not disconnect.");
           return rc;
     }
     # Empty every thing and quit...
     strSql = "";
     strColumn ="";
     strLastError ="";
     return rc;
}

#----------------------------------------------------------------------------------------
public function GetDBAllRows(in strSql,out strHeader, out nHeaderCount, out strRow[], out nRecord)
#----------------------------------------------------------------------------------------
{
     # Reference to the Connection String Constant
     extern gstrConnString;
     # Holds the result set      
     auto rc;
     # Holds the Error that is returned by the ODBC...
     auto strLastError;
     # Holds the index of Array strRow[]
     auto i;
     # Temporary string
     auto strTmp;
     # Set the strLastError to null.
     strLastError ="";
     strTmp = "";
     # Set rc as unsuccessful
     rc = -9999;
     # Attempt to establish a connection
     rc = db_connect("obDatabase",gstrConnString);
     if (rc!=0)
           {
                 # On error return the error code.
                 report_msg("Could not Connect To database.");
                 return rc;
           }
     # Attempt to execute the query...
     rc = db_execute_query("obDatabase", strSql, nRecord);
     if (rc!=0)
           {
                 # On error return the error code
                 db_disconnect("obDatabase");
                 report_msg("db_execute_query returned error.");
                 return rc;
           }
     # Case the number of records returned is zero then
     if (nRecord == 0)
     {
           rc = 1;
           db_disconnect("obDatabase");
           report_msg ("SQL: " & strSql & ". Returned Zero Rows !!!");
           return rc;
     }
     i = 1;
     do
     {
           strTmp = "";
           # Attempt to get the Row
           rc = db_get_row("obDatabase", (i-1), strTmp);
           if (rc!=0)
           {
                 # Case error
                 db_disconnect("obDatabase");
                 report_msg("db_get_row returned error.");
                 return rc;
           }
           # Push the strTmp in the array
           strRow = strTmp;
           # Increment i
           i++;
     }while (i <= nRecord);
     # Attempt to get Headers
     rc = db_get_headers("obDatabase", nHeaderCount, strHeader);
     if (rc!=0)
           {
                 # Case error then
                 db_disconnect("obDatabase");
                 report_msg("db_get_headers returned error.");
                 return rc;
           }
     # Disconnect the db
     rc = db_disconnect("obDatabase");
     if (rc!=0)
     {
           report_msg("Could not disconnect.");
           return rc;
     }
     strSql = "";
     strLastError ="";
     strTmp="";
     return rc;
}
public function getConnection( inout strConn)
{
     # Reference to the Connection String Constant
     extern gstrConnString;
     # Holds the result set      
     auto rc;
     # Set rc as unsuccessful
     rc = -9999;
     # Attempt to establish a connection
     rc = db_connect(strConn,gstrConnString);
     if (rc!=0)
           {
                 # On error return the error code.
                 report_msg("Could not Connect To database.");
                 return rc;
           }
     return rc;
}

星期三, 六月 06, 2007

How to Write a Business-Oriented Paper

Business thesis only need their product or serive better so their profit better. Much different from academic theis.

----------It's only my note of a lecture.

Suggested Content:

  1. Problem Statement
  2. Our Solution
  3. Evidence the Solution Works
  4. Competitive Approaches
  5. Current Status
  6. Next Steps

Good:

  • Innovation
  • Relation with your work
  • Business Value
  • Result (Experiment, Demo)

Bad:

  • Too much Abbreviations -- unless you declare that you'll use *** for something in the latter paragraphs
  • Just image, or prove it can be implement just by theory