简体   繁体   English

编写SQR条件语句

[英]Write an SQR condition statement

I'm new in SQR. 我是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";

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" 似乎表PS_DTR_RPT_ACCT中是否有某个值,那么您希望它说“ REAL ESTATE”,否则说“ 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 *". 现在使用SQR,您必须将SQL放在开始选择块中-规则非常严格-字段名称必须在第1列中-代码在NOT不在第1列中。在以下例程中,我尝试对伪代码进行编码但是,我无法测试它在真实SQR中的代码,因此您可能会出错-另外我也不知道您的字段名称,因为它只显示“ 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. SQR是一种非常不错的有限语言,它的语法有些严格,但像使用SQL的Basic一样简单。 I do recommend reading the reference manual - it's downloadable from Oracle. 我建议阅读参考手册-可从Oracle下载。

Feel free to ask any other questions about SQR - I get alerts if you do - sorry it took this long to answer 随时问有关SQR的任何其他问题-如果您收到我会收到警报-抱歉花了很长时间才回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM