Referencing Package Variables

Running Forms 6i and Oracle 8.1.6
Can you reference server side package variables directly from Forms, or do you still have to write a wrapper procedures to "set" and "get" them.
CREATE OR REPLACE package test_pkg as
v_pkgvar varchar2(10) := 'TEST';
TYPE r_emp_rec IS RECORD
(empno emp.empno%TYPE,
     ename emp.ename%TYPE,
     mgr emp.mgr%TYPE,
     deptno emp.deptno%TYPE,
     dname dept.dname%TYPE,
     loc dept.loc%TYPE
TYPE t_emp_rec IS TABLE OF r_emp_rec INDEX BY BINARY_INTEGER;
end;
DECLARE
data_blk test_pkg.t_emp_rec;
v_test varchar2(100) := test_pkg.v_pkg_var;
BEGIN
null;
END;
It seems funny that i can reference test_pkg.t_emp_rec;
but not test_pkg.v_pkg_var;
Thanks for your help

You have to use wrapper setters and getters to reference package variables on Server side PL/SQL from client side PL/SQL (Forms) this will not change no matter what the versions concerned

Similar Messages

  • Referencing package public variables remotely

    According to Oracle 8i documentation, its not possible to reference - directly or indirectly - package global public variables remotely. This implies the construct <package_name>.<public_variable_name>@<remote_database> doesn't work. The only way possible is to create public functions in the remote package to return the value of the variable. (e.g. function return_variable return <public_variable_name>%type is begin return <public_variable_name>; end;)
    Can anyone please confirm this, otherwise suggest any other simpler way of accessing remote package variables?
    Thanks.

    Rahul,
    No unfortunately you can't get at them, nor can you get any constants. It sure would be a good thing if you could, but I use the following to get around this problem as getting global variables and constants is a very important thing. This method I've shown below actually works pretty slick and it uses a remote function and a view to get the job done.
    I actually like how this works better than calling a variable/constant directly. The example below I just did up, but it shows the basic idea. Basically you put a number beside your var/const as a comment marker. I usually use a sequence to keep track of the numbers I've assigned. A test package was made that has 1 variable and 1 constant. A function is made that gets these values. A view is made that calls this function and returns ALL of the variable and constant values. You can take this even further and have it return the actual variable/constant name itself as well.
    I like doing it this way as you now only have ONE entry point (the view) to get as many variables/constants as you like, even if spread across multiple packages. I have my own code that does all of this, but the example below gives you an idea of how to make one yourself. Remember this is just a simple example, you can make it so you don't have to do the union in the view, and you can make the function return more things if you like, but I'm kinda short on time so my example is pretty simple, but it works quite well.
    The following is from the Oracle docs telling you about trying to get remote values ...
    --[START]
    http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a88876/adg10pck.htm#2501
    Remote Procedure Calls and Parameter Values
    You must explicitly pass values to all remote procedure parameters, even if there are defaults. You cannot access remote package variables and constants.
    --[END]
    Ok here's the code and some output ...
    --[START]
    CREATE OR REPLACE PACKAGE PKG_TEST
    AS
    --[NOTE] : see the comment number markers below, these stay fixed even though they are just comments
    GI_VAR_ONE NUMBER := -100; --[1]
    GI_CONST_ONE CONSTANT NUMBER := -200; --[2]
    END;
    Package created.
    CREATE OR REPLACE FUNCTION FN_TEST(VAR_POSITION NUMBER)
    RETURN NUMBER
    AS
    LI_RETURN NUMBER := 0;
    BEGIN
    IF VAR_POSITION = 1 THEN
    LI_RETURN := PKG_TEST.GI_VAR_ONE;
    ELSIF VAR_POSITION = 2 THEN
    LI_RETURN := PKG_TEST.GI_CONST_ONE;
    END IF;
    RETURN LI_RETURN;
    END;
    Function created.
    CREATE OR REPLACE VIEW V_TEST
    VAR_POSITION,
    VAR_VALUE
    AS
    SELECT 1,FN_TEST(1) FROM DUAL
    UNION
    SELECT 2,FN_TEST(2) FROM DUAL;
    View created.
    SELECT * FROM V_TEST;
    VAR_POSITION VAR_VALUE
    1 -100
    2 -200
    begin
    PKG_TEST.GI_VAR_ONE := -123;
    end;
    PL/SQL procedure successfully completed.
    Commit complete.
    select * from v_test;
    VAR_POSITION VAR_VALUE
    1 -123
    2 -200
    --[END]
    Enjoy :)
    Tyler D.

  • Globals vs package variables

    We want to get rid of the Globals we currently use in forms. Thought of creating a package with package variables and setting these from the form. We do not really want to have to create a set and get function for each variable we create.
    I wanted to be able to pass the variable name to a function to set it or get it. This would be ok using a library in forms and using the COPY and NAME_IN built ins but we want to use a pl/sql package and these are not supported there .
    Any suggestions please.

    If you want an abstractable variable mechanism then you can do something like:
    1) Create a Record type which has two columns - key and value
    2) Create a PL/SQL Table of records of this type
    3) Write routines to get and put into this table based on the Key value.
    So you have a single array of global values which can be referenced using string keys (which of course can themselves be variables or constructed at runtime)

  • How to get values from a stored package variable of type record ?

    Sir,
    In my JClient form, I need to get values from a database stored package variable of type record. And the values are retained in the JClient form for the whole session. The values are copied only once when the form is started.
    What is the best way to do that ?
    Thanks
    Stephen

    Stephen,
    not sure what your model is, but if it is Business Components, I think I would expose the properties as a client method on the application module. This way all JClient panels and frames will have access to it. You could use a HashMap to store the data in teh app module.
    If JDBC supports the record type, then you should be able to call it via a prepared SQL statement. If not, you may consider writing a PLSQL accessor to your stored procedure that returns something that can be handled.
    Steve Muench provides the following examples on his blog page
    http://otn.oracle.com/products/jdev/tips/muench/stprocnondbblock/PassUserEnteredValuesToStoredProc.zip
    http://otn.oracle.com/products/jdev/tips/muench/multilevelstproc/MultilevelStoredProcExample.zip
    Frank

  • Error trying to run SSIS Package via SQL Server Agent: DTExec: Could not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object

    Situation:
    SSIS Package designed in SQL Server 2012 - SQL Server Data Tools
    Windows 7 - 64 bit.
    The package (32 bit) extracts data from a SQL Server db to an Excel Output file, via an OLE DB connection.
    It uses 3 package variables:
    *) SQLCommand (String) to specify the SQL Statement to be executed by the package
    Property path: \Package.Variables[User::ExcelOutputFile].Properties[Value]
    Value: f:\Output Data.xls
    *) EXCELOutputFIle (String) to specify path and filename of the Excel output file
    Property path: \Package.Variables[User::SQLCommand].Properties[Value]
    Value: select * from CartOrder
    *) VarObjectDataSet (Object) to hold the data returned by SQL Server)
    Property path: \Package.Variables[User::VarObjectDataSet].Properties[Value]
    Value: System.Object
    It consists out of 2 components:
    *) Execute SQL Task: executes the SQL Statement passed on via a package variable. The resultng rows are stored in the package variable VarObjectDataSet
    *) Script Task: creates the physical output file and iterates VarObjectDataSet to populate the Excel file.
    Outcome and issue:The package runs perfectly fine both in SQL Server Data Tools itself and in DTEXECUI.
    However, whenever I run it via SQL Server Agent (with 32 bit runtime option set), it returns the errror message below.
    This package contains 3 package variables but the error stating that a package variable can not be set, pops up for the VarObjectDataSet only.  This makes me wonder if it is uberhaupt possible to set the value of a package variable
    of type Object.
    Can anybody help me on this please ?
    Message
    Executed as user: NT Service\SQLSERVERAGENT. Microsoft (R) SQL Server Execute Package Utility  Version 11.0.2100.60 for 32-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  6:40:20 PM  DTExec: Could
    not set \Package.Variables[User::VarObjectDataSet].Properties[Value] value to System.Object.  Started:  6:40:20 PM  Finished: 6:40:21 PM  Elapsed:  0.281 seconds.  The package execution failed.  The step failed.
    Thank you very much in advance
    Jurgen

    Hi Visakh,
    thank you for your reply.
    So, judging by your reply, not all package variables used inside a package need to be set a value for when run in DTEXEC ?
    I already tried that but my package ended up in error (something to do with "... invocation ...." and that error is anything but clearly documented. Judging by the error message itself, it looks like it could be just about anything. that is why I asked my
    first question about the object type package variable.
    Now, I will remove it from the 'set values' list and try another go cracking the unclear error-message " ... invocation ...". Does an error message about " ... invocation ..." ring any bells, now that we are talking about it here ?
    Thx in advance
    Jurgen
    Yes exactly
    You need to set values only forthem which needs to be controlled from outside the package
    Any variable which gets its value through expression set inside package or through a query inside execute sql task/script task can be ignored from DTExec
    Ok I've seen the invocation error mostly inside script task. This may be because some error inside script written in script task. If it appeared after you removed the variable then it may because some reference of variable existing within script task.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Package variable g_security_group_id must be set

    Hi all,
    i have the following problem.
    I have a form based on an interactive report.
    all standard made out of the apex possibilities.
    i have a number of validations, all automatically created by apex, in the form because of the not possible being null of certain columns in my database.
    when i press the insert button or save button when i didn't fill in all the necessary fields, i get the following error:
    ORA-20001: Package variable g_security_group_id must be set.
         Error      ERR-1023 Unable perform validations.
    OK      
    i allready checked my validations and i can't find something wrong with it.
    they haven't been modified neither after being automatically created by apex
    anyone any clue?
    thanks in advance,
    Mr. T

    Desmedt,
    Can you please demonstrate this on apex.oracle.com?
    Scott

  • Help needed for loss of package variables!

    Seem to have an annoying problem which may just be a misundertanding about libraries.
    I have two forms. Initially form 1 created initialised two package variables (of type ora_java.jobject) using the ora_java.new_global_ref function and these persisted across multiple user interactions and existed when form 2 was called (as new form / sharing libraries. Form 2 could call form 1 and the package variables still had values OK.
    These package variables were placed in library which only contained this package and was attached to both forms.
    I needed more functionality on form 2 so I created a menu module which had to run some code from form 2. I put most of the code (actually imported as it's mostly java classes) into the same library as the package containing the variables and attached the expanded pll to both forms and the menu module. Now when I run form 1 values for the package variables exist for the life of form 1 and form 2, but when I try to reference them after the initial display of form 2 they have disappeared!
    Also if form 1 is called again then it behaves differently in that references to the variable are lost after the form is first displayed.
    All forms and menus have shared libraries.
    I have spent some time playing with different variables and it's the same regardless of the variable type.
    Must be something to do with the library I think but don't know what - please help before I tear all my hair out!

    Ian,
    Ensure you have set the SHARE_LIBRARY_DATA parameter in your CALL_FORM statement.
    Also deleting the .fmx files, disconnecting from the database and re-building the form usually helps when everything else fails and you have not made any other changes you can think of that may have caused it to break.
    Also check that the forms are pointing to the right version of your .pll. Removing the attached library, adding it back and recompiling should do the trick.
    Hope this helps, before you lose your hair!

  • Package Variable Values in For Each Contaner

    I have a For Each File Container that loops through Excel files, executing a child package for each file found. I am using the RowCount transform to log the number of rows at various points in a DataFlow. When one file is processed the numbers are correct
    but when multiple files (e.g. 5) are processed some counts are zero when they shouldn't be. I have tried a 1 second sleep in the loop but that didn't fix the problem.
    R Campbell

    Please share more technical details
    numbers of what where, what Data Flaw how a package reports on the counts?
    Arthur
    MyBlog
    Twitter
    Actually, the title IS misleading.
    I have a parent package with a For Each File container
    and within that a child package is called, passing the file path and name. The child package has a
    DataFlow with quite a few branches in the flow. On some of those branches I have
    RowCount "transforms" each linked to its own
    package variable.
    At the CotrolFlow level a script is executed immediately after the DataFlow which writes the package variable values to the dts log.
    If I place one file at a time into the folder that the For Each Container is looking at and wait for it to be processed, the numbers are correct. If I place a number of files (say 5) in the folder at one time, some of the numbers logged are correct
    and some are zero.
    I did try a 1 second sleep at the start of the logging  script but, when I think about it, the package variables probably being read before the script starts to execute. If this is a timing issue (which I don't think that it should be) it might need
    to be a separate script between the DataFlow and the existing script, with a sleep in it.
    Because each loop of the parent package executes a new instance of the child package I am puzzled as to how there can be a timing issue. No matter how tight the loop might be, a new instance of the child package is executed each time.
    R Campbell

  • Passing Script variable to Package variable, ultimately used as fileName

    Following an excellent post by Geplaatst door Joost, I put together a script which SHOULD populate a package variable, then use that variable as a file name.
    The Script code is as follows:
    public class ScriptMain : UserComponent
    string iScriptVar;
    public override void PreExecute()
    base.PreExecute();
    public override void PostExecute()
    base.PostExecute();
    Variables.ExtractName = iScriptVar.ToString();
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    if (!Row.CUSIP_IsNull)
    iScriptVar = Row.CUSIP.ToString();
    A Windows message box (put in as debug, but removed for brevity here) shows the correct value is being set to iScriptVar at all points it was inserted.
    The "ExtractName" variable is checked as a ReadWriteVariables for the Script properties.
    But, the "ExtractName" package variable is not being passed to the Expressions for the FlatFile Connection properties, which is set to:  @[User::ExtractName].
    Where have I gone wrong?

    Why not to provide the link to the post already?
    iScriptVar
    is a local to script variable this explains why it did not you need the full wiring
    e.g.
    Dts.Variables["User::iScriptVar"].Value = iScriptVar
    Arthur
    MyBlog
    Twitter

  • BC4J ApplicationModule Pooling and persitent package variables

    Scenario:
    HttpRequest
    starts=> - use SessionCookie API to get an Application Module
    - call pck.set_id (packaged procedure which sets i++ )
    - call pck.get_id (packaged function returning value of i)
    finish=> release application Module (***)
    What I've seen:
    (***) When release statelessly
    Two browser sessions (could) get the same Application Module, in which case the 'i' value is incremented 'by' both browser sessions.
    (***) When release statefully
    Two browser sessions get their 'own' Application Module and manipulate their own 'i' value (even) between consequitive HTTP Requests.
    If both situations are explained and viewed correctly, does BC4J application module pooling guarantee that whenever I want to use an AM statefully I get persistent package variable state reproduced in that AM???
    If I understand correctly this doesn't mean I get the 'same' AM instance each time, but the BC4J Application Module pooling makes sure that whichever AM I get has state reproduced?
    Thx for explaining/affirming?
    -J.

    Scenario:
    HttpRequest
    starts=> - use SessionCookie API to get an Application Module
    - call pck.set_id (packaged procedure which sets i++ )
    - call pck.get_id (packaged function returning value of i)
    finish=> release application Module (***)
    What I've seen:
    (***) When release statelessly
    Two browser sessions (could) get the same Application Module, in which case the 'i' value is incremented 'by' both
    browser sessions.
    (***) When release statefully
    Two browser sessions get their 'own' Application Module and manipulate their own 'i' value (even) between
    consequitive HTTP Requests.
    If both situations are explained and viewed correctly, does BC4J application module pooling guarantee that whenever
    I want to use an AM statefully I get persistent package variable state reproduced in that AM???In scenario2 above the reason that two different ApplicationModule instances are returned for each
    respective session is that the pool has not yet hit its recycle threshold. Once this threshold is hit then the pool will
    begin "recycling" the state managed instances and you will observe the same behaviour as in scenario 1.
    If I understand correctly this doesn't mean I get the 'same' AM instance each time, but the BC4J Application Module
    pooling makes sure that whichever AM I get has state reproduced?This is true for the state that BC4J is aware of (i.e. iterator state, pending transactional changes, etc).
    However, BC4J cannot reproduce user state, like the PL/SQL session state that you have defined above. In order
    to maintain "user" state it is necessary to:
    1. passivate/activate the user state when BC4J passivates/activates its own state. BC4J currently provides a hook for
    this via ApplicationModuleImpl.passivateState(Document, Element) and ApplicationModuleImpl.activateState(Element).
    2. reset user state when BC4J recycles an ApplicationModule. 9.0.2 does not define a great mechanism for
    resetting user state. However, the upcoming maintenance release will provide an ApplicationModuleImpl.reset
    hook to clean up session state properly when an ApplicationModule is recycled.
    Hope this helps.

  • Referencing session variables in customMessages

    Can someone assist me with referencing session variables in a customMessage? For example, they following customMessage from productMessages.xml does not appear to work:
    <WebMessage name="kmsgProductPortal"><TEXT>Customer Dashboards - @{biServer.variables['NQ_SESSION.variable1']} </TEXT></WebMessage>
    Any help is appreciated.

    Can someone assist me with referencing session variables in a customMessage? For example, they following customMessage from productMessages.xml does not appear to work:
    <WebMessage name="kmsgProductPortal"><TEXT>Customer Dashboards - @{biServer.variables['NQ_SESSION.variable1']} </TEXT></WebMessage>
    Any help is appreciated.

  • Using Oracle package variables in JDBC.

    Can anybody know how we can use Oracle Package variable in Java/JDBC?
    I am using a insert trigger on a table which will initialize the login user
    from a package variable.In my log4j configuration file, while inserting data into this table, I am updating the user with my current user. But the insert statement is not identifying the user and it is inserting null.
    PLease let me know.

    Siva,
    You said:
    It is not inserting the user in the tableI see no table, here. Only a variable in a PL/SQL package.
    You also said:
    But the same is working in Oracle.Do you mean in SQL*Plus?
    Siva, try to forget how you are doing it, and tell me what you are trying to do.
    Do you have some UPDATE_USER column in your database tables where you record the username of the person who did the operation?
    Are you trying to write a trigger that populates this column?
    If so, then all you need is something like:
    create or replace trigger MY_TRIG
      after insert or update
      on MY_TABLE
      for each row
    begin
      :new.UPDATE_USER := user;
    end;Good Luck,
    Avi.
    P.S. By the way, what has this to do with OC4J?

  • Forms 10 and PL/SQL: Using a server package variable

    Hi,
    I have a variable created at package level in the server,
    When I try to assign its value to a Forms item, I get an error.
    "Unable to access distant package variable".
    What should I do to access this variable?
    Many thanks

    Hello,
    Add to the package a procedure to set this variable, and also a function that returns the variable content.
    Francois

  • Accessing database package variables from Forms

    I have a database package that populates a table of values, i.e.
    type t_route_list is table of rt_route.RTR_ID%type;
    route_list t_route_list
    route_list gets populated by a package function and I want to access route_list in the Form.
    While I can access other package variables by writing a function that returns the variable, Forms doesnt seem to like functions that return a user defined datatype as above. I have also tried using a procedure with an OUT param instead of a function but it also fails with same error.
    i.e.
    declare
    v_route_list pkg_bulk_route_replace.t_route_list;
    begin
    pkg_bulk_route_replace.init;
    pkg_bulk_route_replace.get_route_list(v_route_list);
    message(v_route_list(1));
    end;
    This will not compile, but removing the index (1) from the last line makes it compile but crash with ORA-0600.
    The code above with message replaced with dbms_out.put_line works fine on TOAD.
    So my question is......
    Can my database package return a plsql table to a form and if so, how?!

    Actually I've got this to work now!
    Thde main culprit appears to be a difference in the version of sql or pl/sql used on forms (version 5) and the database (8.1.7).
    I had defined my table as a nested table. By redefining this as a indexed table, simply by adding on 'index by binary_integer' on my server package, I am suddenly able to access the elements of the table on my form. Fortunately this did not break the server code either - the table was populated using bulk collect and that still works.
    Still got a bit of coding to do, but things are looking up now.

  • Global Variables Vs Form Library Package Variables Vs DB Package Variables

    I realise this question has been asked a few times with varying degrees of answers, but I am still seeking comment/advice from others.
    I am aware of following options for retaining persistent data to share between forms.
    1. Package variables in a library that you share in a session.
    This requires usage of SHARE_LIBRARY_DATA, there is risk that this not set, then does not share data.
    2. Package variables in a database package.
    Requires round trip to DB. Is this expensive for performance?
    What about risk of DB package becoming invalid and losing state?
    3. Use global variables
    Can be tricky to manage.
    4. Use parameters
    Only one way, ie called form cannot alter value that caller can see.
    Packages are closest to OO approach in using get and set modules. Allows all variables to be managed in one location. This appears best practice.
    Forms library packages appear risky if caller does not include SHARE_LIBRARY_DATA.
    DB packages have cost of round trip to DB. Does this become expensive is have to reference many times. Also topic of DB package becoming invalid and losing state?
    Forms global variables have regular disadvantages of globals, ie not sure who may modify. Need to manage carefully. Text only
    As a second related question, for value such as current user, for performance (and maintainability) is it better to obtain this from oracle user function each time, or save somewhere (in one of options above) and use that saved value each time.

    My personal opinion:
    I like the "packaged" version with getters and setters. In general, i create a client-side package in a pll which has methods to access the value by getters and setters. With that, the "implementation" is encapsulated and doesn't really matter to the rest of your system. All modules have to access the value using the getter and setter.
    Inside the procedure i use two approaches:
    1. If its for communication purposes between different forms i use globals, which are filled or extracted in the getter and setter (see this http://andreas.weiden.orcl.over-blog.de/article-28180655.html )
    2. If its for someother purpose where the value should be "session persistent" i use a database package with getters and setters, which are called from the client-side package getter and setter. If the value is quite "constant" throughout the session, i read the value once at initialization code of the client-side package and the getter just returns that "cached" value
    Hope this helps.

Maybe you are looking for

  • Blue screen error when connecting an ethernet cable

    I have a Compaq Presario 5300US desktop that I'm trying to upgrade.  It has 512mb (max) of memory and a newer video card than the factory one.  I installed Vista Home Basic on it with no problems.  I also installed a pci ethernet card along with the

  • Animated GIFs in Captivate 2 or 3

    I have 31 lessons (PowerPoint) that contain animated GIFs. If I import these into Captivate 2 or Captivate 3, will these animations within the animated GIFs be maintained? Thanks for any replies! All the best with your own projects. Dean

  • Spotlight is gray instead of blue and won't return proper results

    Hello, I have been having difficulty with Spotlight for 2 months now. One day, it just stopped returning any results. So I reindexed the entire hard drive, checked via Terminal to make sure indexing was on and followed a bevy of other tricks found in

  • Using jsxbin files in a Photoshop extension

    I have seen that jsx files can be converted to jsxbin files which hide the source from the user. Is it possible to use such jsxbin files in a Photoshop extension? If yes, how would one go about converting a jsx file to a jsxbin file? Thanks!

  • Process Chain Mail Alert

    Hi Gurus, Could anyone please tell me how to set up a mail alert to a list of receipients in case of Process Chain failure. Thanks in advance, Best regards, KT Varkey