2013-10-16 18 views
2

在PL/SQL匿名塊中使用替換字符串有什麼辦法嗎?我試圖在PL/SQL匿名塊內使用我的替換字符串DATE_DIFF作爲&DATE_DIFF.但它給出了以下錯誤。在PL/SQL匿名塊中使用替換字符串

ORA-06550: line 13, column 18: PLS-00103: Encountered the symbol "&" when expecting one of the following: (- + all case mod new null <an identifier> <a double-quoted delimited-identifier> <a bind variable> continue any avg count current max min prior some sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set s

我怎樣才能解決這個問題?

更新PL/SQL匿名塊使用替換字符串的

示例代碼。

DECLARE 
v_date_diff NUMBER; 
BEGIN 

v_date_diff := &DATE_DIFF.; // this didn't work 

END; 
+1

替換變量是SQLP * PLUS相關功能。其他一些工具可能會或可能不支持它們。 –

+0

@NicholasKrasnov對替換字符串的Oracle APEX支持。 – Bishan

+0

如果我沒有在PL/SQL塊中的APEX中弄錯,替換變量的語法將是':DATE_DIFF'或使用'V'函數'V('DATE_DIFF')'。 –

回答

1

在APEX,當您想要檢索會話狀態的項目爲標籤,列表等使用替換字符串語法(&DATE_DIFF.)。爲了獲取會話狀態在PL/SQL塊,你要麼前綴項目名與冒號的項目,或者使用V()功能:

  1. :DATE_DIFF
  2. v('DATE_DIF')