http://apex.oracle.com/pls/apex/f?p=31517:282
It will search not only for a single character withing a string but also for a substring of any length up to 4000 characters.
SELECT create_pkg_from_table.create_package ('EMP', 'EMPNO', 1)
FROM DUAL;
5. Finally, run the following SQL to create the calls to the package functions and procedures you will need in your page processes and validations:
SELECT create_pkg_from_table.create_plsql_block ('EMP', 'EMPNO', 1)
FROM DUAL;
The only thing you need to do now is to format that code and paste it in the appropriate process.
CREATE OR REPLACE FUNCTION x_rep (p_string IN VARCHAR2)
RETURN VARCHAR2
IS
v_string VARCHAR2 (4000);
BEGIN
v_string :=
REPLACE (TRANSLATE (p_string, 'x' || CHR (10) || CHR (13), 'x'),
';',
'/'
);
RETURN v_string;
EXCEPTION
WHEN OTHERS
THEN
RETURN NULL;
END x_rep;
/
FUNCTION get_string_highlight (p_string IN VARCHAR2, p_highlight IN VARCHAR2)
RETURN VARCHAR2
IS
v_string VARCHAR2 (4000);
v_substring VARCHAR2 (4000);
v_trailingstring VARCHAR2 (4000);
v_newstring VARCHAR2 (32000);
v_position NUMBER := 0;
v_length NUMBER := LENGTH (p_highlight);
v_span_start VARCHAR2 (400)
:= '<span style="color:red;font-weight:bold">';
v_span_end VARCHAR2 (400) := '</span>';
BEGIN
IF p_highlight IS NOT NULL
THEN
v_string := p_string;
FOR i IN 1 .. 20
LOOP
v_position := INSTR (UPPER (v_string), UPPER (p_highlight));
IF v_position > 0
THEN
v_substring := SUBSTR (v_string, 1, v_position + v_length);
v_substring :=
SUBSTR (v_string, 1, v_position - 1)
|| v_span_start
|| SUBSTR (v_string, v_position, v_length)
|| v_span_end;
v_string := SUBSTR (v_string, v_position + v_length);
v_newstring := v_newstring || v_substring;
END IF;
EXIT WHEN v_position = 0;
END LOOP;
v_newstring := v_newstring || v_string;
ELSE
v_newstring := p_string;
END IF;
RETURN v_newstring;
END get_string_highlight;
DECLARE
vrow BINARY_INTEGER;
BEGIN
FOR i IN 1 .. apex_application.g_f01.COUNT
LOOP
vrow := apex_application.g_f01 (i);
UPDATE dept
SET dname = apex_application.g_f04 (vrow),
loc = apex_application.g_f05 (vrow)
WHERE empno = apex_application.g_f02 (vrow);
END LOOP;
END;
The easiest way to debug is to use:
CREATE OR REPLACE FUNCTION compare_checkbox_strings (
p_checkbox IN VARCHAR2,
p_column IN VARCHAR2
)
RETURN NUMBER
IS
l_vc_arr2 apex_application_global.vc_arr2;
v_count NUMBER;
BEGIN
l_vc_arr2 := apex_util.string_to_table (p_checkbox);
FOR i IN 1 .. l_vc_arr2.COUNT
LOOP
EXIT WHEN v_count > 0;
v_count := INSTR (':' || p_column || ':', ':' || l_vc_arr2 (i) || ':');
END LOOP;
IF v_count > 0
THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
END compare_checkbox_strings;
Now, you can use it in your SQL Query like this:
SELECT * FROM your_table WHERE compare_checkbox_strings (:p1_your_checkbox, your_column) = 1;You can find a working example here: http://apex.oracle.com/pls/otn/f?p=31517:275
INSERT INTO dbt_images
SELECT *
FROM dbt_images@remote_db
WHERE ID = p_id;
CREATE TABLE dbt_images AS
SELECT *
FROM dbt_images@remote_db
WHERE 1 = 2;
CREATE OR REPLACE TYPE object_row_type AS OBJECT ( ID NUMBER, NAME VARCHAR2 (256), image BLOB, creator NUMBER, created DATE ); /
CREATE OR REPLACE TYPE object_table_type AS TABLE OF object_row_type; /
CREATE OR REPLACE FUNCTION get_remote_blob (p_id IN NUMBER)
RETURN object_table_type PIPELINED
IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO dbt_images
SELECT *
FROM dbt_images@remote_db
WHERE ID = p_id;
COMMIT;
FOR cur IN (SELECT ID, NAME, image, creator, created
FROM dbt_images)
LOOP
PIPE ROW (object_row_type (cur.ID,
cur.NAME,
cur.image,
cur.creator,
cur.created
));
END LOOP;
DELETE FROM dbt_images
WHERE ID = p_id;
COMMIT;
RETURN;
END get_remote_blob;
/
SELECT ID, image, NAME, DBMS_LOB.getlength (image) FROM TABLE (getblob (p_id));


