[20180808]Null value to Dynamic SQL.txt
[20180808]Null value to Dynamic SQL.txt
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> create table t1( id number,name varchar2(10));
Table created.
insert into t1 values (1,'a');
insert into t1 values (2,'b');
commit ;
begin
execute immediate 'update t1 set name = :1' using null;
end;
/
execute immediate 'update t1 set name = :1' using null;
*
ERROR at line 2:
ORA-06550: line 2, column 51:
PLS-00457: expressions have to be of SQL types
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
--//主要原因是這裡的NULL不知道什麼型別,只要定義型別就ok了.
--//修改如下:
begin
execute immediate 'update t1 set name = :1' using cast(null as varchar2(10));
end;
/
execute immediate 'update t1 set name = :1' using cast(null as varchar2(10));
*
ERROR at line 2:
ORA-06550: line 2, column 72:
PLS-00103: Encountered the symbol "(" when expecting one of the following:
. ) @ %
--//依舊不行.視乎在這裡不能使用括號指定長度.
begin
execute immediate 'update t1 set name = :1' using cast(null as varchar2);
end;
/
--//這樣ok!
SCOTT@book> select * from t1;
ID NAME
---------- --------------------
1
2
SCOTT@book> rollback;
Rollback complete.
--//當然也可以這樣寫:
declare
v_name varchar2(10);
begin
v_name := null;
execute immediate 'update t1 set name = :1' using v_name;
end;
/
SCOTT@book> select * from t1;
ID NAME
---------- --------------------
1
2
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2199613/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- C# return dynamic/anonymous type value as function resultC#Function
- mysql遇到Variable can’t be set to the value of ‘NULL’MySqlNull
- use the function_based index to access the null valueFunctionIndexNull
- Hashtable/HashMap與key/value為null的關係HashMapNull
- duplicate ORA-01405: fetched column value is NULLNull
- (entity bean)動態賦值值物件-- Dynamic Create Value Object 模式 (轉)Bean賦值物件Object模式
- 動態賦值弱型別值物件--Dynamic Create Value Object 模式 (轉)賦值型別物件Object模式
- Mysql:Variable 'XXXt' can't be set to the value of 'NULL'解決MySqlNull
- 解決問題:Variable 'time_zone' can't be set to the value of 'NULL'Null
- mysql:Variable 'character_set_client' can't be set to the value of 'NULL'解決MySqlclientNull
- VUE前端打包報錯:TypeError: Class extends value undefined is not a constructor or nullVue前端ErrorUndefinedStructNull
- Variable 'character_set_client' can't be set to the value of Null的解決方法clientNull
- [Err] 1231 - Variable 'sql_mode' can't be set to the value of 'NULLSQLNull
- [mysql] 批量匯入提示: Variable ‘character_set_client’ can’t be set to the value of ‘NULLMySqlclientNull
- mysql匯入報錯Variable 'sql_notes' can't be set to the value of 'NULL'MySqlNull
- Not-null property references a transient value - transient instance must be saved before current opeNull
- ((NULL) null).printNULL();((NULL) null).printnull();Null
- 永久有效的 webstorm license server 20180808WebORMServer
- IS NULL和IS NOT NULLNull
- [20120508]bad sql.txtSQL
- not null與check is not nullNull
- [20160121]調式PL SQL.txtSQL
- php static dynamicPHP
- C# dynamicC#
- dynamic_castAST
- 了不起的 “filter(NULL IS NOT NULL)”FilterNull
- MySQL中is not null和!=null和<>null的區別MySqlNull
- 物件轉json字串的過程中對value為null的值的一些處理物件JSON字串Null
- 【NULL】Oracle null值介紹NullOracle
- mysql探究之null與not nullMySqlNull
- Difference between 2>&-, 2>/dev/null, |&, &>/dev/null, >/dev/null, 2>&1devNull
- dynamic bone unity githubUnityGithub
- why use dynamic SQL?SQL
- Disable Dynamic DNS updateDNS
- MySQL案例-TIMESTAMP NOT NULL與NULLMySqlNull
- LOW_VALUE、HIGH_VALUE、ENDPOINT_VALUE轉換--UTL_RAW、DBMS_STATS.CONVERT_RAW_VALUE
- MySQL中IS NULL、IS NOT NULL、!=不能用索引?胡扯!MySqlNull索引
- [20190706]Same dog, different leash – functions in SQL.txtFunctionSQL