I have been trying to figure out how to run a pg store procedure
from a tcl file with no success. I have tried to copy the way the
news pakcage does it but it did not work neither.
I have this stored procedure which works fine when called from
postgres' shell
create function news__unido_document_object ( timestamp, integer,
timestamp, integer,varchar, varchar, bool, integer, timestamp,
integer, timestamp)
returns integer as '
declare
new__publish_date alias for $1; -- default now()
new__document_id alias for $2; -- default null
new__creation_date alias for $3; -- default now()
new__creation_user alias for $4; -- default null
.....
begin
v_document_id := acs_object__new(
new__document_id,
''unido_document'',
new__creation_date,
new__creation_user,
new__creation_ip,
new__contex_id
);
insert into unido_documents (
document_id, parent_document_id, author, expiry_date,
relevant_from_date, relevant_to_date, cleared_for_public_p,
document_type
) values (
v_document_id, new__parent_id, new__creation_user,
new__expiry_date, new__publish_date, new__relevant_to_date,
new__cleared_public_p, new__document_type
);
return v_document_id;
end;' language 'plpgsql';
--------------------------
I have the -postgres.xql file that looks like this
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1</version></rdbms>
<fullquery name="doc_insert">
<querytext>
select news__unido_document_object (
:publish_date_ansi,
null,
:publish_date_ansi,
:approval_user,
:approval_ip,
'tm',
'Yes',
null,
:archive_date_ansi,
:package_id, null
);
</querytext>
</fullquery>
</queryset>
---------------------------------------
and then I have tryed calling from tcl this procedure in this ways
but none works
db_exec_plsql doc_insert (
begin
news.unido_document_object (
new__publish_date => :publish_date_ansi,
new__document_id => :null,
new__creation_date => :publish_date_ansi,
new__creation_user => :approval_user,
new__creation_ip => :approval_ip,
new__document_type => :'tm',
new__cleared_public_p => :'Yes',
new__parent_id => :null ,
new__expiry_date => :archive_date_ansi ,
new__contex_id => :package_id ,
new__relevant_to_date => :null
);
end;
)
and
set new_id [db_exec_plsql doc_insert "
begin
:news.unido_document_object (
new__publish_date => :publish_date_ansi,
new__document_id => :null,
new__creation_date => :publish_date_ansi,
new__creation_user => :approval_user,
new__creation_ip => :approval_ip,
new__document_type => :'tm',
new__cleared_public_p => :'Yes',
new__parent_id => :null ,
new__expiry_date => :archive_date_ansi ,
new__contex_id => :package_id ,
new__relevant_to_date => :null
);
end;
"]
Could anybody tell me what am I doing wrong? What am I missing? or
Where can I learn How to run a postgres store procedure
from a tcl file?
Thanks in advance,