I have a procedure:
CREATE OR REPLACE PROCEDURE get_row_count (
p_table_name IN VARCHAR2,
p_row_count OUT NUMBER
) AS
v_sql VARCHAR2(1000);
BEGIN
-- Construct the SQL query to count rows
v_sql := 'SELECT COUNT(*) FROM ' || p_table_name;
-- Execute the SQL statement and get the count
EXECUTE IMMEDIATE v_sql INTO p_row_count;
EXCEPTION
WHEN OTHERS THEN
-- Handle exceptions (e.g., table not found)
p_row_count := -1; -- or raise an error
DBMS_OUTPUT.PUT_LINE('Error: ' || SQLERRM);
END get_row_count;
/
It compiles properly and procedure is placed into appropriate place in SQL Object Browser, but I don't know how to run it from SQL commands or SQL Scripts. I tried the following:
begin
get_row_count(p_table_name => 'Produkty');
end;
but I get error
Error at line 2/3: ORA-06550: line 2, column 3: PLS-00306: wrong number or types of arguments in call to 'GET_ROW_COUNT' ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_240100", line 802 ORA-06550: line 2, column 3: PL/SQL: Statement ignored
I also tried:
begin
get_row_count('Produkty');
end;
but then I get error:
Error at line 2/3: ORA-06550: line 2, column 3: PLS-00306: wrong number or types of arguments in call to 'GET_ROW_COUNT' ORA-06512: at "SYS.WWV_DBMS_SQL_APEX_240100", line 802 ORA-06550: line 2, column 3: PL/SQL: Statement ignored
when I try exec get_row_count('Produkty'); I get error: ORA-00900: invalid SQL statement.
Maybe it is something simple I'm missing. Please let me know a way to call this procedure from sql commands.
Thanks