SQL$HELP72.HLB  —  DECLARE  MODULE  Example
    Example 1: Declaring a module specifying character strings of
    different character sets

    Assuming that the character sets for the database match the
    character sets specified in the program, the following example
    shows a simple SQL precompiled C program that retrieves one row
    from the COLOURS table.

    /* This SQL precompiled program does some simple tests of character length
    *  and character sets.
    */
    #include stdio
    #include descrip

    main()
    {

    /* Specify CHARACTER LENGTH CHARACTERS in the DECLARE MODULE statement.
    *  In addition, specify the NAMES, NATIONAL, and DEFAULT character sets.
    */
    EXEC SQL DECLARE MODULE CCC_COLOURS
             NAMES ARE DEC_KANJI
             NATIONAL CHARACTER SET KANJI
             SCHEMA RDB$SCHEMA
             AUTHORIZATION SQL_SAMPLE
             CHARACTER LENGTH CHARACTERS
             DEFAULT CHARACTER SET DEC_KANJI
             ALIAS RDB$DBHANDLE;

    /* If you do not specify character sets in the DECLARE ALIAS statement, SQL
    *  uses the character sets of the compile-time database.
    */
    EXEC SQL DECLARE ALIAS FILENAME MIA_CHAR_SET;

    int      SQLCODE;

    /* Because the default character set is DEC_KANJI, you do not need to qualify
    *  the variable dec_kanji_p with the character set, but you must declare
    *  char in lowercase.
    */
    char  dec_kanji_p[31];

    /* When you declare a parameter with lowercase char, SQL considers the
    *  character set unspecified and allocates single-octet characters.
    */
    char  english_p[31];

    /* When you specify the character set, SQL allocates single- or multi-octet
    *  characters, depending upon the character set.
    */
    char  CHARACTER SET DEC_MCS  french_p[31];
    char  CHARACTER SET KANJI    japanese_p[31];
       .
       .
       .

    /* Select one row from the COLOURS table. */
    EXEC SQL SELECT ENGLISH, FRENCH, JAPANESE, ROMAJI,
                    KATAKANA, HINDI, GREEK, ARABIC, RUSSIAN
             INTO :english_p, :french_p, :japanese_p, :dec_kanji_p,
                  :katakana_p, :devanagari_p, :isolatingreek_p,
                  :isolatinarabic_p, :isolatincyrillic_p
             FROM COLOURS LIMIT TO 1 ROW;

         if (SQLCODE != 0)
             SQL$SIGNAL();

    printf ("\nENGLISH: %s", english_p);
    printf ("\nFRENCH: %s", french_p);
    printf ("\nJAPANESE: %s", japanese_p);
    printf ("\nROMAJI: %s", dec_kanji_p);
    printf ("\nKATAKANA: %s", katakana_p);
    printf ("\nHINDI: %s", devanagari_p);
    printf ("\nGREEK: %s", isolatingreek_p);
    printf ("\nARABIC: %s", isolatinarabic_p);
    printf ("\nRUSSIAN: %s", isolatincyrillic_p);

    EXEC SQL   ROLLBACK;
    }
Close Help