Package variables urgent
Hi,
I want to use certain variables which have been declared in the package ie global variables .
These variables are to be accessed in a trigger.
how do i do this.
any method is welcome,either through functions or procedures.
please do provide the solution
Thanks both for the reply.
Now the scenario has changed a bit.
what i have done is that i have defined a package variable in the package.
Now The package has 4 sps and i function.
I assign a value to the package variable in one of the sps.
using this value, I insert it into a temporary which i create inside the sp.(using execute immediate)
can i do this.i get an error of previalges which was sorted out.
Now i am accesiing the data in the temp table inside the function.the function returns me an id which is retrieved from another table using the value in the temp table.
This function is called inside a trigger,which gives me an error ora-04601-existing state of package being discarded.
pls help.
Similar Messages
-
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
StephenStephen,
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 -
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
JurgenHi 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. TDesmedt,
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 CampbellPlease 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. -
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 thanksHello,
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. -
To view package variables in Forms 6i debugger
Can anyone tell me how to view the value of the variables declared in the package spec(from forms side)? i can see only the local variables and global variables(declared using :GLOBAL) in the debugger window.
In the 6i Debugger the visible Package variables are restricted to the Variables defined in the package body and these are only visible whilst you are instanciating the package for the first time - e.g. running through the anonymous block that you can have at the bottom of the package Definition.
Otherwise they are invisble. Variables defined within Program units inside the Package are of course visble.
The new Debugger in Forms 9i has fixed this problem and you can always view (and watch!) Variables defined both in the package Spec and Body. -
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) -
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 helpYou 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
Maybe you are looking for
-
Why does the App Store not work in Genius with VoiceOver switched on
After I downloaded IOS 6 to my iPhone 4 there were a lot of things not working properly, the main things that were a problem was the App Store, to move anything with VoiceOver switched on it was touch-and then tap twice also to move the thing on the
-
Auto fill addresses in SMS texts - where did it go?
I just had to swap out my iPhone4 (1st one only one month old had hardware problems) everything with the new phone seems fine, but I just noticed when texting that I can't type the first few letters of a person's name and it automatically shows all t
-
Servlet cannot find classes when in a EAR
Hi I have a EAR that contains a EJB module and a web application module. The Web application module contains two servlets to be deployed. One is Action Servlet (struts.jar) and the other is our home-made. I am
-
My iMac is now starting to make a noise when on. It sounds as if the fan is working overtime. It is an audible ticking. Any help appreciated
-
HELP - I can't download video podcasts that I used to be able to !
I have a 120 gb iPod classic that I received for Christmas a couple of years ago (2008) & I download podcasts to it every wk. since I received it. It still has 80 gb of free space BUT it wont' load some video podcasts from iTunes now. I'm thinking I