Procedure does not count space : Utility Procedure « Stored Procedure Function « Oracle PL / SQL






Procedure does not count space

 
SQL> --
SQL>
SQL> CREATE OR REPLACE function dontcountsp(p_pass_string VARCHAR2)
  2          RETURN NUMBER IS
  3               v_MYCOUNTER INTEGER := 1;
  4               v_COUNTNOSP NUMBER := 0;
  5     BEGIN
  6          WHILE v_MYCOUNTER <= LENGTH(p_PASS_STRING) LOOP
  7               IF SUBSTR(p_PASS_STRING,v_MYCOUNTER,1) != ' ' THEN
  8                    v_COUNTNOSP := v_COUNTNOSP + 1;
  9               ELSE
 10                   NULL;
 11              END IF;
 12              v_MYCOUNTER := v_MYCOUNTER + 1;
 13         END LOOP;
 14         RETURN v_COUNTNOSP ;
 15    END dontcountsp;
 16    /

Function created.

SQL>
SQL>   DECLARE
  2         v_MYTEXT VARCHAR2(20) := 'THIS IS A TEST';
  3    BEGIN
  4         DBMS_OUTPUT.PUT_LINE('Total count is ' || dontcountsp(v_MYTEXT));
  5    END;
  6    /
Total count is 11

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> --

 








Related examples in the same category

1.Assert procedure
2.Use stored procedure to output table content
3.emp table lookup
4.Use stored procedure to log message
5.Create a stored procedure to measure a table usage
6.File dump procedure
7.Copy tables
8.Count credits