I want to make a select from table T1, to filter records using only the
last value in field 28. How I can create the DICT for this field?
Thanks in advance,
You will need to write a program and call it from a 'B' correlative or an
'I' type.
001 I
002 LASTVAL(attr)
003
004
005 10L
001 SUBROUTINE LASTVAL(result,attr)
002 result = attr<1,DCOUNT(attr,@VM)>
003 RETURN
If the number of values are fixed:
001 S
002 0
003
004
005
006
007
008 Tfilename;Xvmc;;amc
009 L
010 10
will work,
The old way
001 S
002 0
003
004
005
006
007
008 F;3;3;S;_
009 L
010 10
doesn't work in jBase.
HTH
Mark Hogden
Proco, Inc.
0001 I
0002 @RECORD<28>;@RECORD<28, DCOUNT(@1, @VM)>
0003
0004
0005 10L
or create a subroutine :
0001 SUBROUTINE lastmv
0002 INCLUDE qbasiccommonpick
0003 newpick(12) = newpick(12)<1,DCOUNT(newpick(12),@VM)>
0004 RETURN
The dictionary item can then call the subroutine with :
001 A
002 28
003
004
005
006
007
008 CALL lastmv
009 L
010 10
The nice thing about the subroutine is that it can be reused for any
attribute in any file, whereas the I-type is only useful for attribute 28.
Dan
-----Original Message-----
From: jB...@googlegroups.com [mailto:jB...@googlegroups.com] On Behalf Of
alf
Sent: Tuesday, April 04, 2006 18:52
To: jBASE
Subject: Last Value in a MultiValue field
The old way
001 S
002 0
003
004
005
006
007
008 F;3;3;S;_
009 L
010 10
doesn't work in jBase.
Mark - is this still true of 4.1? Not that I can do anything about it,
but I am curious ;-)
Jim
Here's my data file:
LIST F.USER APPLICATION
@ID............. APPLICATION...................
ADMINUSER @APP1
USERN2229 @APP2
@APP3
USERB7188 @APP1
USERP7058 @APP4
USERY4392 @APP2
@APP5
USERL3598 @APP2
@APP6
Here's the command and output:
jsh ~ -->LIST F.USER APPLICATION WITH EVAL
'APPLICATION<1,DCOUNT(APPLICATION,@VM)>' = '@APP3'
USERN2229 @APP2
@APP3
Just replace the LIST with SELECT and it should still work.
HTH
1> S
2> 0
3> mv extract
4>
5>
6>
7>
8> F;0;(T<filename>;X<n>;<p>;<p>) <n> = the multivalue position to
extract, <p> is the attribute of the item.
9> L
10> 5
If the MV position is dynamic, then it needs a basic program to get at it.
Provides an interface for jBC subroutines or C functions to manipulate
data during jQL processing. Synonymous with B code.
Syntax
B;{filename}subname
CALL{X} {filename}subname
Syntax Elements
filename is ignored but provided for compatibility with older systems.
subname is the name of the called subroutine (or function). This
subroutine must reside in one of the libraries defined for the user.
Notes
Use the B or CALL code when you need to perform processing that is not
possible with other available codes.
All necessary variables are pre-defined in a COMMON block that you must
INCLUDE in your subroutine. See the Advanced
Programmers Reference Manual for more information on constructing C
functions.
Subroutine programs must start with these lines:
SUBROUTINE subname {(parameter)}
INCLUDE qbasiccommon
Option parameter is only used when the JBCEMULATE environment variable
is set to AP.
qbasiccommon is a standard header file provided with jBASE. You may need
to include a different qbasiccommon block, depending
on the emulation in use. If required, you can create your own version of
the code. See the Advanced Programmers Reference Manual
for more information.
qbasiccommon defines the following COMMON data values:
• file descriptor variables for the current file and dictionary
• name of the file being processed
• current record key
• current record being processed - as a dynamic array
• current data value (the data which will subsequently be output)
• number of records processed so far
• current values of the field, value and subvalue mark counts
• number of detail lines output since the last break line
• a value to indicate the current status of the process. One of the
following
0 processing a detail line
1 - 15 processing a break line - break level is indicated by the value
127 processing a GRAND-TOTAL line
-1 processing a SORT or SELECT
Example 1
LIST SALES COMMENTS
COMMENTS (in DICT of SALES file)
001 A
002 3