我有一个触发器,它基本上取值 public static class TabsAdapter extends FragmentPagerAdapter
implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
private final Context mContext;
private final ActionBar mActionBar;
private final ViewPager mViewPager;
private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
static final class TabInfo {
private final Class<?> clss;
private final Bundle args;
TabInfo(Class<?> _class, Bundle _args) {
clss = _class;
args = _args;
}
}
public TabsAdapter(FragmentActivity activity, ViewPager pager) {
super(activity.getSupportFragmentManager());
mContext = activity;
mActionBar = activity.getActionBar();
mViewPager = pager;
mViewPager.setAdapter(this);
mViewPager.setOnPageChangeListener(this);
}
public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
TabInfo info = new TabInfo(clss, args);
tab.setTag(info);
tab.setTabListener(this);
mTabs.add(info);
mActionBar.addTab(tab);
notifyDataSetChanged();
}
@Override
public void onPageScrollStateChanged(int state) {
// TODO Auto-generated method stub
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// TODO Auto-generated method stub
}
@Override
public void onPageSelected(int position) {
// TODO Auto-generated method stub
mActionBar.setSelectedNavigationItem(position);
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
Object tag = tab.getTag();
for (int i=0; i<mTabs.size(); i++) {
if (mTabs.get(i) == tag) {
mViewPager.setCurrentItem(i);
}
}
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
}
@Override
public Fragment getItem(int position) {
TabInfo info = mTabs.get(position);
return Fragment.instantiate(mContext, info.clss.getName(), info.args);
}
@Override
public int getCount() {
return mTabs.size();
}
}
(一个varchar字段),并且根据值是否为数字,设置一些不同的值。下面的选择显示了我如何获得我的价值观。
in_address
我想知道是否有办法存储第一个 INSERT INTO ........... --irrelevant names
SELECT
case when ISNUMERIC(in_address)=1 then convert( tinyint, left( in_address,1 ) ) else 9 end,
case when ISNUMERIC(in_address)=1 then xlat_byte else 9 end,
case when ISNUMERIC(in_address)=1 then xlat_bit else 9 end,
case when ISNUMERIC(in_address)=1 then 'xlat_' else '' end+in_address,
FROM [in],##in_xlat
WHERE (ISNUMERIC(in_address)=1 AND in_xlat_address = right(in_address, 2)) or ISNUMERIC(in_address)=0 AND in_xlat_address = 1
调用的结果并重复使用它们而不是每次都重新计算。
答案 0 :(得分:1)
您可以像这样使用OUTER APPLY:
INSERT INTO ........... --irrelevant names
SELECT
case when numbers.isnumber=1 then convert( tinyint, left( in_address,1 ) ) else 9 end,
case when numbers.isnumber=1 then xlat_byte else 9 end,
case when numbers.isnumber=1 then xlat_bit else 9 end,
case when numbers.isnumber=1 then 'xlat_' else '' end+in_address,
FROM [in],##in_xlat
outer apply (select isnumeric(in_address) as isnumber from [in] in2 where in2.keyfields = [in].keyfields) as numbers
WHERE (numbers.isnumber=1 AND in_xlat_address = right(in_address, 2)) ornumbers.isnumber=0 AND in_xlat_address = 1