X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0DA6E53AF9 for ; Thu, 31 Mar 2005 17:13:01 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81615-04 for ; Thu, 31 Mar 2005 16:12:59 +0000 (GMT) Received: from hub.org (hub.org [200.46.204.220]) by svr1.postgresql.org (Postfix) with ESMTP id 1083853AEE for ; Thu, 31 Mar 2005 17:12:59 +0100 (BST) Received: from localhost (unknown [200.46.204.144]) by hub.org (Postfix) with ESMTP id EC6BD129322 for ; Thu, 31 Mar 2005 12:12:58 -0400 (AST) Received: from hub.org ([200.46.204.220]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80260-09 for ; Thu, 31 Mar 2005 16:12:56 +0000 (GMT) Received: from ganymede.hub.org (blk-224-186-157.eastlink.ca [24.224.186.157]) by hub.org (Postfix) with ESMTP id EEC091291F2 for ; Thu, 31 Mar 2005 12:12:55 -0400 (AST) Received: by ganymede.hub.org (Postfix, from userid 1000) id 5D6BD343B8; Thu, 31 Mar 2005 12:12:52 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 5BE053425E for ; Thu, 31 Mar 2005 12:12:52 -0400 (AST) X-Return-Path: X-Received: from localhost ([unix socket]) by ganymede.hub.org (Cyrus v2.2.12) with LMTPA; Thu, 31 Mar 2005 05:26:42 -0400 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (localhost [127.0.0.1]) by ganymede.hub.org (Postfix) with ESMTP id 7299636DD1 for ; Thu, 31 Mar 2005 05:25:24 -0400 (AST) X-Received: from mail.postgresql.org [200.46.204.71] by localhost with IMAP (fetchmail-6.2.5) for scrappy@localhost (single-drop); Thu, 31 Mar 2005 05:25:24 -0400 (AST) X-Received: from svr1.postgresql.org ([unix socket]) by svr1.postgresql.org (Cyrus v2.2.12) with LMTPA; Thu, 31 Mar 2005 10:23:22 +0100 X-Sieve: CMU Sieve 2.2 X-Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3DA5453633 for ; Thu, 31 Mar 2005 10:23:22 +0100 (BST) X-Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61676-09 for ; Thu, 31 Mar 2005 09:23:15 +0000 (GMT) X-Received: from postgresql.org (svr1.postgresql.org [200.46.204.71]) by svr1.postgresql.org (Postfix) with ESMTP id 82ACE5331F for ; Thu, 31 Mar 2005 10:23:15 +0100 (BST) X-Original-To: pgsql-bugs-postgresql.org-owner@localhost.postgresql.org X-Delivered-To: pgsql-bugs-postgresql.org-owner@localhost.postgresql.org X-Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E211D52A39 for ; Thu, 31 Mar 2005 10:23:14 +0100 (BST) X-Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 64290-05 for ; Thu, 31 Mar 2005 09:23:08 +0000 (GMT) X-Received: from secf.com (209-128-104-244.BAYAREA.NET [209.128.104.244]) by svr1.postgresql.org (Postfix) with ESMTP id 73C5353800 for ; Thu, 31 Mar 2005 10:23:08 +0100 (BST) X-Received: from dinesh by secf.com (MDaemon.PRO.v7.2.2.R) with ESMTP id md50000561022.msg for ; Thu, 31 Mar 2005 01:23:42 -0800 Reply-To: From: "Dinesh Pandey" To: Subject: FW: Help Date: Thu, 31 Mar 2005 14:51:03 +0530 Organization: Second Foundation India P Ltd. MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00A3_01C53601.11C7A150" X-Priority: 1 (Highest) X-MSMail-Priority: High X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Thread-Index: AcU10hUWVCCiEJ4vSF6iZJhujyZUCAAAJ5MA Importance: High X-Authenticated-Sender: dpandey@secf.com X-MDRemoteIP: 220.227.32.11 X-Return-Path: dpandey@secf.com X-MDaemon-Deliver-To: pgsql-bugs-owner@postgresql.org X-MDAV-Processed: mail.secf.com, Thu, 31 Mar 2005 01:23:47 -0800 Message-Id: <20050331092308.73C5353800@svr1.postgresql.org> X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-DCC: : X-Spam-Pyzor: Reported 0 times. ReSent-Date: Thu, 31 Mar 2005 12:12:48 -0400 (AST) Resent-From: "Marc G. Fournier" Resent-To: pgsql-bugs@postgresql.org ReSent-Subject: FW: Help ReSent-Message-ID: <20050331121248.G18194@ganymede.hub.org> X-Virus-Scanned: by amavisd-new at hub.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.514 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_MESSAGE, UPPERCASE_25_50, X_MSMAIL_PRIORITY_HIGH, X_PRIORITY_HIGH X-Spam-Level: * X-Archive-Number: 200504/14 X-Sequence-Number: 11466 This is a multi-part message in MIME format. ------=_NextPart_000_00A3_01C53601.11C7A150 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit _____ From: Dinesh Pandey [mailto:dpandey@secf.com] Sent: Thursday, March 31, 2005 2:45 PM To: pgsql-bugs@postgresql.org Subject: Help Importance: High Hi, I have installed PostgreSQL 8.0.1 on Solaris 9. I am porting my database from Oracle 9i to PostgreSQL. I am using PL/pgSQL language. In Oracle we can get error message from "SQLERRM" keyword and inserting it into table. How can I get error message/code in PostgreSQL after an EXCEPTION or RAISE EXCEPTION occurs in EXCEPTION block?? Pls help me or send me some example. Thanks Dinesh Pandey CREATE OR REPLACE FUNCTION DOES_NODE_HAVE_RULE (IN_SENTRYID_ID IN NUMBER ,IN_NODE_ID IN NUMBER ,IN_DEVICEID IN NUMBER ,IN_ACTION IN VARCHAR2 ) RETURN BOOLEAN IS does NUMBER(2) := 0; mesg VARCHAR2(500) := 'Does rule exist failed for sentry: '||in_sentryid_id||', node: '||in_node_id||'.'; c_context VARCHAR2(50) := 'DOES NODE HAVE RULE'; c_program VARCHAR2(100) := 'RULE_CONTROL.DOES_NODE_HAVE_RULE'; v_sql VARCHAR2(1000); BEGIN v_sql := 'SELECT COUNT(*) FROM PORTAL_'||in_action||'_NODE_RULE WHERE sentryid_id = '||in_sentryid_id|| ' AND node_id = '||in_node_id||' AND device_id ='||in_deviceid; EXECUTE IMMEDIATE v_sql INTO does; IF does > 0 THEN RETURN TRUE; ELSIF does = 0 THEN RETURN FALSE; END IF; EXCEPTION WHEN OTHERS THEN DATAMAN.log_error(c_program, c_context, 1, 'PACKAGE', 'OTHERS: '||mesg, SQLERRM); RAISE_APPLICATION_ERROR(-20000,SUBSTR(SQLERRM,1,250)); END does_node_have_rule; / SHOW ERROR ------=_NextPart_000_00A3_01C53601.11C7A150 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
 


From: Dinesh Pandey = [mailto:dpandey@secf.com]=20
Sent: Thursday, March 31, 2005 2:45 PM
To:=20 pgsql-bugs@postgresql.org
Subject: Help
Importance:=20 High

Hi,
 
I = have installed=20 PostgreSQL 8.0.1 on Solaris 9.
 
I am = porting my=20 database from Oracle 9i to PostgreSQL. I am using PL/pgSQL=20 language.
 
In = Oracle we can=20 get error message from "SQLERRM" keyword and inserting it into = table.=20
 
How = can I get=20 error message/code in PostgreSQL after an EXCEPTION or RAISE = EXCEPTION=20 occurs in EXCEPTION block??
 
Pls = help me or=20 send me some example.
 
 
Thanks
Dinesh=20 Pandey 
 
 
 
CREATE OR REPLACE = FUNCTION=20 DOES_NODE_HAVE_RULE
 (IN_SENTRYID_ID IN = NUMBER
 ,IN_NODE_ID IN=20 NUMBER
 ,IN_DEVICEID IN NUMBER
 ,IN_ACTION IN=20 VARCHAR2
 )
 RETURN=20 BOOLEAN
 IS
 

     =20 does       =20  NUMBER(2)       :=3D=20 0;
      = mesg   VARCHAR2(500) :=3D=20 'Does rule exist failed for sentry: '||in_sentryid_id||', node:=20 '||in_node_id||'.';
     =20 c_context     VARCHAR2(50)  :=3D 'DOES NODE = HAVE=20 RULE';
      c_program   =20  VARCHAR2(100)   :=3D=20 'RULE_CONTROL.DOES_NODE_HAVE_RULE';
  =20 v_sql   VARCHAR2(1000);
BEGIN
 
      v_sql :=3D 'SELECT COUNT(*) FROM=20 PORTAL_'||in_action||'_NODE_RULE WHERE sentryid_id =3D=20 '||in_sentryid_id||
     =20       ' AND node_id =3D '||in_node_id||' AND = device_id=20 =3D'||in_deviceid;
 
   EXECUTE IMMEDIATE v_sql INTO does;
  =20
      IF does > 0=20 THEN
         RETURN=20 TRUE;
      ELSIF does =3D 0 = THEN
  =20     RETURN FALSE;
      END = IF;
 
   EXCEPTION
      WHEN = OTHERS=20 THEN
        =20 DATAMAN.log_error(c_program, c_context, 1, 'PACKAGE', 'OTHERS:  = '||mesg,=20 SQLERRM
);
    &nbs= p;   =20 RAISE_APPLICATION_ERROR(-20000,SUBSTR(SQLERRM
,1,250));
 
   END does_node_have_rule;
/
SHOW=20 ERROR 
 
------=_NextPart_000_00A3_01C53601.11C7A150--