Declare objects globally or pass as parameter in Package
Hi All,
Need a technical suggestion, in a package i am having several functions,
say Fn_A calling Fn_B and Fn_B calling Fn_C and Fn_C calling Fn_D
and i need a collection of Nested Table Objects to be processed at Fn_D,
and it has to reach from Fn_A, in-between say Fn_C if required, can also process
the Nested Table Object.
Also for each Function need to pass 3 parameters of collection object and 3 to 4 Number/Varchar2.
My question is, would it be better to declare the Nested Table Object globally inside the package,
or Pass it as an IN OUT NO COPY parameter throughout all functions ?
And the scenario is :
Nested Table would have 1000 objects in the collection,
and each object will have size = 75 Bytes
and in one day on an average 3 million calls made.
regards,
Ludy
My bias would be not to use a package global if you can reasonably pass the collection as a parameter. It's easier to maintain code that is self-contained rather than trying to debug code whose behavior depends on the state of the session. If you pass in the collection as a parameter, you can write unit tests for all 4 procedures relatively easily rather than having to go through all 4 to test procedure D. Plus, if you don't need to maintain session state, you can update your package code without causing any application tier connections that remained open to error out.
Performance wise, I wouldn't expect it to matter, though it would be worth benchmarking.
Justin
Similar Messages
-
How to declare a global variable from a PL/SQL package
Hi All,
Using a global variable is a bad practise for all language. However, in my case, I have a PL/SQL package defines all constants, and I want to use them directly via SQL statement, for instance,
PACKAGE my_const
IS
DEFAULT_ZIP_CODE CONSTANT VARCHAR2(5) := '00000';
END;And I cannot referrence this variable from my select statement as
SELECT my_const.DEFAULT_ZIP_CODE from dual;I have to create a function via my package, as,
FUNCTION get_default_zip_code RETURN VARCHAR2
IS
BEGIN
RETURN DEFAULT_ZIP_CODE;
END;and
SELECT my_const.get_default_zip_code from dual;I don't want to create functions to referrence the default varaibles. Does anyone have any clues?
thanks
Edited by: user4184769 on Jul 19, 2010 8:36 AMriedelme wrote:
thanks for the info. Your scope explanation makes sense even though it is not intuitive to me. I think the usage of package variables should be supported by SQL (they're just values to be copied) Maybe look at it from another language's perspective. You want to use a global PL package variable in Java/C#/Delphi/VB/etc. How would you do it?
None of these languages can crack open the data segment of a PL code unit, inspect the variables in it, and extract a value from it. Instead, it needs to be done as follows:
Using sqlplus as the client illustrates how all these languages will need to do it:
SQL> var value varchar2(20);
SQL> begin
2> :value := SomePackage.someVar;
3> end;
4> /So why should SQL behave differently? It is not the same as the PL language. It is not a subset of the PL language. Yeah, PL/SQL blurs the line between these 2 languages making it very simple for us to mix their source code. But PL/SQL is SQL integrated with PL - not PL integrated with SQL. PL has tight hooks into SQL, creating cursors for you, defining bind variables, binding variables and doing the whole Oracle Call Interface bit for you.
But SQL has no need for PL code, just as it has no need for Java code, or Delphi code or VB code. Yes, it is possible for it to call Java stored procs. As it is possible for it to call PL procs. But these are via the formal call interface of those languages - not via tight integration hooks that blur the languages and make SQL and Java, or SQL and PL, look like a single integrated source code unit.
Thus SQL has the pretty much the same constraints in calling the PL language as other languages do. What SQL can do is use the PL engine's call interface and tell it "+execute this function and return the result of the function+". -
Crystal Reports 2008 - passing a parameter in the Command Object
Hi,
I am using Crystal Reports 2008. I have 4 Command Objects where I have the following queries.
select emrace, count(empl_id) cntFCiv from emmain where emtype='CIV' and emsex ='F' and emdateterm is null group by emrace
select emrace, count(empl_id) cntFSw from emmain where emtype='SWOR' and emsex ='F' and emdateterm is null group by emrace
select emrace, count(empl_id) cntMCiv from emmain where emtype='CIV' and emsex = 'M' and emdateterm is null group by emrace
select emrace,count(empl_id) cntMSw from emmain where emtype='SWOR' and emsex = 'M' and emdateterm is null group by emrace
I want to pass a parameter to all these command objects. I want the user to select a parameter from a list of values. So, I created a parameter object, Bureau. (I get the values for the parameter with this command object: select code_agcy, descriptn from systab1 where code_key = 'UNIT'). I want the user to be able to get the counts for each bureau.
How do I pass the parameter that the user picked to those command objects. I tried doing this:
select emrace, count(empl_id) cntFCiv from emmain where emtype='CIV' and emsex ='F' and emdateterm is null
and emunit = '{?Bureau}' group by emrace
But it did not work. Any help will be greatly appreciated.
Thanks.Hi,
I am using Crystal Reports 2008. I have 4 Command Objects where I have the following queries.
select emrace, count(empl_id) cntFCiv from emmain where emtype='CIV' and emsex ='F' and emdateterm is null group by emrace
select emrace, count(empl_id) cntFSw from emmain where emtype='SWOR' and emsex ='F' and emdateterm is null group by emrace
select emrace, count(empl_id) cntMCiv from emmain where emtype='CIV' and emsex = 'M' and emdateterm is null group by emrace
select emrace,count(empl_id) cntMSw from emmain where emtype='SWOR' and emsex = 'M' and emdateterm is null group by emrace
I want to pass a parameter to all these command objects. I want the user to select a parameter from a list of values. So, I created a parameter object, Bureau. (I get the values for the parameter with this command object: select code_agcy, descriptn from systab1 where code_key = 'UNIT'). I want the user to be able to get the counts for each bureau.
How do I pass the parameter that the user picked to those command objects. I tried doing this:
select emrace, count(empl_id) cntFCiv from emmain where emtype='CIV' and emsex ='F' and emdateterm is null
and emunit = '{?Bureau}' group by emrace
But it did not work. Any help will be greatly appreciated.
Thanks. -
How to pass a parameter to a declared function
Hello all
Can anyone help me with the following? I have a function which reads files and then adds the contents to a database. As some of the files are quite big I want to add them one at a time to the database. To do this I am passing a value from another page, if this value matches the filename then only that file will be loaded. I know I cannot use the request object to pass the value, as my function is declared, and I should pass the value as a param. Does anyone have any example code of how I can do this?
Thanks in advance for any help you can give me
elliemayFirst, I would use a servlet instead of a JSP page, then I recommend using the "indexOf" method of the String object when you get the files name Array. If "indexOf(request.getParameter(Branch))" equals "-1", the file cannot be processed. Here is a quick example of a servlet doing the work (based on your code) :
package mypackage1;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ProcessFiles extends HttpServlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
File f = null;
PrintWriter out = null;
String sBranch = null;
String sPath = null;
String[] files = null;
response.setContentType("text/html; charset=windows-1252");
out = response.getWriter();
sBranch = request.getParameter("Branch");
// Check here if sBranch is not null
InitDB();
sPath = dbLookup("TEXT","T1_FILE_PATH");
// Check here if sPath is not null
f = new File(sPath);
files = f.list();
for (int i = 0; i < files.length; i++)
// Acting like a filter using the "indexOf" method of the String object on each item
if (files.length() == 15 && files[i].indexOf(sBranch) != -1)
ProcessFile(files[i], sPath);
DeleteFile(files[i]);
out.println("<html>");
out.println("<head><title>ProcessFiles</title></head>");
out.println("<body>");
out.println("<p>Files loaded</p>");
out.println("</body></html>");
out.close();
private void ProcessFile(String sFileName,String sPathPrefix) throws Exception
String record = null;
int RecCtr = 0;
final String EOR_DELIM = "*END*";
String sBranch = sFileName.substring(0,3);
String sRunDate = sFileName.substring(3,11);
final String InitSQL = "Insert into T1 values ('" + sBranch + "',";
String sSQL = InitSQL;
int i;
ExecSQLCmd("Delete from T1 where Branch='" + sBranch + "'");
try
FileReader fr = new FileReader(sPathPrefix + "/" + sFileName);
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null)
if (MyStrEquals(record,EOR_DELIM))
sSQL=ChopOff(sSQL,1) + ")";
ExecSQLCmd(sSQL);
RecCtr++;
sSQL = InitSQL;
else
StringTokenizer st = new StringTokenizer(record,"@");
i=0;
while (st.hasMoreTokens())
sSQL += ("'" + Escape(st.nextToken()) + "',");
i++;
catch (IOException e)
System.out.println("IOException error!");
e.printStackTrace();
throw e; -
I am passing my itab data to variable declared in global declaration.
Dear All,
I am passing my itab data to variable declared in global declaration, i am getting column one data in all eight variables declared. but column two data having 8*10=80 data i.s. for 1 entry of column there is 10 entries of column two of field two ,
but when i am passing that data to a variable i am getting only 1st entry of column 2 instead of 10 entries, plz help me in solving this query. i am working on Smartform.Definetly you will get only one record...
instead of variable decalre and internal table of type variable definition in the global defination and append the values into it..
now you will get all the entries which you want..
Regards
Satish Boguda -
How do I Pass a parameter to a SQL Component Task where the source SQL statement is also a variable
Hi,
I have been tasked with making a complex package more generic.
To achieve this I need to pass a parameter to a SQL Component Task where the source SQL statement is also a variable.
So to help articulate my question further I have create a package and database as follows; -
USE [KWPlay]
GO
/****** Object: Table [dbo].[tblTest] Script Date: 05/14/2014 17:08:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblTest](
[ID] [bigint] IDENTITY(1,1) NOT NULL,
[Description] [nvarchar](50) NULL,
CONSTRAINT [PK_tblTest] PRIMARY KEY CLUSTERED
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
I populated this table with a single record.
I unit tested the SQL within SSMS as follows;
SELECT * FROM dbo.tblTest
Result; -
ID
Description
1
Happy
DECLARE @myParam NVARCHAR(100)
SET @myParam = 'Sad'
UPDATE dbo.tblTest SET [Description] = @myParam FROM dbo.tblTest WHERE ID = 1
SELECT * FROM dbo.tblTest
Result; -
ID
Description
1
Sad
Within the package I created two variables as follows; -
Name: strSQL
Scope: Package
Data Type: String
Value: UPDATE dbo.tblTest SET [Description] = @myParam FROM dbo.tblTest WHERE ID = 1
Name: strStatus
Scope: Package
Data Type: String
Value: Happy
I then created a single ‘Execute SQL Task’ component within the control flow as follows; -
However when I run the above package I get the following error; -
SSIS package "Package.dtsx" starting.
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "UPDATE dbo.tblTest SET [Description] = @myParam FR..." failed with the following error:
"Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Execute SQL Task
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.
The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the
errors.
SSIS package "Package.dtsx" finished: Failure.
I also tried; -
Name: strSQL
Scope: Package
Data Type: String
Value: UPDATE dbo.tblTest SET [Description] = ? FROM dbo.tblTest WHERE ID = 1
However I received the error; -
SSIS package "Package.dtsx" starting.
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "UPDATE dbo.tblTest SET [Description] = ? FROM dbo...." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with
the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Execute SQL Task
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches
the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Tried; -
Name: strSQL
Scope: Package
Data Type: String
Value: UPDATE dbo.tblTest SET [Description] = ? FROM dbo.tblTest WHERE ID = 1
and; -
Result; -
SSIS package "Package.dtsx" starting.
SSIS package "Package.dtsx" finished: Success.
Therefore the answer was to put the parameter number rather than the parameter name under the parameter mapping tab-> parameter name column.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/ -
How to assign Values to nested table and pass as parameter to procedure?
How to assign Values to nested table and pass as parameter to procedure?
Below is the Object and its type
create or replace type test_object1 as object
val1 varchar2(50),
val2 varchar2(50),
val3 varchar2(50)
create or replace type test_type1 is table of test_object1;
create or replace type test_object2 as object
val1 varchar2(50),
val2 varchar2(50),
val3 varchar2(50)
create or replace type test_type2 is table of test_object2;
GRANT ALL ON test_object1 TO PUBLIC;
GRANT ALL ON test_type1 TO PUBLIC;
GRANT ALL ON test_object2 TO PUBLIC;
GRANT ALL ON test_type2 TO PUBLIC;
here is the table made of object type:
create table test_object_tpe
sl_num NUMBER,
description VARCHAR2(100),
main_val1 test_type1,
main_val2 test_type2
NESTED TABLE main_val1 STORE AS tot1
NESTED TABLE main_val2 STORE AS tot2;
here is the procedure which inserts values into nested table:
PROCEDURE INSERT_TEST_DATA(sl_num IN NUMBER,
description IN VARCHAR2,
p_main_val1 IN test_type1,
p_main_val2 IN test_type2
IS
BEGIN
FOR rec in p_main_val1.first..p_main_val1.last
LOOP
INSERT INTO xxdl.test_object_tpe
sl_num,
description,
main_val1,
main_val2
VALUES
sl_num
,description
,test_type1 (test_object1(
p_main_val1(rec).val1,
p_main_val1(rec).val2,
p_main_val1(rec).val3
,test_type2 (test_object2( p_main_val2(rec).val1,
p_main_val2(rec).val2,
p_main_val2(rec).val3
END LOOP;
commit;
END INSERT_TEST_DATA;
here is the anonymoys block which assigns values to the object type and pass values into the procedure:
set serveroutput on;
declare
p_sl_num NUMBER := 1001;
p_description VARCHAR2(50) := 'Testing Val1';
inval1 test_type1 := test_type1();
inval2 test_type2 := test_type2();
begin
inval1(1).val1 := 'testx1';
inval1(1).val2 := 'testx2';
inval1(1).val3 := 'testx3';
inval2(1).val1 := 'testy1';
inval2(1).val2 := 'testy2';
inval2(1).val3 := 'testy3';
CSI_PKG.INSERT_TEST_DATA(sl_num => p_sl_num,
description => p_description,
p_main_val1 => inval1,
p_main_val2 => inval2
end;
Can anybody correct me.
Thanks,
LavanThanks for posting the DDL and sample code but whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
How to assign Values to nested table and pass as parameter to procedure?
>
Well you are doing almost everything wrong that could be done wrong.
Here is code that works to insert data into your table (the procedure isn't even needed).
declare
p_sl_num NUMBER := 1001;
p_description VARCHAR2(50) := 'Testing Val1';
inval1 test_type1 := test_type1();
inval2 test_type2 := test_type2();
begin
inval1.extend();
inval1(1) := test_object1('testx1', 'testx2', 'testx3');
inval2.extend();
inval2(1) := test_object2('testy1', 'testy2', 'testy3');
INSERT INTO test_object_tpe
sl_num,
description,
main_val1,
main_val2
VALUES
(p_sl_num, p_description, inval1, inval2);
commit;
end;
/See Example 5-15 Referencing a Nested Table Element in Chap 5 Using PL/SQL Collections and Records in the PL/SQL doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/collections.htm#CJABEBEA
1. You don't even need the procedure since all it does is a simple INSERT into the table which you can do directly (see my code above)
inval1(1).val1 := 'testx1';There is no element one (1) of 'inval1' since you haven't created any elements yet. You need to EXTEND the collection to add an element
inval1.extend();And then there is an empty element but 'inval1' is a container for objects of type 'test_object1' not for scalars like 'val1', 'val2', and 'val3'.
So you can't do
inval1(1).val1 := 'testx1';You have to create an instance of 'test_object1'
inval1(1) := test_object1('testx1', 'testx2', 'testx3');And so on for the other collection
You don't need the procedure (as my sample code shows) but once you populate the variables properly it will work. -
How pass a parameter with forward slash to plsql script
Hi,
I am trying pass a parameter to plsql script from command line using sqlplus, and the parameter is a file directory and has '/'. Seems the system couldn't recognize the value.
here is my code in DECLARE:
l_FileDir VARCHAR2(200) := &&FileDir ;
I pass value '/usr/tmp' (with the single quote in the string)
Can someone tell me how I do it?
Thanks,
Kate
Edited by: user12100435 on Feb 25, 2010 8:31 AMuser12100435 wrote:
I think you are right. The issue is not file-separator character issue. because the exact same script run in another envoironment. And it's not file directory or permission issue because if I use hardcoded value, the code works fine.
The error message is invalid File directory.
Here is the related part of the code.
-- open file handler
IF UTL_FILE.IS_OPEN(l_FileHandler) THEN
UTL_FILE.FCLOSE(l_FileHandler);
ELSE
l_FileHandler := UTL_FILE.FOPEN ( location => l_FileDir,
filename => l_FileName,
open_mode => 'W',
max_linesize => 32767 );
END IF;Ok, based on your input so far, I have cooked up a simple testcase.
Make sure you are doing something similar to this -
test@XE>
test@XE> -- show the contents of the anonymous PL/SQL script
test@XE> -- You are probably passing two parameters - the file location and the file name
test@XE> --
test@XE> ! cat test5.sql
DECLARE
l_FileHandler UTL_FILE.FILE_TYPE;
l_FileDir VARCHAR2(200) := '&1' ;
l_FileName VARCHAR2(200) := '&2' ;
BEGIN
-- open file handler
IF UTL_FILE.IS_OPEN(l_FileHandler) THEN
UTL_FILE.FCLOSE(l_FileHandler);
ELSE
l_FileHandler := UTL_FILE.FOPEN ( location => l_FileDir,
filename => l_FileName,
open_mode => 'W',
max_linesize => 32767 );
UTL_FILE.PUT_LINE(file => l_FileHandler, buffer => 'Hello, World!');
UTL_FILE.FCLOSE(file => l_FileHandler);
END IF;
END;
test@XE>
test@XE> -- execute it
test@XE> @test5.sql '/usr/tmp' 'first.txt'
old 3: l_FileDir VARCHAR2(200) := '&1' ;
new 3: l_FileDir VARCHAR2(200) := '/usr/tmp' ;
old 4: l_FileName VARCHAR2(200) := '&2' ;
new 4: l_FileName VARCHAR2(200) := 'first.txt' ;
DECLARE
ERROR at line 1:
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at line 10
test@XE>
test@XE> -- Create a directory object that points to "/usr/tmp"
test@XE> create directory log_dir as '/usr/tmp';
Directory created.
test@XE>
test@XE> -- now invoke the script
test@XE> -- Note - I pass the value "LOG_DIR" in uppercase. That's the name of my directory object.
test@XE> --
test@XE> @test5.sql 'LOG_DIR' 'first.txt'
old 3: l_FileDir VARCHAR2(200) := '&1' ;
new 3: l_FileDir VARCHAR2(200) := 'LOG_DIR' ;
old 4: l_FileName VARCHAR2(200) := '&2' ;
new 4: l_FileName VARCHAR2(200) := 'first.txt' ;
PL/SQL procedure successfully completed.
test@XE>
test@XE> -- Since my Oracle client is on the same machine as the Oracle server, I can check
test@XE> -- this file "/usr/tmp/first.txt" quite easily
test@XE>
test@XE> ! cat /usr/tmp/first.txt
Hello, World!
test@XE>
test@XE> isotope -
Web link to pass the parameter to custom web app then update the field
Hi,
I have created the web link in service request object to refer Account Object. I want to let user able to select the account from web link then base on the current SR no and account that have created update the record in CRMOD. My question is how to pass the parameter out to my external web app so that they can update my SR correctly?
Thank youHi Messer,
I have put in the syntax as below :-
https://secure-ausomxega.crmondemand.com/OnDemand/user/AssocAccountPopup?mapBC=Service+Request&OACTRL=Account&ophi=PopupNewForm.Account+Id&pfid=PopupNewForm&OMTHD=AssocPopup&OMTGT=PopupSearchList&assocInit=Y&opht=4&OAOBJ=Service+Request&mapField=Account&ophd=PopupNewForm.Account&ophpd=3&disableclear=Y&ophr=AssocAccountPopup&assocval=&ParentType=Edit
This pop up screen wil let the user to select the account then i will pass the account and the SR to external web app to update back the CRMOD. I am not too sure the above syntax is correct or maybe can you give some example.
I am new in CRMOD, hope that you can advice on this.
Thank you,
SK -
How to pass Cascading Parameter in SSRS using Java
How to pass Cascading Parameter in SSRS using Java---
We are having a problem with dependent parameters.There are three drop down--
1.first dropdown is of Country.When we select a country--Accordingly next dropdown(State)will populate
2.Second dropdown is of State. When we select a state--Accordingly next dropdown(City)will populate.
I have three data sources are
CountryList-
SELECT CountryRegionCode, Name
FROM Person.CountryRegion
ORDER BY Name
StateList
SELECT StateProvinceID, StateProvinceCode, CountryRegionCode
FROM Person.StateProvince
WHERE CountryRegionCode = @CountryRegionCode
ORDER BY StateProvinceCode
CityList
SELECT StateProvinceID, City
FROM Person.Address
GROUP BY StateProvinceID, City
HAVING (StateProvinceID = @StateProvinceID)
ORDER BY City
Ihave to show report that has been deployed on server on the besis of these parameters
I am using ReportViewer in JSP Page through url--
http://192.168.90.149/ReportServer/Pages/ReportViewer.aspx?%2fReport+Project1%2fCascading_Parameters&rs:Command=Render&rs:parameter=true&Country="+Country+"&State="+State;
But it is not accepting parameter if they are cascaded.It is working fine if Both parameters are independent.
Edited by: kaushlee on May 11, 2010 9:22 PMTake a look at set_custom_property:
public static final ID SETTEXT = ID.registerProperty("SETTEXT");
public boolean setProperty(ID pid, Object value)
if (pid == SETTEXT)
String text = value.toString();
and in forms
set_custom_property('beans.bean_item', 1, 'SETTEXT', 'some text');
cheers -
Passing a parameter from one class to another class in the same package
Hi.
I am trying to pass a parameter from one class to another class with in a package.And i am Getting the variable as null every time.In the code there is two classes.
i. BugWatcherAction.java
ii.BugWatcherRefreshAction.Java.
We have implemented caching in the front-end level.But according to the business logic we need to clear the cache and again have to access the database after some actions are happened.There are another class file called BugwatcherPortletContent.java.
So, we are dealing with three java files.The database interaction is taken care by the portletContent.java file.Below I am giving the code for the perticular function in the bugwatcherPortletContent.java:
==============================================================
public Object loadContent() throws Exception {
Hashtable htStore = new Hashtable();
JetspeedRunData rundata = this.getInputData();
String pId = this.getPorletId();
PortalLogger.logDebug(" in the portlet content: "+pId);
pId1=pId;//done by sraha
htStore.put("PortletId", pId);
htStore.put("BW_HOME_URL",CommonUtil.getMessage("BW.Home.Url"));
htStore.put("BW_BUGVIEW_URL",CommonUtil.getMessage("BW.BugView.Url"));
HttpServletRequest request = rundata.getRequest();
PortalLogger.logDebug(
"BugWatcherPortletContent:: build normal context");
HttpSession session = null;
int bugProfileId = 0;
Hashtable bugProfiles = null;
Hashtable bugData = null;
boolean fetchProfiles = false;
try {
session = request.getSession(true);
// Attempting to get the profiles from the session.
//If the profiles are not present in the session, then they would have to be
// obtained from the database.
bugProfiles = (Hashtable) session.getAttribute("Profiles");
//Getting the selected bug profile id.
String bugProfileIdObj = request.getParameter("bugProfile" + pId);
// Getting the logged in user
String userId = request.getRemoteUser();
if (bugProfiles == null) {
fetchProfiles = true;
if (bugProfileIdObj == null) {
// setting the bugprofile id as -1 indicates "all profiles" is selected
bugProfileIdObj =(String) session.getAttribute("bugProfileId" + pId);
if (bugProfileIdObj == null) {
bugProfileId = -1;
else {
bugProfileId = Integer.parseInt(bugProfileIdObj);
else {
bugProfileId = Integer.parseInt(bugProfileIdObj);
session.setAttribute(
("bugProfileId" + pId),
Integer.toString(bugProfileId));
//fetching the bug list
bugData =BugWatcherAPI.getbugList(userId, bugProfileId, fetchProfiles);
PortalLogger.logDebug("BugWatcherPortletContent:: got bug data");
if (bugData != null) {
Hashtable htProfiles = (Hashtable) bugData.get("Profiles");
} else {
htStore.put("NoProfiles", "Y");
} catch (CodedPortalException e) {
htStore.put("Error", CommonUtil.getErrMessage(e.getMessage()));
PortalLogger.logException
("BugWatcherPortletContent:: CodedPortalException!!",e);
} catch (Exception e) {
PortalLogger.logException(
"BugWatcherPortletContent::Generic Exception!!",e);
htStore.put( "Error",CommonUtil.getErrMessage(ErrorConstantsI.GET_BUGLIST_FAILED));
if (fetchProfiles) {
bugProfiles = (Hashtable) bugData.get("Profiles");
session.setAttribute("Profiles", bugProfiles);
// putting the stuff in the context
htStore.put("Profiles", bugProfiles);
htStore.put("SelectedProfile", new Integer(bugProfileId));
htStore.put("bugs", (ArrayList) bugData.get("Bugs"));
return htStore;
=============================================================
And I am trying to call this function as it can capable of fetching the data from the database by "getbugProfiles".
In the new class bugWatcherRefreshAction.java I have coded a part of code which actually clears the caching.Below I am giving the required part of the code:
=============================================================
public void doPerform(RunData rundata, Context context,String str) throws Exception {
JetspeedRunData data = (JetspeedRunData) rundata;
HttpServletRequest request = null;
//PortletConfig pc = portlet.getPortletConfig();
//String userId = request.getRemoteUser();
/*String userId = ((JetspeedUser)rundata.getUser()).getUserName();//sraha on 1/4/05
String pId = request.getParameter("PortletId");
PortalLogger.logDebug("just after pId " +pId); */
//Calling the variable holding the value of portlet id from BugWatcherAction.java
//We are getting the portlet id here , through a variable from BugWatcherAction.java
/*BugWatcherPortletContent bgAct = new BugWatcherPortletContent();
String portletID = bgAct.pId1;
PortalLogger.logDebug("got the portlet ID in bugwatcherRefreshAction:---sraha"+portletID);*/
// updating the bug groups
Hashtable result = new Hashtable();
try {
request = data.getRequest();
String userId = ((JetspeedUser)data.getUser()).getUserName();//sraha on 1/4/05
//String pId = (String)request.getParameter("portletId");
//String pId = pc.getPorletId();
PortalLogger.logDebug("just after pId " +pId);
PortalLogger.logDebug("after getting the pId-----sraha");
result =BugWatcherAPI.getbugList(profileId, userId);
PortalLogger.logDebug("select the new bug groups:: select is done ");
context.put("SelectedbugGroups", profileId);
//start clearing the cache
ContentCacheContext cacheContext = getCacheContext(rundata);
PortalLogger.logDebug("listBugWatcher Caching - removing markup content - before removecontent");
// remove the markup content from cache.
PortletContentCache.removeContent(cacheContext);
PortalLogger.logDebug("listBugWatcher Caching-removing markup content - after removecontent");
//remove the backend content from cache
CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(((JetspeedUser)data.getUser()).getUserName()));
PortalLogger.logDebug("listBugWatcher Caching User: " +((JetspeedUser)data.getUser()).getUserName());
PortalLogger.logDebug("listBugWatcher Caching pId: " +pId);
if (pdata != null)
// User's data found in cache!
PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null");
pdata.removeObject(PortletCacheHelper.getUserPortletHandle(((JetspeedUser)data.getUser()).getUserName(),pId));
PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null- after removeObject");
PortalLogger.logDebug("listBugWatcher Caching -finish calling the remove content code");
//end clearing the cache
// after clearing the caching calling the data from the database taking a fn from the portletContent.java
PortalLogger.logDebug("after clearing cache---sraha");
BugWatcherPortletContent bugwatchportcont = new BugWatcherPortletContent();
Hashtable httable= new Hashtable();
httable=(Hashtable)bugwatchportcont.loadContent();
PortalLogger.logDebug("after making the type casting-----sraha");
Set storeKeySet = httable.keySet();
Iterator itr = storeKeySet.iterator();
while (itr.hasNext()) {
String paramName = (String) itr.next();
context.put(paramName, httable.get(paramName));
PortalLogger.logDebug("after calling the databs data from hashtable---sraha");
} catch (CodedPortalException e) {
PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
context.put("Error", CommonUtil.getErrMessage(e.getMessage()));
catch (Exception e) {
PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
context.put( "Error",CommonUtil.getErrMessage(ErrorConstantsI.EXCEPTION_CODE));
try {
((JetspeedRunData) data).setCustomized(null);
if (((JetspeedRunData) data).getCustomized() == null)
ActionLoader.getInstance().exec(data,"controls.EndCustomize");
catch (Exception e)
PortalLogger.logException("bugwatcherRefreshAction", e);
===============================================================
In the bugwatcher Action there is another function called PostLoadContent.java
here though i have found the portlet Id but unable to fetch that in the bugWatcherRefreshAction.java . I am also giving the code of that function under the bugWatcherAction.Java
================================================
// Get the PortletData object from intermediate store.
CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(
//rundata.getRequest().getRemoteUser()));
((JetspeedUser)rundata.getUser()).getUserName()));
pId1 = (String)portlet.getID();
PortalLogger.logDebug("in the bugwatcher action:"+pId1);
try {
Hashtable htStore = null;
// if PortletData is available in store, get current portlet's data from it.
if (pdata != null) {
htStore =(Hashtable) pdata.getObject( PortletCacheHelper.getUserPortletHandle(
((JetspeedUser)rundata.getUser()).getUserName(),portlet.getID()));
//Loop through the hashtable and put its elements in context
Set storeKeySet = htStore.keySet();
Iterator itr = storeKeySet.iterator();
while (itr.hasNext()) {
String paramName = (String) itr.next();
context.put(paramName, htStore.get(paramName));
bugwatcherRefreshAction bRefAc = new bugwatcherRefreshAction();
bRefAc.doPerform(pdata,context,pId1);
=============================================================
So this is the total scenario for the fetching the data , after clearing the cache and display that in the portal.I am unable to do that.Presently it is still fetching the data from the cache and it is not going to the database.Even the portlet Id is returning as null.
I am unable to implement that thing.
If you have any insight about this thing, that would be great .As it is very urgent a promt response will highly appreciated.Please send me any pointers or any issues for this I am unable to do that.
Please let me know as early as possible.
Thanks and regards,
Santanu Raha.Have you run it in a debugger? That will show you exactly what is happening and why.
-
Passing a parameter from one form to another
Hi
I'm trying to pass a parameter from one form to another. I've read lots of postings about this, and I have succeeded in calling the second form using code behind one of the existing Portal buttons (insert). Here is the code:
DECLARE
pro_id NUMBER;
pro_link VARCHAR2(1200);
BEGIN
pro_id := p_session.get_value_as_number(
p_block_name => 'DEFAULT',
p_attribute_name => 'A_PRO_ID');
pro_link := portal30.wwv_user_utilities.get_url(
'CINTRA_APP.PRO_LINK_1',
'WKG_PRO_ID',pro_id,
'_WKG_PRO_ID_cond','=');
PORTAL30.wwa_app_module.set_target(pro_link,'CALL');
END;
Trouble is, the parameter does not get passed. This could be because:
the field I'm trying to populate is based on an LOV ?
the target form is not set up to receive parameters? (I read this somewhere, but how do you do it?)
Thanks
ManfredDear InoL
My Header Form coding as follows.
When I press the button to move to the lines the following code executes
PASSING FORM CODING;
DECLARE
pl PARAMLIST := GET_PARAMETER_LIST('PL_AT');
BEGIN
IF NOT ID_NULL(pl) THEN
DESTROY_PARAMETER_LIST(pl);
END IF;
pl := CREATE_PARAMETER_LIST('PL_AT');
ADD_PARAMETER(pl,'P_AT',TEXT_PARAMETER,:HWSI_ASSET_TAG);
CALL_FORM('E:\IT_SYSTEM\6i\HWDYNAMICINFO.FMX',NO_HIDE,DO_REPLACE,NO_QUERY_ONLY,PL);
END;
RECEIVING FORM CODING;
Written on WHEN_NEW_FORM_INSTANCE
BEGIN
IF :PARAMETER.P_AT IS NULL THEN
GO_ITEM('NZK_HW_DYNAMIC.OS_ASSET_TAG');
ENTER_QUERY;
ELSE
SET_BLOCK_PROPERTY('NZK_HWSTATIC_INFO',DEFAULT_WHERE,'HWSI_ASSET_TAG ='||:parameter.p_at);
SET_BLOCK_PROPERTY('NZK_HWSTATIC_INFO',DEFAULT_WHERE,'HWSI_ASSET_TAG ='||:parameter.p_at);
EXECUTE_QUERY;
GO_ITEM('NZK_HW_DYNAMIC.OS_ASSET_TAG');
END IF;
END;
Created PARAMETER as P_AT, Data Type CHAR, MAX LENGTH 30
Thank you
NZK -
[Web Dynpro ABAP] - Passing a parameter between 2 windows
Hi!
I'm trying to do a web dynpro application that displays in a popup the result of a research.
Thus, I have:
- main_view embedded to main_window
- popup_view embedded to popup_window
In main_view, I have an input field where the user can enter a string. After clicking on the "search" button, the popup has to appear showing all matches corresponding to the user research.
In need to pass the parameter of the input field from main_view to popup_view but don't know how to do it.
Thanks for any help you can provide.
C.
Edited by: Cristina CHEN MA on May 18, 2009 1:24 PMThank you both for your time.
TO: Radhika Vadher
I tried your solution but I get an error message when using
lo_el_tresult->get_static_attributes_table
=> method unknown, protected or private
I used the wizard to get the node's attributes:
DATA : lo_nd_tresult TYPE REF TO if_wd_context_node,
lo_el_tresult TYPE REF TO if_wd_context_element,
ls_tresult TYPE wd_this->element_tresult.
* navigate from <CONTEXT> to <TRESULT> via lead selection
lo_nd_tresult = wd_context->get_child_node( name =
wd_this->wdctx_tresult ).
* get element via lead selection
lo_el_tresult = lo_nd_tresult->get_element( ).
* get all declared attributes
lo_el_tresult->get_static_attributes(
IMPORTING
static_attributes = ls_tresult ).
But I still have an error message:
ls_tresult is not an internal table "OCCURS n" specification is missing
Thanks again for any help you can provide =)
C. -
Extremely URGENT! How to pass a parameter from html to form?
Hi Guys,
I want to be able to pass a parameter to a Pre-Query trigger (from a html page to an Oracle form.) Right now, I hard coded the Pre-Query trigger
(i.e. set_block_property('datablock_name', default_where, 'tableName.fieldName = '||:datablock.field)
I want to be able to assign a value to the above datablock.field from an URL (i.e. something like http://localhost/dev60cgi/ifcgi60.exe?form=MODULE1.fmx&userid=&otherparams=fieldx=parameterSample
Does anyone know how to set that up within Oracle Forms. Thanks in advance.Hello. your you can create one it paginates similar to this...
<HEAD></HEAD>
<BODY >
<!-- Forms applet definition (start) -->
<OBJECT classid="clsid:86ecb6a0-400a-11d5-b638-00c04faedb18" codebase="/jinitiator/jinit.exe#Version=1,1,8,11" WIDTH="950" HEIGHT="560" HSPACE="0" VSPACE="0">
<PARAM NAME="TYPE" VALUE="application/x-jinit-applet;version=1.1.8.11">
<PARAM NAME="CODEBASE" VALUE="/forms60java/">
<PARAM NAME="CODE" VALUE="oracle.forms.engine.Main" >
<PARAM NAME="ARCHIVE" VALUE="f60all_jinit.jar, ComponentesEsigfa.jar" >
<PARAM NAME="serverPort" VALUE="9000">
<PARAM NAME="serverHost" VALUE="MyServer">
<PARAM NAME="serverURL" VALUE="/servlet/oracle.forms.servlet.ListenerServlet?ifcfs=/servlet/f60servlet?config=servlet&form=fca_menu.fmx&otherparams=ejercicio=<%=request.getParameter("ejercicio")%>&useSDI=yes&lookAndFeel=generic&colorSchema=teal">
<PARAM NAME="connectMode" VALUE="HTTP">
<PARAM NAME="serverArgs"
VALUE="module=fca_menu.fmx userid=<%= request.getParameter("login")+"/"+request.getParameter("pwd")+ "@" +request.getParameter("base")%> ejercicio=<%=request.getParameter("ejercicio")%>">
<PARAM NAME="separateFrame" VALUE="false">
<PARAM NAME="splashScreen" VALUE="no">
<PARAM NAME="backgroun[i]Long postings are being truncated to ~1 kB at this time. -
How to pass a parameter with more than one value to a report? (urgent)
Hi, all
I try to pass a parameter from a search form to a report in
which I would like to print out my search result. My problem is
I can pass the parameter to report but only one value which my
cursor points to. could anyone tell me how to pass a list of
value to the report? my trigger in form like this:
declare
PL_ID PARAMLIST;
sc_no books.c_no%type;
begin
PL_ID := GET_PARAMETER_LIST('parametername');
IF NOT ID_NULL(PL_ID) THEN
DESTROY_PARAMETER_LIST(PL_ID);
END IF;
PL_ID := CREATE_PARAMETER_LIST('parametername');
IF ID_NULL(PL_ID) THEN
MESSAGE('PL/SQL held against Button failed to execute');
RAISE FORM_TRIGGER_FAILURE;
END IF;
ADD_PARAMETER(PL_ID, 'PARAMFORM', TEXT_PARAMETER,'NO');
sc_no := :searchlist.c_no; --(c_no is the value I want to pass
but not only one.)
ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
RUN_PRODUCT(REPORTS, 'reportpathname.rep', SYNCHRONOUS, RUNTIME,
FILESYSTEM, PL_ID, NULL);
end;
Thank you in advance
DianaIs it your values in parameter NO separated by coma? And is it
parameter in where clause?
Do you want something like :
from table
where s_no in (NO) ?
If is answer "yes" you can create lexical parameter in report.
You can write in report sowething like:
select a.field1, a.field2,.....
from table a
&COND /* this is if is condition only one line after "from".
if you have more lien after where then you will put this &COND
in line where you want to have your multivalue.
Then in your trigger in form you should write:
sc_no := 'where a.sc_no in ('||:searchlist.c_no||')';
ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
/* again this is if you have only one line with WHERE ili
conditions */
or you will write:
sc_no := 'and a.sc_no in ('||:searchlist.c_no||')';
ADD_PARAMETER(PL_ID, 'pamametername', TEXT_PARAMETER, sc_no);
It will substitute line in which is your conditions with
multivalue.
Maybe you are looking for
-
SD Reports for checking open deliveries, incomplete sales orders?
Hi guys, I am searching for the following reports/ or tables with SQVI in the sap for SD Module: a) If there are Deliveries exist in the system for which invoicing have not been done. There are two types of cases: Delivery created but PGI not don
-
PDF shows background color as white. Prints black. HELP!
I'm trying to print the screen the way I see it which is a white background with black font and an image, but it won't. I went under preferences and accesibility and replaced document colors to black text and white background. However, it still print
-
The videos imported from iPad to Windows PC are reversed. How to fix it?
Hi, When i import the videos and photos from iPad to Windows PC using USB cable, the photos and videos are reversed. well i can reverse the photos from Windows photo editor, i am not able to see the proper videos. Its upside down. How do i fix it ? W
-
Print directly on AS400 (iSeries)
Hello I am using Jasper Report as reporting tool in my web application (using websphere as server). I try to print directly to a printer that is linked with the server. It works without any problem if the server is a PC. But if the server is an AS400
-
OSX 10.7.4 login items resetting
My macbook pro occasionally resets its login items, about once every month. Its getting more and more iritating so I'm hoping someone can suggest something. I'm running OSX 10.7.4. Thanks,