ZdenekMach
Programmer
Sorry, but I am novice in postgreSQL so
I have created this function, but it desnt work.
It still tells me:
"ERROR: syntax error at or near "and"na znaku 630"
-- Function: eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar")
-- DROP FUNCTION eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar");
CREATE OR REPLACE FUNCTION eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar")
RETURNS eds_accountsdataset AS
$BODY$
declare
pom integer;
sWhere varchar;
command varchar;
accountdataset eds_accountsdataset;
begin
command :=
'select a."UserName" as UserName, a."FirstName" as FirstName,
a."LastName" as SurName, b."Status" as Status, a."UserNameMaker" as UserName_Maker,
b."UserNameMakerChecker" as UserName_MakerChecker
from "Users" a
inner join
(select c."UserName", c.lastchanged, d."UserNameMakerChecker",
d."Status" from (select "UserName", max("LastChanged") as lastchanged
from "UserStatus"
group by "UserName") c
inner join "UserStatus" d
on c.lastchanged = d."LastChanged" and c."UserName" = d."UserName") b
on a."UserName" = b."UserName" ';
command := command || eds_getaccountsdataset_where(mustbechecked, applicatestatus, applicatedifferentmaker, currentloggedusername, usernamemaker, status);
EXECUTE IMMEDIATE command into accountdataset ;
return accountdataset;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar") OWNER TO postgres;
I have created this function, but it desnt work.
It still tells me:
"ERROR: syntax error at or near "and"na znaku 630"
-- Function: eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar")
-- DROP FUNCTION eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar");
CREATE OR REPLACE FUNCTION eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar")
RETURNS eds_accountsdataset AS
$BODY$
declare
pom integer;
sWhere varchar;
command varchar;
accountdataset eds_accountsdataset;
begin
command :=
'select a."UserName" as UserName, a."FirstName" as FirstName,
a."LastName" as SurName, b."Status" as Status, a."UserNameMaker" as UserName_Maker,
b."UserNameMakerChecker" as UserName_MakerChecker
from "Users" a
inner join
(select c."UserName", c.lastchanged, d."UserNameMakerChecker",
d."Status" from (select "UserName", max("LastChanged") as lastchanged
from "UserStatus"
group by "UserName") c
inner join "UserStatus" d
on c.lastchanged = d."LastChanged" and c."UserName" = d."UserName") b
on a."UserName" = b."UserName" ';
command := command || eds_getaccountsdataset_where(mustbechecked, applicatestatus, applicatedifferentmaker, currentloggedusername, usernamemaker, status);
EXECUTE IMMEDIATE command into accountdataset ;
return accountdataset;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION eds_getaccountsdataset(mustbechecked bool, applicatestatus bool, applicatedifferentmaker bool, currentloggedusername "varchar", usernamemaker "varchar", status "varchar") OWNER TO postgres;