JFIF$        dd7 

Viewing File: /usr/share/doc/firebird/sql.extensions/README.context_variables

------------------------
System context variables
------------------------


CURRENT_CONNECTION / CURRENT_TRANSACTION (FB 1.5)
-------------------------------------------------

  Function:
    Returns system identifier of the active connection/transaction,
    i.e. a connection/transaction, in which context the given SQL
    statement is executed.

  Author:
    Dmitry Yemanov <dimitr@firebirdsql.org>

  Syntax rules:
    CURRENT_CONNECTION / CURRENT_TRANSACTION

  Type:
    INTEGER

  Scope:
    DSQL, PSQL

  Example(s):
    1. SELECT CURRENT_CONNECTION FROM RDB$DATABASE;
    2. NEW.CONN_ID = CURRENT_TRANSACTION;
    3. EXECUTE PROCEDURE P_LOGIN(CURRENT_CONNECTION);

  Note(s):
    These values are stored on the database header page,
    so they will be reset after a database restore.


ROW_COUNT (FB 1.5)
------------------

  Function:
    Returns number of rows, affected by the last SQL statement.

  Author:
    Dmitry Yemanov <dimitr@firebirdsql.org>

  Syntax rules:
    ROW_COUNT

  Type:
    INTEGER

  Scope:
    PSQL, context of the given procedure/trigger.

  Example(s):
    UPDATE TABLE1 SET FIELD1 = 0 WHERE ID = :ID;
    IF (ROW_COUNT = 0) THEN
      INSERT INTO TABLE1 (ID, FIELD1) VALUES (:ID, 0);

  Note(s):
    1. It can be used to check whether a SELECT statement returned
       any rows or not. Also it can be used to exit a fetch loop
       on an explicit PSQL cursor.
    2. ROW_COUNT contains zero after EXECUTE STATEMENT call. That's
       a design limitation, because dynamic SQL statements are
       executed as nested requests (i.e. in another context).

  See also:
    README.cursors


SQLCODE / GDSCODE (FB 1.5)
--------------------------

  Function:
    Returns numeric error code for the active exception.

  Author:
    Dmitry Yemanov <dimitr@firebirdsql.org>

  Syntax rules:
    SQLCODE / GDSCODE

  Type:
    INTEGER

  Scope:
    PSQL, context of the exception handling block.

  Example(s):
    BEGIN
      ...
    WHEN SQLCODE -802 DO
      EXCEPTION E_EXCEPTION_1;
    WHEN SQLCODE -803 DO
      EXCEPTION E_EXCEPTION_2;
    WHEN ANY DO
      EXECUTE PROCEDURE P_ANY_EXCEPTION(SQLCODE);
    END

  Note(s):
    1. GDSCODE variable returns a numeric representation of the
       appropriate Firebird error code.
    2. Both SQLCODE and GDSCODE always evaluate to zero outside
       the exception handling block.
    3. If you catch exceptions with 'WHEN SQLCODE' block, then only
       SQLCODE variable contains the error code inside this block,
       whilst GDSCODE contains zero. Obviously, this situation is
       opposite for 'WHEN GDSCODE' block.
    4. For 'WHEN ANY' block, the error code is set in SQLCODE
       variable only.
    5. If user-defined exception is thrown, both SQLCODE and GDSCODE
       variables contain zero, regardless of the exception handling
       block type.


INSERTING / UPDATING / DELETING (FB 1.5)
----------------------------------------

  Function:
    Determines type of row operation being executed.

  Author:
    Dmitry Yemanov <dimitr@firebirdsql.org>

  Syntax rules:
    INSERTING / UPDATING / DELETING

  Type:
    BOOLEAN (emulated via pseudo-expression in FB 1.5)

  Scope:
    PSQL, triggers only.

  Example(s):
    IF (INSERTING OR DELETING) THEN
      NEW.ID = GEN_ID(G_GENERATOR_1, 1);

  See also:
    README.universal_triggers

    
SQLSTATE (FB 2.5)
-----------------

  Function:
    Returns character-encoded state for the active exception.

  Author:
    Dmitry Yemanov <dimitr@firebirdsql.org>

  Syntax rules:
    SQLSTATE

  Type:
    CHAR(5) CHARACTER SET ASCII

  Scope:
    PSQL, context of the exception handling block.

  Example(s):
    BEGIN
      ...
    WHEN SQLSTATE '44000' DO
      EXCEPTION E_CHECK_VIOLATION;
    WHEN ANY DO
      EXECUTE PROCEDURE P_ANY_EXCEPTION(SQLSTATE);
    END

  Note(s):
    1. SQLSTATE always evaluates to NULL outside the exception handling block.


RDB$ERROR (FB 4.0)
------------------

  Function:
    Returns specific context of the active exception.

  Author:
    Dmitry Yemanov <dimitr@firebirdsql.org>

  Syntax rules:
    RDB$ERROR ( context )
    context ::= { GDSCODE | SQLCODE | SQLSTATE | EXCEPTION | MESSAGE }

	GDSCODE, SQLCODE, SQLSTATE - see above

	EXCEPTION : VARCHAR(63) CHARACTER SET UTF8 
	  Returns name of the active user-defined exception
	  or NULL if active exception is a system one

	MESSAGE : VARCHAR(1024) CHARACTER SET UTF8
	  Returns interpreted text for the active exception

  Type:
    Depends on context

  Scope:
    PSQL, context of the exception handling block.

  Example(s):
    BEGIN
      ...
    WHEN ANY DO
      EXECUTE PROCEDURE P_LOG_EXCEPTION(RDB$ERROR(MESSAGE));
    END

  Note(s):
    RDB$ERROR always contains NULL outside the exception handling block.
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg!%5MmZ/c-{1_Je"|^$'O&ޱմTrb$w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