FW: JBC SELECT utilizing a WITH clause

28 views
Skip to first unread message

Treg Taylor

unread,
Nov 7, 2008, 11:51:57 AM11/7/08
to jB...@googlegroups.com
As requested; Any improvements???


PROGRAM SK.AUTO_POSTCANCEL

CLEAR
PARAM1 = SENTENCE(1)
MATCHFOR = "'":SENTENCE(2):"'0X"
FILENAME = FIELD(PARAM1,":",1)

OPEN FILENAME TO FN ELSE CRT "ERROR: UNKNWON FILENAME(":FILENAME:")";STOP
SELECT FN TO SEL.VAR
LOOP WHILE READNEXT IID FROM SEL.VAR DO
IF IID MATCHES MATCHFOR THEN
KEYS<-1> = IID
CNT = CNT + 1
END
REPEAT

IF CNT = 0 THEN
CRT "ERROR: NO RECORDS SELECTED"
STOP
END

FORMLIST KEYS TO SEL.VAR2

DATA PARAM1
EXECUTE "RUN PRIVLIB POST" PASSLIST SEL.VAR2
STOP

-----Original Message-----
From: Besso...@gmail.com [mailto:Besso...@gmail.com]
Sent: Friday, November 07, 2008 10:24 AM
To: Treg Taylor
Subject: Re: JBC SELECT utilizing a WITH clause

So, why don't you share your findings?

On 6 нояб, 19:35, Treg Taylor <Treg.Tay...@supportkids.com> wrote:
> I found a way that did not require shell out to another process
>
> Thank you all
>
> Treg
>
> -----Original Message-----
> From: jB...@googlegroups.com [mailto:jB...@googlegroups.com] On Behalf Of Simon Verona
> Sent: Wednesday, November 05, 2008 4:57 PM
> To: jB...@googlegroups.com
> Subject: RE: JBC SELECT utilizing a WITH clause
>
> Like :
>
> EXECUTE 'SELECT FILE WITH ATT="Data"'
>
> Or did you have something else in mind ?
>
> Simon
>
> -----Original Message-----
> From: jB...@googlegroups.com [mailto:jB...@googlegroups.com] On Behalf Of
> Treg Taylor
> Sent: 05 November 2008 16:24
> To: 'jB...@googlegroups.com'
> Subject: JBC SELECT utilizing a WITH clause
>
> Hi All-
>
> Anyone know if there is a way to execute a JBC SELECT utilizing a WITH
> clause?
>
> Thanks in advance,
>
> Treg
>
> CUBS: OCT98
> JBase: 3.4.2
> Win2000 SP4
>
> Notice: This electronic transmission and its attachments are confidential
> and protected by applicable state and/or federal law.  Any use, reading,
> dissemination, distribution, copying or storage of this information by
> anyone other than the intended recipient is strictly prohibited.  If you are
> not the intended recipient, please immediately notify the sender by return
> email or telephone and delete this message and its attachments from your
> system.
>
> Notice: This electronic transmission and its attachments are confidential and protected by applicable state and/or federal law.  Any use, reading, dissemination, distribution, copying or storage of this information by anyone other than the intended recipient is strictly prohibited.  If you are not the intended recipient, please immediately notify the sender by return email or telephone and delete this message and its attachments from your system.
>
>

Notice: This electronic transmission and its attachments are confidential and protected by applicable state and/or federal law. Any use, reading, dissemination, distribution, copying or storage of this information by anyone other than the intended recipient is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by return email or telephone and delete this message and its attachments from your system.

Emery A Grantier

unread,
Nov 7, 2008, 2:07:13 PM11/7/08
to jB...@googlegroups.com
Or just build the first loop into the executed program, and do away with
the "select" program entirely...

Bruce Willmore

unread,
Nov 7, 2008, 10:11:04 PM11/7/08
to jB...@googlegroups.com
This example program brings a question to mind that I've been meaning to ask
for quite some time, but never got around to.

Which of the following would be more efficient,

KEYS<-1> = ID

or

INS ID BEFORE KEYS<1>?

Thanks...

Jim Idle

unread,
Nov 8, 2008, 2:26:53 PM11/8/08
to jB...@googlegroups.com
On Fri, 2008-11-07 at 22:11 -0500, Bruce Willmore wrote:
> This example program brings a question to mind that I've been meaning to ask
> for quite some time, but never got around to.
>
> Which of the following would be more efficient,
>
> KEYS<-1> = ID
>
> or
>
> INS ID BEFORE KEYS<1>?
>
> Thanks...
>

See quite a number of past posts to this group about this See grup
search.

In summary though:

If you insert before the first value, then the entire dynamic array must
be shifted in memory, which will slow down linearly, or at least in
relation to the performance of memmove() on your OS. It can be even
worse because an insert that causes a reallocation may need to use new
memory rather than just ask the OS to extend the block you have. If it
does that, it will first copy the dynamic array to new memory, then
imeediately memmove() it. Never do this basically.

Adding after the last value is very efficient because jBASE knows how
long the array is and can go straight to the end. It must do a few more
checks than a straight string append, because of adding empty values in
different emulations. Hence a pure append is faster if you can guarantee
behavior, but not so much so that you need to worry about it.

Basically, in all similar cases, appending to the end of the string is
always faster, even if it means you do a single SORT() at the end of
building your array. The memmove() on most systems is extremely fast,
but it is still better not to do it all :-)

Jim

Reply all
Reply to author
Forward
0 new messages