REG: Storage of Sequence values

Ravichandran

New Member
Hi,

Where the sequence values are getting stored in progress ?

Is there any way to get the sequence value without using "CURRENT-VALUE()" function ?
 
Hi,

Where the sequence values are getting stored in progress ?

Is there any way to get the sequence value without using "CURRENT-VALUE()" function ?

Unless you've upgraded in the last couple of hours, no, as I have already said, not directly in the 4GL.

You can write some fancy code to generate the values along these lines:

Code:
RUN FancyCode(sequencename).

Procedure FancyCode (sequencename).

<output to tempfile.p '4GL with 'CURRENT-VALUE(sequencename) output statement'>
<run tempfile.p>

end.


Or, Outside the 4GL, you can use DataAdmin > Dump Data > Sequence Values, which essentially does the same thing I've just described.

Or you could combine the two and parse the output of the DataAdmin,

Or you could prewrite a program that outputs current-value for a particular sequence (eg. OutputCustSeq.p), then
Code:
RUN VALUE('Output' + sequenceName)
.

Or, you could upgrade.
 
##############################################
# script to dump sequence current values
# may be helps
##############################################
echo "OUTPUT TO VALUE('dump_seq.p') NO-MAP NO-ECHO." > dump_seq.p;

echo "FOR EACH _Sequence :" >> dump_seq.p;
echo " PUT UNFORMATTED" >> dump_seq.p;
echo " 'EXPORT '" >> dump_seq.p;
echo " _Sequence._Seq-Num" >> dump_seq.p;
echo " ' "'" >> dump_seq.p;
echo " _Sequence._Seq-Name" >> dump_seq.p;
echo " '" CURRENT-VALUE(' _Sequence._Seq-Name ').' SKIP." >> dump_seq.p;
echo "END." >> dump_seq.p;
echo "OUTPUT CLOSE." >> dump_seq.p;
echo "" >> dump_seq.p;
echo "OUTPUT TO VALUE('seqval.d')." >> dump_seq.p;
echo "RUN VALUE('dump_seq.p')." >> dump_seq.p;
echo "OUTPUT CLOSE." >> dump_seq.p;

$DLC/bin/_progres $BASE -1 -b -p dump_seq.p;
rm dump_seq.p;
 
After a little work - I got this code working OK. SO ... I can extract the current sequence values from the database.

BUT ... how can I get them back IN - without using the Procedure Editor??

I am dealing with dumping/reloading many databases at remote sites (over 200). Using the Procedure Editor would make the process vastly more complicated than it should be. I have to be able to script the lot.

Can anyone suggest something??

I'm using Progress 9.1D under Unixware. (Yes I know it's ancient - and steps are being taken to upgrade to 10 shortly.)

I see that Progress suggest using their code in prodict - but I can't find the code anywhere.

Cheers,
Ron.
 
Dump and load of sequences is supported on the data admin tool, for which you have the source.
 
In version 9 there are no dynamic means to set sequences so you have to write a little program that will read the saved value and set it. You then have to run the generated .p as a "compile on the fly" program. (That is what the dictionary program does.)

Something like this:
Code:
/* loadseq.p
 *
 * Load sequence values
 *
 * 11/03/00     bmy     created
 * 12/31/01     tom     modified to use parameter
 *
 * november 3, 2000 */

define variable seqnum  as integer no-undo.
define variable seqval  as integer no-undo.

define variable seqname as character no-undo.
define variable sdir    as character no-undo.
define variable sfile   as character no-undo.
define variable pfile   as character no-undo.

pfile   = OS-GETENV( "TMP" ) + "/seq.p".

OS-COMMAND value( "rm -f " + pfile ).

sfile = entry( 1, session:parameter, "|" ).     /* sequence data file name      */
sdir  = entry( 2, session:parameter, "|" ).     /* .d file path                 */

input from value( sdir + "/" + sfile ).

repeat:

  import seqnum seqname seqval.

  output to value( pfile ) append.
  put unformatted "current-value( " seqname " ) = " seqval "." skip.
  output close.

end.

run value( pfile ).

return.
 
Back
Top