If you ever need to create a view that selects all fields from a particular record, then you should be using the %SelectAll meta-sql construct.

Why? Because %SelectAll uses the underlying record definition to select the fields - so it will always return all fields from the underlying record, even if that record definition changes.

The basic syntax is:

  • %SelectAll(RECORD_NAME ALIAS)

There is all a %SelectDistinct construct which adds a distinct to the select clause and uses the same syntax.

%SelectAll returns all the fields for the record specified and includes a from clause.

For example, say I want the latest effective dated, active fields from PSXLATITEM. My SQL might start something like this:

select FIELDNAME, FIELDVALUE, EFFDT, EFF_STATUS, XLATLONGNAME, XLATSHORTNAME, LASTUPDDTTM, LASTUPDOPRID, SYNCID from PSXLATITEM A where EFFDT = ( select max(EFFDT) from PSXLATITEM where FIELDNAME = A.FIELDNAME and FIELDVALUE = A.FIELDVALUE and A.EFFDT <= sysdate ) and A.EFF_STATUS = 'A';

Instead of typing out all those fields, lets use %SelectAll - that's what I did to generate this example btw ;)

So our meta-sql would look like this - (I've also replaced sysdate with %CurrentDateIn)

%SelectAll(PSXLATITEM A)where EFFDT = ( select max(EFFDT) from PSXLATITEM where FIELDNAME = A.FIELDNAME and FIELDVALUE = A.FIELDVALUE and A.EFFDT <= %CurrentDateIn ) and A.EFF_STATUS = 'A'

Note that %SelectAll wraps date, time and date/time fields with %DateOut%TimeOut%DateTimeOut as well. This resolves into the following meta-sql:

SELECT A.FIELDNAME , A.FIELDVALUE , TO_CHAR(A.EFFDT ,'YYYY-MM-DD') , A.EFF_STATUS , A.XLATLONGNAME , A.XLATSHORTNAME , TO_CHAR(A.LASTUPDDTTM ,'YYYY-MM-DD-HH24.MI.SS."000000"') , A.LASTUPDOPRID , A.SYNCID FROM PSXLATITEM A WHERE EFFDT = ( SELECT MAX(EFFDT) FROM PSXLATITEM WHERE FIELDNAME = A.FIELDNAME AND FIELDVALUE =A.FIELDVALUE AND A.EFFDT <= TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD') ) AND A.EFF_STATUS = 'A'

Note that the example includes an alias of A in the parameters to %SelectAll. If you are using %SelectAll you might have to play with your SQL a bit to get it work, especially if you are using joins to other tables. It may not work in all cases, but if nothing else, its a time saver!

%SELECTALL的更多相关文章

  1. 关于WPF中TextBox使用SelectAll无效的问题的解决办法

    1.首先保证你设置的SelectionBrush不是透明的颜色或者和背景色相同 2.在使用SelectAll之前要保证Textox以及获取到焦点. this.textbox.SelectionBrus ...

  2. 如何让TEdit在获取输入焦点后selectAll?

    关于网友提出的“ 如何让TEdit在获取输入焦点后selectAll?”问题疑问,本网通过在网上对“ 如何让TEdit在获取输入焦点后selectAll?”有关的相关答案进行了整理,供用户进行参考,详 ...

  3. selectAll, unSelectAll两个操作的实现

    private void updateBatchSelectionStatus() {     ContactListAdapter.ViewHolder viewHolder = null;     ...

  4. wpf GridControl selectAll UnSelect

    <Window x:Class="WpfApplication1.GridControlView" xmlns="http://schemas.microsoft. ...

  5. react-native IOS TextInput长按提示显示为中文(select | selectall -> 选择 | 全选)

    根据手机系统语言(简体中文/英文),提示不同的长按效果 长按提示效果图 英文长按提示 中文长按提示 解决 1.手机系统语言为简体中文: 设置->通用->语言与地区 2.ios/项目/inf ...

  6. SpringAOP注解报错:java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut selectAll

    原因 我使用的aspectjweaver.jar版本是1.5.1,版本过低,导致报错. 需要下载高本版的aspectjweaver.jar. 解决办法 在这里下载:https://mvnreposit ...

  7. 年度巨献-WPF项目开发过程中WPF小知识点汇总(原创+摘抄)

    WPF中Style的使用 Styel在英文中解释为”样式“,在Web开发中,css为层叠样式表,自从.net3.0推出WPF以来,WPF也有样式一说,通过设置样式,使其WPF控件外观更加美化同时减少了 ...

  8. 编写自己的PHP MVC框架笔记

    1.MVC MVC模式(Model-View-Controller)是软件工程中的一种软件架构模式,把软件系统分为三个基本部分:模型(Model).视图(View)和控制器(Controller). ...

  9. angularjs 1 开发简单案例(包含common.js,service.js,controller.js,page)

    common.js var app = angular.module('app', ['ngFileUpload']) .factory('SV_Common', function ($http) { ...

随机推荐

  1. eclipse导入不到嵌套的项目

    search for nested projects搜索不到嵌套项目

  2. springmvc笔记(来自慕课网)

    1.准备工作:springmvc相关的jar包. 2.这里我们先用eclipse来操作. 首先看一个接口编程,后面的所有知识点都是通过这个接口编程引出的. OneInterface.java pack ...

  3. [SQL]合并字符串

    --带符号合并行列转换 --有表t,其数据如下: /* a b 1 1 1 2 1 3 2 1 2 2 3 1 --如何转换成如下结果: a b 1 1,2,3 2 1,2 3 1 */ drop t ...

  4. OLAP如何实现数据的聚合计算-分析过程

  5. Microsoft Office 2007的ContentType

    当从浏览器返回一个文件时,需要指定ContentType,以下是Office2007对应的值: "application/vnd.openxmlformats-officedocument. ...

  6. 获取Repeater控件中的每一项数据

    var items = rptList.Items;//获取Repeater控件的所有项 foreach (RepeaterItem item in items)//遍历每一项内容 {   var t ...

  7. JavaScript对象的创建之动态原型方式

    为了让定义的方式更加符合java的需求,就把定义方法的原型代码放置在Person这个构造函数中. function Person(name,age,friends){ //属性在构造函数中定义 thi ...

  8. Android 中获取 debug 测试 SHA1 和 release SHA1 证书指纹数据的方法

    百度地图开发的时候要申请KEY,需要提供SHA1证书指纹数据 Eclipse eclipse中直接查看:windows -> preferance -> android -> bui ...

  9. 使用virtualbox安装centos虚拟机,以及VirtualBox无法安装64位Linux CentOS的解决办法

    之前一直用vmware的虚拟机,好吧,其实一直盗版挺不好的,然后想用centos搭点东西,结果在vmare上安装centos总是有些问题,看了人给的建议换用virtualbox,虽然virtualbo ...

  10. JavaScript_1

    一.方法 ---------------------Array 对象------------------------ 1.concat() : 将作为参数传递的元素拼接到一个已存在的数组2.pop() ...