问题
Hello I have a PostgreSQL function which returns table
-- Function: stloadstoryview(integer)
-- DROP FUNCTION stloadstoryview(integer);
CREATE OR REPLACE FUNCTION stloadstoryview(IN luserid integer)
RETURNS TABLE(stid integer, stname text, stowner character varying, stbegin date, stend date) AS
$BODY$
Begin
Return query
Select dbStory.stID, dbStory.stName, (Select usName from dbUser where usID = dbStory.stOwner):: Varchar(30), dbStory.stBegin, dbStory.stEnd from dbStory
where dbStory.stID in (Select dbStoryRights.stID from dbStoryRights where usID = lUserID)
Order by dbStory.stName;
End;
$BODY$
LANGUAGE plpgsql STABLE
COST 100
ROWS 1000;
ALTER FUNCTION stloadstoryview(integer)
OWNER TO postgres;
which will return
"(2,"Story 201",admin,2015-01-01,2015-06-30)"
"(1,Story101,admin,2015-03-01,2015-04-30)"
In the first row it will return "Story 201" with quotes and in second row "Story101" which is unquoted.....
If the spaces in between the values its returning quotes so how to get all values in that column without qoutes.Having spaces in the values.
回答1:
It looks like you are querying the function directly which will return a single column containing all the values returned from the function.
Try selecting the fields from the function instead:
SELECT *
FROM stloadstoryview(1);
Which will return data in separate columns:
"stid", "stname", "stowner", "stbegin", "stend"
2, Story 201, admin, 2015-01-01, 2015-06-30
1, Story101, admin, 2015-03-01, 2015-04-30
来源:https://stackoverflow.com/questions/29281371/how-to-remove-or-escape-the-double-quotes-while-returning-table-from-postgresql