如果无法更改光标,仍可以使用负位置值
the
substr()
function
如Ed Gibbs所示,从字符串末尾向后计数,但与光标结果集相反:
with t as (
select 1 as costumer_id, 'jose' as name, '09' as branch_code from dual
union all select 2, 'peter ', '09' from dual
union all select 3, 'jhon', '09' from dual
union all select 4, 'charlie', '058' from dual
)
select costumer_id, name, branch_code,
substr(branch_code, -2) as new_branch_code
from t;
| COSTUMER_ID | NAME | BRANCH_CODE | NEW_BRANCH_CODE |
|
| 1 | jose | 09 | 09 |
| 2 | peter | 09 | 09 |
| 3 | jhon | 09 | 09 |
| 4 | charlie | 058 | 58 |
SQL Fiddle
.
因此,您可以使用相同的调用更改更新以设置值:
UPDATE table_example
SET code_cust = reg_customer_data.code_cust,
branch_code = substr(reg_customer_data.branch_code, -2),
...