1752613 Members
4836 Online
108788 Solutions
New Discussion юеВ

Re: 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 2
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!!!