在postgresql函数中遇到以下函数出现问题:
我得到以下错误:
错误:查询没有结果数据的目的地 提示:如果要放弃SELECT的结果,请改用PERFORM。 语境:PL语句中的PL / pgSQL函数savegamelog(text,text,integer,integer,bigint,bigint,bigint,integer,integer,integer,integer)第15行
我的功能如下:
DECLARE
s text;
pDatatime integer;
pDataid bigint;
BEGIN
pDatatime = floor(extract(epoch from '["now()",]'::timestamp));
IF length(pTableName) > 0 THEN
UPDATE lastgamedata SET data= pData::bytea, gameid= pGameid, balance= pBalance ,bet= pBet, win= pWin, betline= pBetline, lines=pLines, datatime= pDatatime WHERE uid= pUserid;
END IF;
UPDATE gamestatistic SET totalin =totalin+pBet , totalout =totalout+pWin WHERE gameindex=pGameid;
SELECT dblink_connect('host=127.0.0.1
user=user
password=pass
dbname=dbname');
SELECT dblink_exec('UPDATE hall SET totalbetin = totalbetin+pBet , totalbetout =totalbetout+pWin WHERE id = (SELECT roomnumber FROM users WHERE uid = pUserid)');
INSERT INTO gamedata( sessionID, uid, gameID, key, balance, bet, win, betline, lines, datatime, type, denomination ) VALUES ( 0, pUserid, pGameid, 0, pBalance, pBet, pWin, pBetline, pLines, pDatatime, pType, pDenomination ) RETURNING dataid INTO pDataid;
INSERT INTO gamedata_storage ( dataid, data ) VALUES ( pDataid, pData::bytea );
return pDataid;
END;
我知道功能是错误的,我不知道如何解决它.. 任何人都可以指出我正确的方向..
答案 0 :(得分:2)
按照错误消息说明进行操作,更改
SELECT dblink_connect('host=127.0.0.1
user=user
password=pass
dbname=dbname');
到
PERFORM dblink_connect('host=127.0.0.1
user=user
password=pass
dbname=dbname');