Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136

    Unanswered: How to create a global variable?

    Hello!

    How can i create a global variable?

    E.g. G_Language :

    If G_Language = 1 Then
    ...
    ElsIf G_Language = 2 Then

    Thanks in advance!

  2. #2
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    Hi

    Try out this !

    CREATE OR REPLACE PACKAGE GlobalPkg
    AS
    SUBTYPE GLANGUAGE IS NUMBER(100);
    END;
    /

  3. #3
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Hello!

    Thanks, it works.

    But how can i declare G_LANGUAGE, in the same package?

    G_LANGUAGE = 1;

    doesn't work.


    (Later in my Software i'll have a function, that gets data from the INI-File, like:
    [General]
    Language=1
    /* User's configurations*/


    Thanks in advance,
    Julia
    Last edited by julla27; 04-02-04 at 07:13.

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    In PL/SQL, assignments are done using ":=" not "=".

    g_language := 1;

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    What is wrong?

    CREATE OR REPLACE PACKAGE PKG_GLOBAL
    AS
    SUBTYPE G_LANGUAGE IS NUMBER(10);
    END;
    CREATE OR REPLACE PACKAGE BODY PKG_GLOBAL
    AS
    SUBTYPE G_LANGUAGE
    BEGIN
    G_LANGUAGE := 1;
    END;
    END;
    /

    Thanks,
    Julia

  6. #6
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186
    you could have

    CREATE OR REPLACE PACKAGE PKG_GLOBAL
    AS
    G_LANGUAGE NUMBER(10) := 1;
    END;
    /

    and then refer to PKG_GLOBAL.G_LANGUAGE from anywhere

  7. #7
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    yes. It works

    Thanx

  8. #8
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Thanks to all - it works!

  9. #9
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Thanks to all - it works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •