SQL 陳述式
資料總管區域可用來透過一或多個 SQL 陳述式選取要顯示的資料。SQL 參數適用於下列區域類型
-
資訊資料總管 - 單一 SQL (F1-DE-SINGLE)。參數具有 SQL 陳述式描述。
-
資訊資料總管 - 多個 SQL (F1-DE)。參數會遵循SQL 陳述式 x的描述模式。
-
查詢資料總管 - 多個 SQL (F1-DE-QUERY)。參數會遵循SQL 陳述式 x的描述模式。
關鍵字 |
---|
AT |
下列資料表提供可在資料總管區域的 SQL 陳述式參數中使用的 SQL 替代關鍵字列表。執行時,系統會判斷資料庫,然後使用資料庫特定語法來替代關鍵字:
關鍵字 |
描述 |
範例 |
---|---|---|
@toCharacter() |
將輸入轉換成「字元」資料類型。 |
select @toCharacter(batch_cd) as batchCode from ci_batch_ctrl |
@toDate() |
將輸入轉換成「日期」資料類型。 |
select @toDate(last_update_dttm) as lastUpdateDate from ci_batch_ctrl |
@toNumber() |
將輸入轉換成「數字」資料類型。 |
select @toNumber(next_batch_nbr) from ci_batch_ctrl |
@currentDate |
擷取目前日期。 注意:不應該使用 Oracle 函數 SYSDATE 和 CURRENT_DATE,因為它們無法在需要時,適當地將日期從資料庫時區調整成安裝時區。
|
select batch_cd, @currentDate as today from ci_batch_ctrl |
@currentTimestamp |
擷取目前日期/時間。 注意:不應該使用 Oracle 函數 SYSTIMESTAMP 和 CURRENT_TIMESTAMP,因為它們無法在需要時,適當地將日期/時間從資料庫時區調整成安裝時區。
|
select batch_cd from ci_batch_ctrl where last_update_dttm > @currentTimestamp |
@concat |
將兩個或更多個資料欄的結果列表結合在一起。 |
select batch_cd @concat next_batch_nbr concatNbr from ci_batch_ctrl |
@substr(string, start) |
String 是您嘗試取得其子字串的輸入字串。 Start 是輸出結果的字元位置。 |
select batch_cd batchCode from ci_batch_ctrl 結果:TESTCD select @substr(batch_cd,3) batchCode from ci_batch_ctrl 結果:STCD |
@substr(string, start, end) |
String 是您嘗試取得其子字串的輸入字串。 Start 是輸出結果的字元位置。 End 是輸出中從開始位置算起的所需字元數。 |
Select batch_cd batchCode from ci_batch_ctrl 結果:TESTCD select @substr(batch_cd,3,2) batchCode from ci_batch_ctrl 結果:ST |
@trim |
刪減輸出兩端的空格。 |
select @trim(batch_cd) as batchCode from ci_batch_ctrl |
以下是與「模糊」搜尋相關的語法。只有在已啟用 Oracle DB Text 並已建立內容文字索引的情況下,才適用該語法。如需詳細資訊,請參考進階搜尋選項。 |
||
@fuzzy(string, score, numresult, ‘weight’) |
String 是搜尋的輸入值。 Score 是「模糊」程度。有效值介於 1 - 80。數字越大,搜尋閱精確。預設值為 60。 Numresults 是要考量的字串變動數。有效值介於 1 到 5000。預設值為 100。 指示 ‘weight’ 以表示依權重順序傳回結果。將此設定保持關閉以指示依分數順序傳回結果。 |
將分數設為 70、結果數設為 6 並指定權重。 select user_id, last_name from sc_user where contains(last_name, @fuzzy(:F1,70, 6, 'weight')) > 0 |
@fuzzy(string) |
這會從假設 score 為預設值 60 並假設 numresult 為預設值 100 的模糊擴展作業傳回字串結果。 |
使用預設值: select user_id, last_name from sc_user where contains(last_name, @fuzzy(:F1))> 0 |
@fuzzy(string, score) |
這會從已指定 score 且 numresult 為預設值 100 的模糊擴展作業傳回字串結果。 |
將分數設為 70。 select user_id, last_name from sc_user where contains(last_name, @fuzzy(:F1,70)) > 0 |
@fuzzy(string, score, numresult) |
這會從已指定相似性分數和 numresult 的模糊擴展作業傳回字串結果。 |
將分數設為 70、將結果數設為 6。 select user_id, last_name from sc_user where contains(last_name, @fuzzy(:F1,70, 6)) > 0 |