Home » SQL & PL/SQL » SQL & PL/SQL » Need help in Stored Procedure SQL Statement
Need help in Stored Procedure SQL Statement [message #40709] Fri, 01 November 2002 11:43 Go to next message
Srikanth Mannem
Messages: 6
Registered: October 2002
Junior Member
Hi,

I have a requirement to update table that has 138 columns. The columns are named as CommitedHours1, CommitedHours2, ... CommitedHours138.

I wrote the following 138 statements and it worked.

UPDATE FORECASTOUTPUT SET CommitedHours2 = 0 WHERE HolidayScheduleOID IN (Select HolidayScheduleOID FROM EDS_HolidaysView WHERE to_char(HolidayDate, 'DD-MON-YY') = to_char(tmpDataDate + 1, 'DD-MON-YY')) AND FLAG IN (tmpWorkweek, tmpCommitments, tmpInactivity) AND
SESSIONID = tmpSessionID;

But, when I put them in the For Loop and it's not working. As I am running the Stored Procedure with ASP, it gives me that the SQL is invalid. Can anyone please help me.

FOR I IN 1 .. 138
LOOP
tmpString := 'UPDATE FORECASTOUTPUT SET CommitedHours' || I;

tmpString := tmpString || ' = 0 WHERE HolidayScheduleOID IN (Select HolidayScheduleOID FROM EDS_HolidaysView';

tmpString := tmpString || ' WHERE to_char(HolidayDate, ''DD-MON-YY'') = to_char(tmpDataDate + ' || tmpDummy1;

tmpString := tmpString || ', ''DD-MON-YY'')) AND FLAG IN (' || tmpWorkweek || ', ' || tmpCommitments;

tmpString := tmpString || ', ' || tmpInactivity || ') AND SESSIONID = ' || tmpSessionID;

EXECUTE IMMEDIATE tmpString;
tmpDummy1 := tmpDummy1 + 1;
END LOOP;
Re: Need help in Stored Procedure SQL Statement [message #40710 is a reply to message #40709] Fri, 01 November 2002 11:58 Go to previous message
Rick Cale
Messages: 111
Registered: February 2002
Senior Member
Too much to look at. I would suggest writing the value of tmpString then try to run in sqlplus. I would debug from that side then from inside this app.
Previous Topic: variable substitution in stored procedure
Next Topic: Hands On
Goto Forum:
  


Current Time: Sun Apr 28 18:09:33 CDT 2024