Oracle 10g - Return value of a variable

Hello, everyone,

In Oracle 10g, how does one return the value of a variable that was declared/set within a query?

For example, consider the following:


DECLARE cnt INTEGER(1);
BEGIN
  SELECT 1 into cnt FROM SYS.DUAL WHERE EXISTS (a query that gets at least one record)
  IF cnt = 0
    THEN
        ... an insert query
    ELSE
        SET cnt = 1;
  END IF;
END;

How do I return the value of cnt?

V/r,

:slight_smile:

43 views, so far. No one knows the answer?

V/r,

:slight_smile:

none of us know oracle

sometimes, good sql knowledge can answer a question in any platform

this is not one of those times

Just my luck to be working a contract that requires Oracle. :confused: (I’ve been a MS SQL guy since 2000.)

Still… I figured a forum as popular as SitePoint would have a few Oracle gurus.

V/r,

:slight_smile: