The peek function is used to retrieve the contents of a field from a specific table.
Syntax: peek(fieldname [ , row [ , tablename ] ] )
Eg: LET varMinDate = Num(Peek('ExpenseDate', 0, 'Expenses'));
In the above example, 'ExpenseDate is the field and 'Expenses'' is the table from which value is retrieved. The parameter '0' specifies that the value should be retrived from the first row of the ExpenseDate field in the Expenses table. The calculated value is stored in the varMinDate varible and can be used at a later instance in the script.
Similarly, to retrive the value of the last row, '0' can be replaced by -1.
This would be:
Eg: LET varMaxDate = Num(Peek('ExpenseDate', -1, 'Expenses'));
Most often, peek function is used to get the first and last values of a field. However, it can also be used otherwise, of course depending on the scenario.
Hope this helps you.
Let us take an example.
The synatx for peek function is
peek(fieldname [ , row [ , tablename ] ] )
Where fieldname is the field in which you want to apply the function.
Row must be an integer. 0 denotes the first record, 1 the second and so on. Negative numbers indicate order from the end of the table. -1 denotes the last record read.
Table name is the name of Table that contain the fields.
Let us understand by an example--
now we use the peek function to get the values from the field EmployeeCode from the table Employee
So in this case we will get the last record from the field.
In case we use 0 than it will return the first record
In case we use 1 than it will return the second record and so on.....
For example ....EmployeeCode =
So in case of -1 it will return 65
in case of 1 it will return
in case of 0 ,12
Hope this help you.
hi, ı read web servıs, data after take 3 value ın webservıs and joın my functıon.
take all data peek and functıon read all data but ALL ROWS SAVE FIRST READ MY FUNCTON,
let vStartDate = num(date(mid('2015-06-25',1,10 ),'YYYY-MM-DD'));
let vEndDate = num(date(mid('2015-06-25',1,10 ),'YYYY-MM-DD'));
FOR i=$(vStartDate) to $(vEndDate)
let vDate= date($(i),'YYYY-MM-DD');
date(date#(left(DEPDATE,10),'YYYY-MM-DD'),'DD.MM.YYYY') as [Sirena Sefer Tarihi],
Trim(DEPPOINT&'-'&ARRPOINT) AS [Hat],
mid(DEPTIME,12,5) as [Sirena Saat],
mid(DEPTIME,1,10)&mid(DEPTIME,12,5) as [Sirena DateTime],
COMPARTMENT as [Sirena Sınıf],
[DEPPOINT]&''&[ARRPOINT]&''&['A'&PLANETYPE] as KEY,
'A'&PLANETYPE as PLANETYPE,
'KK'&FLIGHTNO as [Sirena Uçuş Numarası]
FROM [http://localhost:5555/QVSource/WebConnectorV2/?.... [Envelope/Body/FLIGHTLOADITEMRPL/FLIGHTLOADITEM]);
FOR i=1 to $(NumRows)
//[DEPPOINT]&''&[ARRPOINT]&''&['A'&PLANETYPE] as KEY
select ads.ads_rpt.getroutegcd('$(vDEP)','$(vARR)','$(vACTYPE)') as vellat from dual;
store TEST into TEST.qvd;
suppose the following table:
LOAD * INLINE [
Peek() function allows you to select any record that's been already loaded. This function takes 3 parameters:
- table name in single quotes
- the record you want to fetch (0 means the first loaded record, -1 means the last one, -2 the second last one). if no row number is defined, -1 is assumed. Optional parameter
- the name of the referred table. If no table is defined, the last loaded table will be assumed, Optional parameter.
In the example above, if you define a variable with Peek('Value',0,'Dim') then 432 will be returned by the function:
let vPeek = Peek('Value',0,'Dim');
The variable has to be declared with LET because is something that need to be evaluated. When a variable contains a constant number or a string, then SET can be used. Also it is important to note that Peek() is an inter-record function that can only be used in script,
49432_Peek_Example.qvw 148.2 K
SET defines a variable as a literal string --> SET vMath = 2+2 will return "2+2" while LET will return 4. Just the same, SET will not execute the function, instead, it will return a literal string. You need to use LET if you want to store an expression in a variable.
Not sure if you can do SET vPeek = $(=Peek(....) --> Even if you could, not sure if you'd get the same result. Stick with LET.