Monday, 19 August 2013

Structure of PL/SQL-Blocks

PL/SQL is a block-structured language. Each block builds a (named) program unit, and blocks can be nested. Blocks that build a procedure, a function, or a package must be named. A PL/SQL block has an optional declare section, a part containing PL/SQL statements, and an optional exception-handling part. Thus the structure of a PL/SQL looks as follows (brackets [ ] enclose optional parts):
[]
[declare
]
begin
[exception
]
end;
The block header specifies whether the PL/SQL block is a procedure, a function, or a package.
If no header is specified, the block is said to be an anonymous PL/SQL block. Each PL/SQL
block again builds a PL/SQL statement. Thus blocks can be nested like blocks in conventional
programming languages. The scope of declared variables (i.e., the part of the program in which
one can refer to the variable) is analogous to the scope of variables in programming languages
such as C or Pascal.

Remove Attachment from QC Through QTP

Remove Attachment from QC Through QTP
‘The following function will Remove the specified attachment from the current test of QC when the file name provided
Function RemoveQCAttachements(NameOfTheFile)
var_count= QCUtil.CurrentTest.Attachments.NewList(“”).count
For i= 1 to var_count
If QCUtil.CurrentTest.Attachments.NewList(“”).Item(2).Name =NameOfTheFile Then
AttachmentID = QCUtil.CurrentTest.Attachments.NewList(“”).Item(1).ID
QCUtil.CurrentTest.Attachments.RemoveItem(AttachmentID)
Else
Reporter.ReportEvent micFail,”Please provide the valid filename with extention”,”Please provide the valid filename with extention”
End If
Next
End Function
NameOfTheFile=”abc.vbs” ‘Provide the file name with extension
call RemoveQCAttachements(NameOfTheFile)

Upload Attachments To QC

Upload Attachments To QC
Function UpLoadAttachmentToQC(FilePath)
Set ObjCurrentTest = QCUtil.CurrentTest.Attachments
Set ObjAttch = ObjCurrentTest.AddItem(Null)
ObjAttch.FileName = FilePath
ObjAttch.Type = 1
ObjAttch.Post
ObjAttch.Refresh
End Function
FilePath=”C:\abc.vbs”
Call UpLoadAttachmentToQC(FilePath)

How to Close QTP After Execution

How to Close QTP after execution
Private Function CloseQTP
Set objWMIService = GetObject(“winmgmts:\\.\root\CIMV2″)
Set colProcess = objWMIService.ExecQuery (“Select * from Win32_Process Where Name = ‘QTPro.exe’”)
For Each objProcess in colProcess
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcess = NothingEnd FunctionCall CloseQTP

How to specify the environment variables to be loaded when QTP is started

How to specify the environment variables to be loaded when QTP is started
You can either define individual values in the .vbs file or specify an environment file to load.
Example:
Here is what the .vbs file could look like:
Dim App ‘As Application
‘ Launch QTP
Set App = CreateObject(“QuickTest.Application”)
App.Launch
App.Visible = True
‘ Load an INI file with user-defined parameters
App.Test.Environment.LoadFromFile “C:\Test_Params\environment_file1.ini”
‘ Set the value of a specific user-defined Environment variable
App.Test.Environment.Value(“newvariable”) = “new value”
As you can see from the example, the Environment variable file is actually an .ini file. The structure would be:
[Environment]
var1=value1
var2=value2