My current approach is to always initialize variables before hand and also, if 
more than one value might exist, check for COUNT first or “LIMIT” the search to 
just one. I am trying to standardize my code to true SQL as much as possible.
 
Javier,
 
Javier Valencia, PE
O: 913-829-0888
C: 913-915-3137
 
 
 
From: [email protected] [mailto:[email protected]] On Behalf Of 
jan johansen
Sent: Wednesday, February 06, 2019 1:29 PM
To: [email protected]
Subject: RE: [RBASE-L] - SQL tutorial
 
Javier,
 
I normally use the "SELECT Colname INTO...INDICATOR" as well.
Works great. The only time I have an issue is when it could return more than 
one row.
 
Thanks,
 
Jan
 
 
  
From: <[email protected]>
To: <[email protected]>
Date: Wed, 6 Feb 2019 12:31:56 -0600
Subject: RE: [RBASE-L] - SQL tutorial
  
Jan,
 
A while back I stopped using the “SET VAR =…” syntax and replaced (when 
possible) with the “SELECT ColName INTO…INDICATOR …” construct as R:azzak 
example shows. As I understand, it reflects the more standard SQL syntax and 
works great.
 
Javier,
 
Javier Valencia, PE
O: 913-829-0888
C: 913-915-3137
 
 
 
From: [email protected] [mailto:[email protected]] On Behalf Of 
jan johansen
Sent: Wednesday, February 06, 2019 12:06 PM
To: [email protected]
Subject: Re: [RBASE-L] - SQL tutorial
 
 
Razzak,
 
Thank you. I was actually replacing the existence check with this when I posted 
the question.
I think elsewhere in the system when I look at
WHILE SQLCODE = 0
or
WHILE SQLCODE <> 100
my brain got really tied in knots.
 
Thx again,
 
Jan
 
 
  
From: "A. Razzak Memon" <[email protected]>
To: [email protected], [email protected]
Date: Tue, 05 Feb 2019 20:28:00 -0500
Subject: Re: [RBASE-L] - SQL tutorial
  
Jan,

Here is one approach to validate the existence of a row ...

SET VAR vRows INTEGER = 0
SELECT COUNT(*) INTO vRows INDICATOR iv1 FROM PODetail WHERE PO_ID =
.vPOID AND ReceiptStatus = 'P'

IF vRows = 0 THEN
    CLS
    PAUSE 2 USING 'No record found!' CAPTION 'Receipt Status' ICON WARNING +
    BUTTON 'Press any key to continue ...' +
    OPTION BACK_COLOR WHITE +
    |MESSAGE_FONT_NAME Tahoma +
    |MESSAGE_FONT_COLOR RED +
    |MESSAGE_FONT_SIZE 12
    GOTO Done
ENDIF

-- Do what you have to do here ...
-- Example
    CLS
    EDIT USING ReceiptStatus WHERE PO_ID = .vPOID AND ReceiptStatus = 'P'
LABEL Done
    CLEAR VARIABLES iv%,vRows
    RETURN

Hope it helps!

Razzak


At 06:41 PM 2/5/2019, jan johansen wrote:

>All,
>
>I think I need a SQL refresher.
>I need to update old code that looks like this.
>
>SET ERROR VAR hold
>SET VAR vchk = ReceiptStatus IN PODetail WHERE PO_ID = .vPOID AND
>ReceiptStatus = 'P'
>IF hold = 0 THEN
>
>So is
>IF hold = 0 the same as
>IF SQLCODE = 0?
>
>Sorry such a dumb question.
>
>Jan
>
>--
>For group guidelines, visit
><http://www.rbase.com/support/usersgroup_guidelines.php>http://www.rbase.com/support/usersgroup_guidelines.php
>---
>You received this message because you are subscribed to the Google
>Groups "RBASE-L" group.
>To unsubscribe from this group and stop receiving emails from it,
>send an email to
><mailto:[email protected] 
><mailto:rbase-l%2Bunsubscribe%40googlegroups.com> 
>>[email protected] 
><mailto:rbase-l%2Bunsubscribe%40googlegroups.com> .
>For more options, visit
><https://groups.google.com/d/optout>https://groups.google.com/d/optout.

--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected] 
<mailto:rbase-l%2Bunsubscribe%40googlegroups.com> .
For more options, visit https://groups.google.com/d/optout.
--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
 
--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
---
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

-- 
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to