Hi
I have just started programming in dotLRN. And I have encountred the following errors in the database creation script. I would appreciate a lot if some one can take out time and help me.
The errors are -
1. Function inline_0() does not exist.
HINT: No function matches the given name and argument types. You may need to add explicit type casts
2. LINE 182: Syntax error at or near 'room'
I am also attaching the code..
Thanks
Ashem
------------
-- chat-auth-create.sql
-- Create privileges for the chat rooms
select acs_privilege__create_privilege('room_create', 'Create a chat room', null);
select acs_privilege__create_privilege('room_modify', 'Modify a chat room', null);
select acs_privilege__create_privilege('room_delete', 'Delete a chat room', null);
select acs_privilege__create_privilege('room_view', 'View chat room details', null);
-- Create privileges dealing with users
select acs_privilege__create_privilege('chat_user', 'Normal chat user', null);
select acs_privilege__create_privilege('user_grant', 'Add user to a chat room', null);
select acs_privilege__create_privilege('user_revoke', 'Delete user from a chat room', null);
select acs_privilege__create_privilege('user_ban', 'Ban user from accessing a chat room', null);
select acs_privilege__create_privilege('user_unban', 'Unban user to access a chat room', null);
-- Create read/write privileges
select acs_privilege__create_privilege('message_read', 'Can read chat message', null);
select acs_privilege__create_privilege('message_write', 'Can write chat message', null);
-- Create privileges dealing with moderators/professors, etc.
select acs_privilege__create_privilege('room_moderator', 'Chat room moderator', null);
select acs_privilege__create_privilege('room_moderate', 'Moderate a chat room', null);
select acs_privilege__create_privilege('moderator_grant', 'Add moderator to a chat room', null);
select acs_privilege__create_privilege('moderator_revoke', 'Delete moderator from a chat room', null);
-- Create privileges dealing with administrator
select acs_privilege__create_privilege('room_admin', 'God for chat', null);
-- Provide privileges to normal chat users
select acs_privilege__add_child('chat_user', 'message_read');
select acs_privilege__add_child('chat_user', 'message_write');
-- Provide privileges to moderators/professors, etc
select acs_privilege__add_child('room_moderator', 'chat_user');
select acs_privilege__add_child('room_moderator', 'room_moderate');
select acs_privilege__add_child('room_moderator', 'user_ban');
select acs_privilege__add_child('room_moderator', 'user_unban');
-- Provide privileges to chat room administrator/site wide administrator
select acs_privilege__add_child('room_admin', 'room_create');
select acs_privilege__add_child('room_admin', 'room_modify');
select acs_privilege__add_child('room_admin', 'room_delete');
select acs_privilege__add_child('room_admin', 'room_view');
select acs_privilege__add_child('room_admin', 'user_grant');
select acs_privilege__add_child('room_admin', 'user_revoke');
select acs_privilege__add_child('room_admin', 'room_moderator');
select acs_privilege__add_child('room_admin', 'moderator_grant');
select acs_privilege__add_child('room_admin', 'moderator_revoke');
select acs_privilege__add_child('admin', 'room_admin');
-- Create a room object
create function inline_0()
returns integer as '
declare
attr_id acs_attributes.attribute_id%TYPE;
begin
PERFORM
acs_object_type__create_type (
'room', -- object_type
'acs_object', -- supertype
'Chat Room', -- pretty_name
'Chat Rooms', -- pretty_plural
'chat_rooms', -- table_name
'room_id', -- id_column
'null' -- name_method
);
-- Create attributes for object room
-- Attribute: pretty name
attr_id := acs_attribute__create_attribute (
'room', -- object_type
'pretty_name', -- attribute_name
'string', -- datatype
'Room Name', -- pretty_name
'Room Names' -- pretty_plural
);
-- Attribute: detail
attr_id := acs_attribute__create_attribute (
'room', -- object_type
'detail', -- attribute_name
'string', -- datatype
'Detail', -- pretty_name
'Details' -- pretty_plural
);
-- Attribute: moderated
attr_id := acs_attribute_create_attribute (
'room', -- object_type
'moderated_p', -- attribute_name
'boolean', -- datatype
'Moderated', -- pretty_name
'Moderated' -- pretty_plural
);
-- Attribute: active
attr_id := acs_attribute_create_attribute (
'room', -- object_type
'active_p', -- attribute_name
'boolean', -- datatype
'Activated', -- pretty_name
'Activated' -- pretty_plural
);
return 0;
end;'
language 'plpgsql';
select inline_0();
drop function inline_0();
-- Create table chat rooms
create table chat_rooms (
-- Each room has an unique id
room_id integer
constraint chat_rooms_room_id_pk primary key
constraint chat_rooms_room_id_fk
references acs_objects(object_id),
-- Pretty name of a room
pretty_name varchar(50)
constraint chat_rooms_pretty_name_nn not null,
-- Room description
detail varchar(150),
-- Whether the room is moderated, default is false
moderated_p boolean
default 'f'
constraint chat_rooms_moderated_p_ck check
(moderated_p in ('t', 'f')),
-- Whether the room is active, default is true
active_p boolean
default 't'
constraint chat_rooms_active_p_ck check
(active_p in ('t', 'f'))
);
-- Function room add
create function room__new (integer, varchar, varchar, boolean, boolean, integer, timestamptz, integer, varchar, varchar)
returns integer as '
declare
p_room_id alias for $1;
p_pretty_name alias for $2;
p_detail alias for $3;
p_modertated_p alias for $4;
p_active_p alias for $5;
p_context_id alias for $6;
p_creation_date alias for $7;
p_creation_user alias for $8;
p_creation_ip alias for $9;
p_object_type alias for $10;
v_room_id chat_rooms.room_id%TYPE;
begin
v_room_id := acs_object__new (
null,
'room',
now(),
p_context_id,
p_creation_user,
p_creation_ip
);
insert into chat_rooms (room_id, pretty_name, detail, moderated_p, active_p)
values (v_room_id, p_pretty_name, p_detail, p_moderated_p, p_active_p);
return v_room_id;
end;'
language 'plpgsql';
-- Function room name
create function room__name (integer)
returns varchar as '
declare
p_room_id alias for $1;
v_pretty_name chat_rooms.pretty_name%TYPE;
begin
select into v_pretty_name pretty_name from chat_rooms where room_id = p_room_id;
return v_pretty_name;
end;'
language 'plpgsql';
-- Function room modify
create function room__modify (integer, varchar, varchar, boolean, boolean)
returns integer as '
declare
p_room_id alias for $1;
p_pretty_name alias for $2;
p_detail alias for $3;
p_moderated_p alias for $4;
p_active_p alias for $5;
begin
update chat_rooms set
pretty_name = p_pretty_name,
detail = p_detail,
moderated_p = p_moderated_p,
active_p = p_active_p
where
room_id = p_room_id;
return 0;
end;'
language 'plpgsql';
-- Function room remove
create function room__remove (integer)
returns integer as '
declare
p_room_id alias for $1;
begin
delete from chat_rooms where room_id = p_room_id;
PERFORM acs_object__delete(p_room_id);
return 0;
end;'
language 'plpgsql';