利用DB2 V10.1中的全局变量实现全球化
本文的第 1 部分 展示了 DB2 V10.1 的安全性特性如何满足将来自多个国家(行政区)的数据整合到单独一组表中的组织的关键业务需求: 1. 使本地用户仅能访问其所在国家(行政区)的数据 2. 使地区用户仅能访问其所在地区的数据 3. 针对地区用户,实现地方敏感
本文的第 1 部分 展示了 DB2 V10.1 的安全性特性如何满足将来自多个国家(行政区)的数据整合到单独一组表中的组织的关键业务需求:
1. 使本地用户仅能访问其所在国家(行政区)的数据
2. 使地区用户仅能访问其所在地区的数据
3. 针对地区用户,实现“地方敏感型”,自动将不同国家(行政区)的币种值转为通用币种(例如,为了汇总分别使用新加坡货币和中国香港货币的两种商品的价格,需要进行币种转换)
4. 根据用户是本地用户还是地区用户来屏蔽列数据
本文以第1 部分作为基础,展示了如何利用全局变量和角色来降低代码复杂性、提高有用性,同时动态计算对地方敏感的日期/时间段。
提高指定日期/时间值时的有用性
全局变量可用于使 SQL 更易理解。您不必再在 SQL 语句中指定复杂的公式,而是可以为该公式创建一个全局变量,直接指定该变量。全局变量提供了共享的通用例程,可在任何 SQL 中使用它们,这些例程消除了重复编写相同代码的需要。除此之外,利用全局变量时,只需在指定公式的位置创建变量一次,因此可减少 SQL 中的错误。
全局变量支持使用描述性名称,这有助于用户或读者确定应执行哪些计算。例如,指定一周的第一天时,可以在查询中包含这样的计算:
SELECT … FROM REAL_ESTATE_SALES
WHERE PROPERTY_TYPE = ‘CONDO’
AND EFFECTIVE_DATE =
CURRENT_DATE – (DAYOFWEEK_ISO (CURRENT_DATE)-1) DAYS)
我们也可以创建一个全局变量来改善可读性。这允许任何查看 SQL 语句的用户确定查询执行的日期计算:
CREATE VARIABLE FIRST_DAY_OF_WEEK DATE
DEFAULT
(CURRENT_DATE – (DAYOFWEEK_ISO (CURRENT_DATE)-1) DAYS)
现在,可将查询写为:
SELECT … FROM REAL_ESTATE_SALES
WHERE PROPERTY_TYPE = ‘CONDO’
AND EFFECTIVE DATE = FIRST_DAY_OF_WEEK
全局变量允许我们指定一个“常量”,全局变量的名称表示业务查询执行的操作。下面给出了几个常用的日期/时间段:
1. 今天
2. 昨天
3. 明天
4. 一个月的第一天
5. 一个月的最后一天
6. 一个星期的第一天
7. 当前季度的第一天
利用全局变量,可以通过用户友好、易于阅读的格式表示这些时间段。下面给出了上述时间段的定义。
今天:
CREATE VARIABLE TODAY DATE DEFAULT CURRENT DATE
昨天:
CREATE VARIABLE YESTERDAY DATE DEFAULT CURRENT DATE – 1 DAY
明天:
CREATE VARIABLE TOMORROW DATE DEFAULT CURRENT DATE + 1 DAY
一个月的第一天:
CREATE VARIABLE FIRST_DAY_OF_CURRENT_MONTH DATE
DEFAULT
(CURRENT_DATE – (DAY (CURRENT_DATE)-1) DAYS)
一个月的最后一天:
CREATE VARIABLE LAST_DAY_OF_CURRENT_MONTH DATE
DEFAULT
(LAST_DAY (CURRENT DATE))
一个星期的第一天:
CREATE VARIABLE FIRST_DAY_OF_WEEK DATE
DEFAULT
(CURRENT_DATE – (DAYOFWEEK_ISO (CURRENT_DATE)-1) DAYS)
当前季度的第一天(请注意,定义中也使用了全局变量 FIRST_DAY_OF_THE_CURRENT_MONTH):
CREATE VARIABLE FIRST_DAY_OF_QUARTER DATE
DEFAULT
(ROUND (FIRST_DAY_OF_CURRENT_MONTH,’Q'))

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The difference between C++ local variables and global variables: Visibility: Local variables are limited to the defining function, while global variables are visible throughout the program. Memory allocation: local variables are allocated on the stack, while global variables are allocated in the global data area. Scope: Local variables are within a function, while global variables are throughout the program. Initialization: Local variables are initialized when a function is called, while global variables are initialized when the program starts. Recreation: Local variables are recreated on every function call, while global variables are created only when the program starts.

The Chinese meaning of request is "request". It is a global variable in PHP and is an array containing "$_POST", "$_GET" and "$_COOKIE". The "$_REQUEST" variable can obtain data and COOKIE information submitted by POST or GET.

The go language does not have static global variables. It uses a more flexible way to handle the need for global variables. Global variables are usually declared at the package level, that is, variables declared outside the function. These global variables are throughout the package. are visible and can be used in any function in the package.

Differences in syntax between db2 and oracle: 1. SQL syntax differences. Although db2 and oracle both use structured query language, they have some differences in syntax; 2. db2 and oracle have different data types; 3. Foreign key constraint definition, db2 can be defined when creating the table or added after using the "ALTER TABLE" statement. Oracle needs to be defined together when creating the table; 4. There are also some differences in the syntax of db2 and oracle stored procedures and functions.

As JavaScript becomes more popular, more and more websites and applications rely on JavaScript. However, the use of global variables in JavaScript can have security issues. In this article, I will introduce how to implement global variable safety in JavaScript. The best way to avoid using global variables is to avoid using global variables. In JavaScript, all variables are global by default unless they are declared within a function. Therefore, local variables should be used whenever possible

Golang is a strongly typed programming language with features such as efficiency, simplicity, and concurrency, so it is gradually favored by more and more developers. In the development of Golang, the global variables and local variables of functions often involve data competition issues. This article will analyze the data competition problem of global variables and local variables in Golang functions from the perspective of actual coding. 1. Data competition for global variables Golang global variables can be accessed in all functions, so if rigorous design and coding are not carried out

The annual CES is coming to an end. For this exhibition, Lei Technology has released 10+ in-depth reports, covering new product information, trend observation, exhibition experience, etc., and received a lot of feedback. There is so much information that Xiaolei wants to share about this CES. Today, Lei Technology’s rear reporting team compiled the 11 most important questions about this CES. Xiaolei answered them on the spot, hoping to help you quickly understand this consumer electronics session. Extravaganza. Q1: What trends have you seen in consumer electronics? CES stands for "Consumer Electronics Show" and is regarded as the global benchmark for consumer electronics. What “wind direction” does Xiaolei (ID: leitech) see this year? After visiting for a few days, the technology trends at CES2024 are actually very concentrated and prominent. In addition to what everyone has already mentioned

With chatbots such as ChatGPT and Wen Xinyiyan being put into use, artificial intelligence (AI) has become one of the hottest technological topics, triggering people's endless imagination about the future. Some insiders said: The next 5-10 years will be a critical period for the development of artificial intelligence. It is expected that the global artificial intelligence market will reach 16 trillion US dollars in 2030, and the scale of my country's artificial intelligence core industry will exceed 1 trillion yuan. According to the "2023 Global Unicorn List" released by Hurun Research Institute, there are 105 unicorns in the artificial intelligence industry, 21 more than a year ago, making it one of the fastest growing industries. Ranked fourth after financial technology (171 companies), software services (136 companies), and e-commerce (120 companies). China holds 33 seats. AI
