ERROR: cannot insert multiple commands into a prepared stat
Posted: Fri 12 Sep 2008 13:19
Hi All,
I am executing stored procedure through my vc++ code gives error but same is ececuted through postgres UI:
My stored procedure is:
CREATE OR REPLACE FUNCTION abi_sp_getnewfiles(strserverid character varying, nmaxcount integer, nfilestate integer)
RETURNS refcursor AS
$BODY$declare
DECLARE cur cursor for SELECT recno FROM inputtable WHERE FileState=0 for update;
ref refcursor;
rownum integer;
ncount integer;
nrecno integer;
BEGIN
rownum :=0;
ncount := 0;
-- select files
open cur;
LOOP
if ncount > nmaxcount then
exit;
else
fetch cur into nrecno;
update inputtable set FileState=nFileState,ServerID=strServerID where recno=nrecno;
end if;
ncount := ncount + 1;
end loop;
close cur;
--update InputTable set FileState= nFileState ,ServerID=strServerID where FileState=0 and ROWNUM <= nMaxCount;
-- Open cursor to return from Stored Procedure
open ref for SELECT RecNo,FileName, ReceiverType, FileState, InitialWork,
Priority, ReceivedTime, RecvSourceDir, ReceiverKey,
TransactionID, FileID, INLOGKEY, ServerID
FROM InputTable
WHERE FileState= nFileState and ServerID=strServerID;
--Change to busy state
Update Inputtable set FileState=1
where FileState=nFileState and ServerID=strServerID;
--commit;
return ref;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION abi_sp_getnewfiles(character varying, integer, integer) OWNER TO postgres;
EROR IS AS BELOW:
"Code execution error.
Error[-2147467259]
Error message[Unspecified error]
Engine Used[PgOleDb]
Error type[ERROR: cannot insert multiple commands into a prepared statement
]
Any comments/suggestions would be appreciated.
Kind Regards
shilpa
I am executing stored procedure through my vc++ code gives error but same is ececuted through postgres UI:
My stored procedure is:
CREATE OR REPLACE FUNCTION abi_sp_getnewfiles(strserverid character varying, nmaxcount integer, nfilestate integer)
RETURNS refcursor AS
$BODY$declare
DECLARE cur cursor for SELECT recno FROM inputtable WHERE FileState=0 for update;
ref refcursor;
rownum integer;
ncount integer;
nrecno integer;
BEGIN
rownum :=0;
ncount := 0;
-- select files
open cur;
LOOP
if ncount > nmaxcount then
exit;
else
fetch cur into nrecno;
update inputtable set FileState=nFileState,ServerID=strServerID where recno=nrecno;
end if;
ncount := ncount + 1;
end loop;
close cur;
--update InputTable set FileState= nFileState ,ServerID=strServerID where FileState=0 and ROWNUM <= nMaxCount;
-- Open cursor to return from Stored Procedure
open ref for SELECT RecNo,FileName, ReceiverType, FileState, InitialWork,
Priority, ReceivedTime, RecvSourceDir, ReceiverKey,
TransactionID, FileID, INLOGKEY, ServerID
FROM InputTable
WHERE FileState= nFileState and ServerID=strServerID;
--Change to busy state
Update Inputtable set FileState=1
where FileState=nFileState and ServerID=strServerID;
--commit;
return ref;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION abi_sp_getnewfiles(character varying, integer, integer) OWNER TO postgres;
EROR IS AS BELOW:
"Code execution error.
Error[-2147467259]
Error message[Unspecified error]
Engine Used[PgOleDb]
Error type[ERROR: cannot insert multiple commands into a prepared statement
]
Any comments/suggestions would be appreciated.
Kind Regards
shilpa