Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9461E4763A5 for ; Wed, 14 Aug 2002 04:33:40 -0400 (EDT) Received: from ds9.quadratec-software.com (ds9.quadratec-software.com [62.23.102.82]) by postgresql.org (Postfix) with ESMTP id 9667E475B4F for ; Wed, 14 Aug 2002 04:33:39 -0400 (EDT) Received: from spade.orsay.quadratec.fr (deltaq.quadratec-software.com [62.23.102.66]) by ds9.quadratec-software.com (8.11.3/8.11.3) with ESMTP id g7E80ET19901 for ; Wed, 14 Aug 2002 10:00:14 +0200 Received: from hotshine (shintranet.orsay.quadratec.fr [172.16.200.100]) by spade.orsay.quadratec.fr (Switch-2.1.0/Switch-2.1.0) with SMTP id g7E8XdT01737 for ; Wed, 14 Aug 2002 10:33:39 +0200 (CEST) From: "philip johnson" To: Subject: pgsql-sql@postgresql.org Date: Wed, 14 Aug 2002 09:28:51 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 1 (Highest) X-MSMail-Priority: High X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: High X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/215 X-Sequence-Number: 9061 I've a stored procedure I'd like to migrate from MS SqlServer to Postgresql 7.2.1. How can I do ? here is the stored procedure CREATE PROCEDURE ws_doc_tree_new @parent_node_id int, @label varchar(50), @publication varchar(32) AS DECLARE @doc_exists int, @new_node_id int, @parent_doc_id int, @parent_node_path varchar(250), @parent_tree_level int /* check if label does not already exists */ SELECT @doc_exists = count(*) FROM ws_doc_tree WHERE ws_doc_tree.parent_node_id = @parent_node_id AND ws_doc_tree.label = @label IF (@doc_exists > 0) BEGIN RAISERROR ('Could not create child node, a folder with the same name already exists',16,1) RETURN 0 END SELECT @parent_node_path = ws_doc_tree.node_path + ws_doc_tree.label + '/', @parent_tree_level = ws_doc_tree.tree_level FROM ws_doc_tree WHERE ws_doc_tree.node_id = @parent_node_id BEGIN TRANSACTION SELECT @new_node_id = max(ws_doc_tree.node_id) + 1 FROM ws_doc_tree INSERT INTO ws_doc_tree (node_id, label, node_path, parent_node_id, tree_level, publication, creation_dt) VALUES (@new_node_id, @label, @parent_node_path, @parent_node_id, @parent_tree_level +1, @publication, current_timestamp) COMMIT TRANSACTION RETURN @new_node_id