Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error in script

ancys
Occasional Contributor

Error in script

hi,

I wrote unix shell program(bash) which in turn executes two sql statements
TaBLE STRUCTURE
Employee
criteriano project
ctr2 update table1 set empname='arun' where empid=1

SCRIPT
#!bin/sh
/oraclepath username/password<
update employee
set sal=sal+2000;
commit;

DECLARE result employee.project%TYPE;
i NUMBER DEFAULT 0;
j NUMBER;
BEGIN
SELECT COUNT(*) INTO j FROM employee WHERE EXISTS(SELECT * FROM employeeWHERE CRITERIANO='Crt2');
IF(j>0) THEN
DECLARE CURSOR cursorname IS SELECT * FROM employee WHERE criteriano='Crt2';
BEGIN
FOR navcursor IN cursorname
LOOP
i:=i+1;
result:=navcursor.project;
EXECUTE IMMEDIATE result;
dbms_output.put_line('Look Ma, I can print from PL/SQL!!!');

COMMIT;
END LOOP;
END;
ELSE
dbms_output.put_line('Look Ma, I can print from PL/SQL!!!');

END IF;
END
EOF

Both query gets execute successfully in query analyser
But when used in unix script 1st query gets executed not the second(i.e) cursor.
Its not able to read the cursor
I need both the query to be executed when i run the script

How to solve this
Help me
2 REPLIES
Jonathan Fife
Honored Contributor

Re: Error in script

What error is it giving you? How do you know it is "not able to read the cursor"?

Also, is that the actual contents of your script?
Decay is inherent in all compounded things. Strive on with diligence
ancys
Occasional Contributor

Re: Error in script

hi

Any sql statements(insert or update or delete or cursor concept) which is placed after the update statement is not getting executed.

The concept is for given criteriano there can multiple project i need to navigate through the records for given criteria no

Help Please!!!