« first day (2032 days earlier)      last day (626 days later) » 

9:05 AM
@TehShrike Oh got it now. Thanks :)
 
9:19 AM
@TehShrike Think I did connect to my pgsql with that user (su postgres)
hi there :P
I'd like to make a function from a "complicated" query
this query gets data from some tables and returns a set of "custom" records
looked on the internet for examples but didn't find anything concrete / useful yet
here is a "shortened" example of my query :
SELECT
	e_contact.entity AS ent,
	e_contact.entity_type AS type,
	contact.value AS contact,
	contact.type AS type,
	CASE
		WHEN e_contact.entity_type = 1 THEN concat_ws(' ',person.name,person.first_name)
		WHEN e_contact.entity_type = 2 THEN "user".login
	END AS name,
	CASE
		WHEN e_contact.entity_type = 1 THEN person.id
		WHEN e_contact.entity_type = 2 THEN "user".id
	END AS id
FROM e_contact
INNER JOIN entity_type ON e_contact.entity_type = entity_type.id
INNER JOIN contact ON e_contact.contact = contact.id
basically this returns entity contact data for any entity, in different tables depending on "entity_type" value
I'd like to turn it into a function that would give me this data for "1 entity", giving these arguments : (entity_type_value, entity_id_value)
So, in my function body, I would replace e_contact.entity_type value (1 or 2 in example) with my argument "entity_type_value", and add a where clause with "e_contact.entity" = my second argument. The most difficult thing for me is the syntax and "building" of the function
thanks for reading/help
 
10:00 AM
Here is where I am actually :
CREATE OR REPLACE FUNCTION getEntityContacts(entity_id_identifier int, entity_type_identifier int)
	RETURNS SETOF RECORD AS
	$func$
		BEGIN
			RETURN QUERY
				SELECT
					e_contact.entity AS ent,
					e_contact.entity_type AS type,
					contact.value AS contact,
					contact.type AS type,
					CASE
						WHEN e_contact.entity_type = 1 THEN concat_ws(' ',person.name,person.first_name)
						WHEN e_contact.entity_type = 2 THEN "user".login
					END AS name,
					CASE
						WHEN e_contact.entity_type = 1 THEN person.id
call to the function returns 0A000 -> feature_not_supported
 
10:53 AM
what is the differnce between writing store procedure in .sql file and writing store procedure in .sf file???
*** .sp
 
 
6 hours later…
4:40 PM
@Julo0sS What database engine are you using? MySQL? Postgresql?
@MohanRaj Nothing that I can imagine
 

« first day (2032 days earlier)      last day (626 days later) »