It seems that all you need in the from clause is vw_lmc_sqlldr_metrics a and lmc_metrics_instances e. I would normally have the select lists pass null for ALL and have lines in the where caluse like:
AND (p_str_database IS NULL OR p_str_database IS NOT NULL AND a.lmc_db_name = p_str_database)
The methods used by this developer look like overkill. In fact it looks as though they were playing with this functionality as a learning process for a time when it's actually a requirement.
Ray
From: "Berthoff, Tom" <Tom.Berthoff sig.com> Reply-To: ODTUG-SQLPLUS-L fatcity.com To: Multiple recipients of list ODTUG-SQLPLUS-L <ODTUG-SQLPLUS-L fatcity.com> Subject: Sanity check Date: Wed, 24 Sep 2008 09:30:39 -0800 Hi,
Here's the situation:
We have a database with information from log files. The log files are generally FTP logs - which files got downloaded, where they went, how big they are, etc - and SQL*Loader logs - rows read, rows rejected, start time, etc.
We are building a web page front end for the database that allows users to query the logs.
So, for instance, we have a query page for the SQL*Loader logs which allows the user to choose a database and/or choose a schema and/or choose a table and/or choose a log file
and/or choose a date, then query the database for those parameters.
The web developer has drop-downs for each of the possible parameters. He initializes each drop-down when loading the page, so that the database drop-down contains all the possible databases, for example. Each drop-down has a default value of "all".
Here's the question:
If the user selects "all" on a given drop down, the web developer takes all the values in the array he uses to populate the drop down, parses them into a comma-delimited string, passes that into stored procedure via a VARCHAR2 variable, then uses a function to put the delimited string into an array which is cast to an object and used in an IN clause in the query. An example follows at the end of the message.
This screams "scalability problems" at me every time I look at it. We're running the query against the development
database which returns small result sets for the databases, schemas, tables, and logs. If we go into production and a lot of people start putting log files into the database, we're looking at possibly hundreds of databases, thousands of schemas, tens of thousands of tables, and millions of log files.
Do you agree with me? Or is the developer taking the correct approach?
If you agree with me, what would be your approach?
Here's the procedure, with query:
PROCEDURE reporting_sqlldrlog ( p_rc_metrics OUT rc_generic, p_str_database IN VARCHAR,
p_str_schema IN VARCHAR, p_str_instance_id IN VARCHAR ) IS BEGIN DBMS_APPLICATION_INFO.set_action ('reporting_sqlldrlog');
OPEN p_rc_metrics FOR SELECT e.lmc_metr_ins_file_name, a.cpu_time, a.elapsed_time, a.lmc_db_name, a.lmc_db_schema_name,
a.lmc_db_table_name, a.nbr_rows_data_errors, a.nbr_rows_discarded, a.nbr_rows_loaded, a.nbr_rows_read, a.nbr_rows_rejected, a.nbr_rows_skipped, a.run_begin, a.run_end, a.lmc_metrics_instance_id FROM vw_lmc_sqlldr_metrics
a, (SELECT TO_CHAR (COLUMN_VALUE) AS in_database FROM THE   |