Forum OpenACS Q&A: Re: Insert Performance Issues - PG 7.2.3/OpenACS 4.5/perl/dbi

In an attempt to take the advice of Randy, I am trying to ween myself off of the motherly love of acs_object.  There were some things that were extremely nice about acs_object that I'm trying to replicate, most importantly creating an auto incrementing index for a table and being able to return that index for a new function.

I've created a table:

create table test2 (
  i        serial,
  txt      varchar(20)
);

I'm trying to build a new function, "test2__new" which will insert a new string into the table and automatically give it a new i value.

I have:

create function test__new (varchar)
return integer as '
declare
  new__text    alias for $1;
begin
  select test2_i_seq.nextval
  into v_index_id;

insert into test2
  (i, txt)
values
  (v_index_id, new__text);

return v_index_id;
end; ' language 'plpgsql';

---

Whenever I try to load this new function, it always gives me "parse erorr at or near "return"".  I am not sure what I'm missing.

Also, I'm trying to find some code that exports an SQL query to Excel/CSV via the OpenACS interface.  I did some searching and found that it is supposed to be a feature of the simple-survey module of dotLRN.  After downloading dotLRN 1.0, I haven't really been able to isolate it.  Can anyone suggest where I might be able to find this type of functionality?

Thanks.

John