Error Codes Listing - Firebird

We lists the internally defined exceptions, including SQLCODEs, GDSCODEs, the symbols for the GDSCODEs, and the English-language messages current at the release of Firebird 1.5.0.

When a Firebird binary is built, the English-language messages are extracted from an internal database. The SQLCODEs are stored, but the GDSCODEs are calculated on the fly. The file firebird.msg, in your Firebird root directory, is built as a binary tree that the client and the server refer to when the server is running.

Rolling Your Own Error Code List

For the curious, a gbak version of the database (named msg.gbak) can be easily downloaded from the Firebird CVS browser. firebird and follow the “CVS Browser” links until you get to the branch named. /firebird / firebird2 /src /msgs/. At the bottom of the display, click the drop-down list box to find the branch you are interested in. You can download the file from there.

The following stored procedure generated the list in Appendix X. It outputs the list to an external table, but you can modify the procedure to suit yourself.

SET TERM ^;
/* The output file */
CREATE TABLE ERRORCODES
EXTERNAL FILE
'C:Program FilesFirebirdFirebird_1_5MyData2794app10.txt'
(ListItem CHAR(169))^
COMMIT ^
/* If needed, uncomment the section below and declare the ASCII_CHAR() function
to get us a carriage return and line feed */
/* DECLARE EXTERNAL FUNCTION ascii_char
INTEGER
RETURNS CSTRING(1) FREE_IT
ENTRY_POINT 'IB_UDF_ascii_char' MODULE_NAME 'ib_udf'^
COMMIT ^
*/
/* Finally, the SP that created the textfile that became Appendix X */
CREATE PROCEDURE OUTPUT_ERRCODES
AS
DECLARE VARIABLE SQC SMALLINT;
DECLARE VARIABLE NUM SMALLINT;
DECLARE VARIABLE FAC SMALLINT;
DECLARE VARIABLE SYM VARCHAR(32);
DECLARE VARIABLE TXT VARCHAR(118);
DECLARE VARIABLE GDC CHAR(9) CHARACTER SET OCTETS;
DECLARE VARIABLE BASE0 INTEGER = 335544320;
DECLARE VARIABLE CALCNUM INTEGER;
DECLARE VARIABLE EOL CHAR(2);
BEGIN
EOL = ASCII_CHAR(13)||ASCII_CHAR(10); /* end-of-line sequence */
FOR SELECT
S.SQL_CODE,
S.NUMBER,
S.FAC_CODE,
S.GDS_SYMBOL,
M.TEXT
FROM SYSTEM_ERRORS S
JOIN MESSAGES M
ON
M.FAC_CODE = S.FAC_CODE
AND M.NUMBER = S.NUMBER
AND M.SYMBOL = S.GDS_SYMBOL
/* Eliminate some unwanted/unused codes */
WHERE M.TEXT NOT CONTAINING 'journal'
AND M.TEXT NOT CONTAINING 'dump'
AND s.GDS_SYMBOL NOT CONTAINING 'license'
AND S.GDS_SYMBOL NOT CONTAINING 'wal_'
AND S.GDS_SYMBOL IS NOT NULL
AND S.SQL_CODE < 102
ORDER BY 1 DESC, 2
INTO :SQC, :NUM, :FAC, :SYM, :TXT
DO
BEGIN
/* The message texts are all in lower case, so we do a little
jiggery-pokery to uppercase the first letter. */
IF (TXT IS NULL) THEN
TXT = '{Message unknown}';
ELSE
TXT = UPPER(SUBSTRING(TXT FROM 1 FOR 1))||
SUBSTRING(TXT FROM 2);

/* Having worked out how the facility code (FAC_CODE) and NUMBER values are used to generate the GDSCODE numbers, it's very straightforward to serve them freshly-cooked from the latest SYSTEM_ERRORS and MESSAGES tables */ IF (FAC IS NOT NULL AND NUM IS NOT NULL) THEN /* We don't want any half-cooked errcodes! */

BEGIN
CALCNUM = BASE0 + (FAC * 65535);
CALCNUM = CALCNUM + NUM + FAC;
GDC = CAST(CALCNUM AS CHAR(9));
INSERT INTO ERRORCODES
VALUES(
/* all vars go into a single string */
:SQC||'|'||:GDC||'|'||:SYM||'|'||:TXT||:EOL) ;
END
END
END ^
COMMIT ^
EXECUTE PROCEDURE OUTPUT_ERRCODES ^
COMMIT ^
SET TERM ;^

/* The text file is now ready to go to the word processor for a little tidying, to get rid of all the white space created by the right-padding on the output string.A quick search and replace replaced all the '|' separators with ASCII 9 (tab) because that was the formatting required by the pre-press people for the tabulating. ASCII_CHAR(9) could have been called in the SP but it seemed more useful to avoid confusing tabs with all the unwanted white space at editing time.*/


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics