开发者

Oracle Select Syntax into Postgres

开发者 https://www.devze.com 2022-12-16 23:27 出处:网络
I am converting Oracle Syntax into Postgres SELECT MSN_INT_ID, M开发者_如何学CO_INT_ID, \'Y\'\"AIRMOVE\"

I am converting Oracle Syntax into Postgres

SELECT MSN_INT_ID,
       M开发者_如何学CO_INT_ID,
       'Y'   "AIRMOVE"
  FROM MISSION_OBJECTIVE
 WHERE MO_MSN_CLASS_CD = 'AMV'
 GROUP BY MSN_INT_ID,
          MO_INT_ID

This part is confusing me:

SELECT MSN_INT_ID,
       MO_INT_ID,
       'Y'   "AIRMOVE"

What is the 'Y' "AIRMOVE" doing?


The snippet 'Y' "AIRMOVE" introduces a computed column into the select-list named AIRMOVE whose value is always 'Y'.


It's a computed column, using a statically defined value.


Part of the confusion may be coming from PostgreSQL 8.3 or earlier, where the "AS" keyword is not optional.

Change:

'Y'   "AIRMOVE"

To:

'Y' AS "AIRMOVE"

And it should work fine. The keyword is optional starting in version 8.4, although I advocate always including it to avoid issues exactly like this one.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号