Member Avatar

Hi all, I wanted to procedure to return number of days and weekdays between two dates. This is what I came up with and it seems to work ok, but I'd like to read what others think. And if there's already a single line function for this, oops. Also, I'm not too comfortable with when to use @variable or just variable. Thanks. DELIMITER $$ CREATE PROCEDURE `DATEDIFF_WEEKDAYS`(IN `IN_from_date` DATE, IN `IN_to_date` DATE) BEGIN DECLARE TOTAL_WEEKDAYS INT DEFAULT 0; DECLARE TOTAL_DAYS INT DEFAULT 0; DECLARE FROM_DTE DATE DEFAULT NOW(); DECLARE TO_DTE DATE DEFAULT NOW(); DECLARE CURR_DTE DATE DEFAULT NOW(); IF(IN_from_date = …

Member Avatar
+0 forum 3
Member Avatar

Hi, I am currently creating 'Routines' to speed up the analysis of the quiz data my database stores. One of the queries I have been using which I would like to turn into a Routine looks like this. SELECT Candidate, QuizName, PercentageScore, PassFail FROM Results WHERE Candidate ='Joe Bloggs' This works perfectly but in order to turn this into a 'Routine' I would have to create a 'Routine' for every single staff member using the quiz. Is there a way where I can have the 'Joe Bloggs' as a input. So I can call the rest of the code but …

Member Avatar
+0 forum 11
Member Avatar

Hi, I am in urgent need for converting sql procedure to postgre sql procedure.Please help me ASAP. CREATE FUNCTION sp_get_id_des (IN cellid INT, IN mcc VARCHAR(3), IN mnc VARCHAR(3), IN nwtype INT, IN mlac INT , IN mrac INT ) returns SETOF record AS' declare pscnt int ; declare cscnt int; declare cnt1 int ; declare cnt2 int; declare cscnid int ; declare pscni int; declare cscnpoolid varchar(20); declare pscnpoolid varchar(20); **DECLARE CONTINUE HANDLER FOR SQLSTATE '42S02' SET @x2 = 1;** BEGIN drop table TEMP_CNINFO_TBL; drop table RESULT_TBL; create temporary table TEMP_CNINFO_TBL select * from FGW_DBS_CNINFO_TBL where CNINFO_MLAC=mlac and CNINFO_MRAC=mrac …

+0 forum 0
Member Avatar

I am trying to write a few very dynamic procedures and functions and wonder about transferring parameters to a procedure as an Array. This is actually easy enough done.... just that I would like to pass something like [CODE] VAR a,b,c : INTEGER; Name, Text1,Text2 : STRING; todaysDate : TDate; PROCEDURE HandleValues(Const Values:ARRAY OF ???) BEGIN // Code to handle fetching the values. END; BEGIN HandleValues([a,b,c,Name,Text1,TodaysDate]); HandleValues([Name,Text1,Text2,a,c]); END. [/CODE] The whole point is that I do not know in which order the parameters occur in the array. I do not know what type comes where. If it only was a …

Member Avatar
+0 forum 4
Member Avatar

Hi, Is there a way i can pass variable column names to a stored proc? Here's what i want to do: i have lots of tables and for each of those i want to select out a few columns. e.g from table titles i want to pick out title_name and cost then maybe i want to go to publishers and pick out mean cost and country. I have the table names and the column names in a perl script. Can i pass these as variables to a generic stored proc? here's what i tried: [CODE] create procedure test_proc @file VARCHAR(256) …

Member Avatar
+0 forum 1

The End.