capture raise notice with java

How do I capture in java a raise notice message from a postgreSQL procedure?

Ex :
Say the following hypothetical body for an sql function :
       BEGIN
            SELECT * INTO aRecord FROM aTable WHERE NEW.attribute = attribute;
            IF NOT FOUND THEN
                  RAISE NOTICE ' Not found %', NEW.attribute;
                  RETURN NULL;
            ELSE
                  RETURN NEW;
            END IF;
      END;

And the following query attached to the above function with a trigger :
INSERT INTO anotherTable
VALUES ('attribute1', 'attribute2');

How do I capture that raise notice in java (to do a system.out.println for instance) when the query returns null because of the trigger associated to a function like the one above?
EmilieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
I don't believe you can sorry
0
Tomas Helgi JohannssonCommented:
        Hi!

Try using the SQLException in a try catch block around your code.
See the following examples
http://www.java2s.com/Code/Java/Database-SQL-JDBC/SQLException.htm

Hope this helps.

Regards,
    Tomas Helgi
0
objectsCommented:
RAISE NOTICE just logs afaik, don't believe an exception gets thrown
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tomas Helgi JohannssonCommented:
      Hi!

I belive that it could be controled through the CLIENT-MIN-MESSAGE config
 
http://www.postgresql.org/docs/8.3/interactive/plpgsql-errors-and-messages.html
http://www.postgresql.org/docs/8.3/interactive/runtime-config-logging.html#GUC-CLIENT-MIN-MESSAGES

Regards,
   Tomas Helgi
0
objectsCommented:
only EXCEPTION raises an error
"the other levels only generate messages of different priority levels"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tomas Helgi JohannssonCommented:
Hmmm, yes you are right.

I confused it with the SQL Warning/Notice handling. ;)

Here is an example on how to display warnings/notices from the db in the client
http://www.java2s.com/Code/Java/Database-SQL-JDBC/SQL-Warning.htm
http://www.java2s.com/Code/Java/Database-SQL-JDBC/GetSqlWarningStatementobject.htm

Regards,
    Tomas Helgi
0
EmilieAuthor Commented:
Thank you both!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.