ERROR: cannot insert multiple commands into a prepared stat

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
ABCDEFG
Posts: 2
Joined: Fri 12 Sep 2008 13:09

ERROR: cannot insert multiple commands into a prepared stat

Post by ABCDEFG » 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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Mon 15 Sep 2008 11:12

According to this error, you are using PgOleDb (not PostgreSQLDirect). Similar situation was discussed here: http://www.devart.com/forums/viewtopic.php?t=12855

ABCDEFG
Posts: 2
Joined: Fri 12 Sep 2008 13:09

ERROR: cannot insert multiple commands into a prepared state

Post by ABCDEFG » Fri 19 Sep 2008 11:16

hi

I had seen your link but my problem is not solved....can any please suggest me proper forum for posting problem.

My Configurations are:
Platform: Windows XP
Language Used: VC++
Database Technology: ADO
Back End: Postgres
Postgres Language: plpgsql


While executing stored procedure through my vc++ code gives error but when same is executed through postgres UI it compiled successfully.

Errors are:
"Code execution error.
Error[-2147467259]
Error message[Unspecified error]
Engine Used[PgOleDb]
Error type[ERROR: cannot insert multiple commands into a prepared statement

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 19 Sep 2008 14:43

Try to find the proper forum here: http://www.postgresql.org/community/resources

Post Reply