Postgresql stored function returning only values not with column names -
I'm new to Postgresql; I have just created the function with the overall type
after my code is :
(find_id bigint, result_name character different, different result_loc character, RESULT_TYPE character different, result_pic character different) Create type_ search_type; Create or function search_result REPLACE ("@ search_text" character different) SETOF gives $ search_type $ body $ declarative as search_type% rowtype; As a result, "user_id" as "user_id" in the form of "user_id" as "user_firstname", "user_firstname", "user_firstname", "result_name", "user_loc" result_loc, result_pic as 'user_picurl', 'user' As the result_type users_list where CONCAT ("Context" ("@ search_text", '%') to proceed LOOP RETURN; User_firstname ",", "User_lastname"); For "end loop" r "SELECT SELECT" Community_id "result_id Result_name as "result_name" as "Community_name", result_loc as "Community_location", result_pic as "Community_img_url", result_type community_list as 'community' where "contact" ("@ search_text", '%') and "type "= 'Created' Lu Next return next; End loop; Return; End $ body $ language plpgsql But when I called the stored function like the code below, it would not only be the datas with the column name
select search_result ('C'); What will happen?
How can I return column names with prices?
The recurring given above is returned.
But I need to get the result as:
result_id result_name result_loc result_pic result_type --------- ------- ---- ----- ----- ----------- ---------- 13 Test 1 San Francisco user 14 test 2 San Francisco user 15 test 3 San Francisco user 16 test 4 San Francisco user 17 test 5 San Francisco UPDATE New code:
create or search search_result REPLACE ("@ search_text" character different, complete "@row_start" Nk, "@row_end" integer) SETOF search_type is $ body returns as $ declared R search_type% rowtype; As a result, "user_id" as "user_id" in the form of "user_id" as "user_firstname", "user_firstname", "user_firstname", "result_name", "user_loc" result_loc, result_pic as 'user_picurl', 'user' As is the result_type users_list where concat ("USER_FIRSTNAME", "',' User_lastname ') by concat (" @ search_text ",'% ') commands, like CONCAT (" USER_FIRSTNAME ","', 'User_lastname'), ASC limit " @row_end "Offset" @row_start "Loop Returns Next R; End loop; Result_id as "result_id", "result_id", "result_id", and result_loc as "Community_location" as result_id, "Community_name", result_pic as "Community_img_url", result_type community_list as 'community' where "contact" ("@ Search_text ", '%') and" type "= 'created by' order '' community_name" asc limit "@ OR_and" offset "@OO_STAT" next return of loop; end loop; return; end $ body $ language plpgsql process as I am called:
choose * search_result ('t', 3,0) to But no value Return
You should:
SELECT * to search_result (' C '); Not only:
select search_result (' c '); You want a table result SELECT Returns set-returning function called in Tulips.
Comments
Post a Comment