1

I'm new in SQR. I need help to write a variable and use it for a condition statement. my pseudo code goes

declare $head_print

let $head_print = (select * from PS_DTR_RPT_ACCT
where RPT_TREE_NODE = 'REAL_ESTATE_EXP' 
or TREE_NODE_NUM between 4600000 and 4699999)

if(head_print contain REAL_ESTATE_EXP or Account between 46000000 and 4699999)
then head_print = "REAL ESTATE";
else head_print = "Capital ESTATE";
user3396478
  • 176
  • 2
  • 13
  • Hmm.. Can you be more explicit about what is the question here? – Anshul Goyal Mar 09 '14 at 17:08
  • I have to do the selection and if the selection contains any value then my head_print variable will show REAL ESTATE otherwise CAPITAL ESTATE. Thanks – user3396478 Mar 09 '14 at 18:27
  • Ok. The question is tagged with `sqr` alone, which has only 6 followers - if there is any other relevant tag, add that as well. Also, the real problem that you are facing is not apparent to me from the question (as in, *what exactly* doesn't work with the code you pasted). Try editing it, and you might get better response. – Anshul Goyal Mar 09 '14 at 20:04
  • Thanks for your help. I figured it out.. – user3396478 Mar 13 '14 at 13:57

1 Answers1

1

It's not quite clear what you want so I'm making an assumption. It seems it is if a certain value is in table PS_DTR_RPT_ACCT, then you want it to say "REAL ESTATE" otherwise say "CAPITAL ESTATE"

Now with SQR, you have to put your SQL in a begin-select block - rules are very strict - field names must be in column 1 - code underneath NOT in column 1. In the following routine, I've tried to code your pseudo code in real SQR, however, I could not test it so you may get errors - plus I don't know your field names since it just says "select *".

Begin-Report

   do GetData

End-Report

Begin-Procedure GetData

! Initialize value - if no data found, query this later and set it to the "ELSE"
Let $Head_print = ''

Begin-Select

Head_Print
   ! Override the value from the table but only if you need to
   Let $Head_Print = 'REAL ESTATE'

from PS_DTR_RPT_ACCT
Where RPT_TREE_NODE = 'REAL_ESTATE_EXP' 
or TREE_NODE_NUM between 4600000 and 4699999)

End-Select 

! If $Head_print is blank, then no value was found with the sql - do the ELSE part
If $Head_Print = ''
   Let $Head_Print = 'Capital Estate'
End-If

End-Procedure

SQR is quite a nice finite language to learn - syntax somewhat strict, but simple as Basic with SQL. I do recommend reading the reference manual - it's downloadable from Oracle.

Feel free to ask any other questions about SQR - I get alerts if you do - sorry it took this long to answer

cardmagik
  • 1,698
  • 19
  • 17