Select statement issue

I have the following select statements in the systemerror event of an 
application object:
*********************************
String ls_error_flag, ls_system_flag
// This declaration is for the OLE stuff.
// Trigger Pfc_systemerror for Smooth Exiting and Error Logging

select code_value
into :ls_error_flag
from robi_code_table
where code_name = 'ROBI_ERROR'
using g_tr_error;

select code_value
into :ls_system_flag
from robi_code_table
where code_name = 'ROBI_SYSTEM_ERROR'
using g_tr_error;

If ls_error_flag = 'Y' Then
        If ls_system_flag = 'Y' Then 
                gnv_app.Event pfc_systemerror()
        End IF
End IF
 
*********************************
As long as the value in the database for either string variable returns a 
'Y' the If .. Then statements are executed correctly. If the value of 
either variable is 'N' in the database the fact the condition is for 
example ls_error_flag = 'Y' is not evaluated as expected and the line of 
code gnv_app.Event pfc_systemerror()
is executed.

Any workarounds?? Appreciate any assistance.
Thanks,
John
0
John_Mathew
2/14/2003 10:42:43 PM
sybase.powerbuilder.database 9855 articles. 2 followers. Follow

4 Replies
546 Views

Similar Articles

[PageSpeed] 34
Get it on Google Play
Get it on Apple App Store

I would check for a null value, since if the select doesn't return anything
it could be null.

if isNull( ls_error_flag ) then ls_error_flag = '?'


However my $.02 on your design ...

If the data involved is not a lot and it is static, I would select your
values and store them in up front during the opening of the application
(perhaps in their own error code cache object).

If you need to get at the data frequently, it will be there local instead of
calling for it again and again.

And in the case of a real error condition, the database connection may not
be available for a good result to come back anyway.

<John_Mathew> wrote in message
news:79ADE1E4B786BDB1007CC29B85256CCD.007CC2D985256CCD@webforums...
> I have the following select statements in the systemerror event of an
> application object:
> *********************************
> String ls_error_flag, ls_system_flag
> // This declaration is for the OLE stuff.
> // Trigger Pfc_systemerror for Smooth Exiting and Error Logging
>
> select code_value
> into :ls_error_flag
> from robi_code_table
> where code_name = 'ROBI_ERROR'
> using g_tr_error;
>
> select code_value
> into :ls_system_flag
> from robi_code_table
> where code_name = 'ROBI_SYSTEM_ERROR'
> using g_tr_error;
>
> If ls_error_flag = 'Y' Then
>         If ls_system_flag = 'Y' Then
>                 gnv_app.Event pfc_systemerror()
>         End IF
> End IF
>
> *********************************
> As long as the value in the database for either string variable returns a
> 'Y' the If .. Then statements are executed correctly. If the value of
> either variable is 'N' in the database the fact the condition is for
> example ls_error_flag = 'Y' is not evaluated as expected and the line of
> code gnv_app.Event pfc_systemerror()
> is executed.
>
> Any workarounds?? Appreciate any assistance.
> Thanks,
> John


0
David
2/15/2003 6:40:23 PM
You also might initialize the variables or check for SQLNRows = 0;
If no data is returned, you may find the the variable is not accessed.  This
seems to be dependent on the DB driver/access method.  NULL is not
guaranteed in the case that no data is returned.

"David Rawheiser" <rawhide58@hotmail.com> wrote in message
news:B1J7hcS1CHA.351@forums.sybase.com...
> I would check for a null value, since if the select doesn't return
anything
> it could be null.
>
> if isNull( ls_error_flag ) then ls_error_flag = '?'
>
>
> However my $.02 on your design ...
>
> If the data involved is not a lot and it is static, I would select your
> values and store them in up front during the opening of the application
> (perhaps in their own error code cache object).
>
> If you need to get at the data frequently, it will be there local instead
of
> calling for it again and again.
>
> And in the case of a real error condition, the database connection may not
> be available for a good result to come back anyway.
>
> <John_Mathew> wrote in message
> news:79ADE1E4B786BDB1007CC29B85256CCD.007CC2D985256CCD@webforums...
> > I have the following select statements in the systemerror event of an
> > application object:
> > *********************************
> > String ls_error_flag, ls_system_flag
> > // This declaration is for the OLE stuff.
> > // Trigger Pfc_systemerror for Smooth Exiting and Error Logging
> >
> > select code_value
> > into :ls_error_flag
> > from robi_code_table
> > where code_name = 'ROBI_ERROR'
> > using g_tr_error;
> >
> > select code_value
> > into :ls_system_flag
> > from robi_code_table
> > where code_name = 'ROBI_SYSTEM_ERROR'
> > using g_tr_error;
> >
> > If ls_error_flag = 'Y' Then
> >         If ls_system_flag = 'Y' Then
> >                 gnv_app.Event pfc_systemerror()
> >         End IF
> > End IF
> >
> > *********************************
> > As long as the value in the database for either string variable returns
a
> > 'Y' the If .. Then statements are executed correctly. If the value of
> > either variable is 'N' in the database the fact the condition is for
> > example ls_error_flag = 'Y' is not evaluated as expected and the line of
> > code gnv_app.Event pfc_systemerror()
> > is executed.
> >
> > Any workarounds?? Appreciate any assistance.
> > Thanks,
> > John
>
>


0
Tyler
2/15/2003 7:31:55 PM
The values for ls_system_flag is displayed as 'N' in the debugger but 
freezes at the last If....Then line of code. The same piece of code works 
like a champ in an event of a window.

*********
ll_rows = gds_robi_rules.Retrieve()
ll_sys_row = gds_robi_rules.Find("code_name 
         = 'ROBI_SYSTEM_ERROR'" + " and active = '" + ls_active 
         + "'", 1, ll_rows )

If ll_sys_row > 0 Then
        ls_system_flag = gds_robi_rules.GetItemString
                                  (ll_sys_row,"code_value" )
End If

If ls_system_flag = 'Y' Then 
   gnv_app.Event pfc_systemerror()
End If
*************

Any ideas ? Appreciate any pointers.

Thanks,
John.

0
John_Mathew
2/15/2003 11:52:30 PM
So its not a data retrival issue but an error invoking pfc_systemError?

What happens if you use the following at the end of your script instead of
what you got
or alternatively, do a post in the call to pfc_systemerror?

----

If ls_system_flag <> 'Y' Then RETURN

gnv_app.Event pfc_systemerror()


<John_Mathew> wrote in message
news:162CA711A9858D8E0083261E85256CCE.006C7B4D85256CCE@webforums...
> The values for ls_system_flag is displayed as 'N' in the debugger but
> freezes at the last If....Then line of code. The same piece of code works
> like a champ in an event of a window.
>
> *********
> ll_rows = gds_robi_rules.Retrieve()
> ll_sys_row = gds_robi_rules.Find("code_name
>          = 'ROBI_SYSTEM_ERROR'" + " and active = '" + ls_active
>          + "'", 1, ll_rows )
>
> If ll_sys_row > 0 Then
>         ls_system_flag = gds_robi_rules.GetItemString
>                                   (ll_sys_row,"code_value" )
> End If
>
> If ls_system_flag = 'Y' Then
>    gnv_app.Event pfc_systemerror()
> End If
> *************
>
> Any ideas ? Appreciate any pointers.
>
> Thanks,
> John.
>


0
David
2/16/2003 8:42:06 PM
Reply: