Get the App
SLTechnology News&Howtos  ›  Database  › 

How to determine whether a string contains a picture format by the oracle function

Shulou Source: shulou.com Published: 2022-05-31 21:07:14 10月23日 Update

This article will explain in detail how the oracle function determines whether the string contains a picture format. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.

The first is to write a function that splits a string and returns a table type.

CREATE OR REPLACE FUNCTION fn_split (p_str IN VARCHAR2, p_delimiter IN VARCHAR2)RETURN ty_str_splitIS j INT := 0; i INT := 1; len INT := 0; len1 INT := 0; str VARCHAR2 (4000); str_split ty_str_split := ty_str_split ();BEGIN len := LENGTH (p_str); len1 := LENGTH (p_delimiter); WHILE j

< len LOOP j := INSTR (p_str, p_delimiter, i); IF j = 0 THEN j := len; str := SUBSTR (p_str, i); str_split.EXTEND; str_split (str_split.COUNT) := str; IF i >

= len THEN EXIT; END IF; ELSE str := SUBSTR (p_str, i, j - i); i := j + len1; str_split.EXTEND; str_split (str_split.COUNT) := str; END IF; END LOOP; RETURN str_split;END fn_split;

The above function can split the string and return it to table

create or replace function fn_ispng( strpng in varchar2 ) return number is v_num number;begin WITH t1 AS (select * from table (fn_split(strpng,'. ')) ) select count(1) into v_num from t1 where t1.column_value in ('png', 'jpg','jpeg','gif','bmp','eps'); return v_num;end fn_ispng;

The above is to determine whether it is a picture format, the picture format returns 1

select fn_ispng('dfdfd.png') From dual; About "oracle function how to determine whether the string contains image format" This article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Tags: Function picture character string format article more good practical content article knowledge type reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux Shulou Information NVidia Docker