How to deduce type variable
First, sorry for my poor English.
This piece of code compiled with no problem nor errors.
interface Singularity<T> {
public T unique();
class UniqueArrayList<K, V extends Singularity<K> > {
Map<K, V> map = new HashMap<K, V>();
public void add(V value) {
map.put(value.unique(), value);
public boolean contains(K key) {
return map.containsKey(key);
class Dimension implements Singularity<String> {
public String unique() {
return null;
class Test {
UniqueArrayList<String, Dimension> list = new UniqueArrayList<String, Dimension>();
}My problem is simple, in this line:
UniqueArrayList<String, Dimension> list = new UniqueArrayList<String, Dimension>(); I need to specify both types K and V, but this is a burden: from definition of Dimension it is clear that K is String
How can i define UniqueArrayList in such way that K will be automatically deduced from V.
Thanks
Boaz
How can i define UniqueArrayList in such way that K will be automatically deduced from >V.I don't know if this is possible. But I have played around a little bit with your code and I think there is bug. Look at the following:
import java.util.HashMap;
import java.util.Map;
interface Singularity<T> {
public T unique();
class UniqueArrayList<K, V extends Singularity<K> > {
Map<K, V> map = new HashMap<K, V>();
public void add(V value) {
map.put(value.unique(), value);
public boolean contains(K key) {
return map.containsKey(key);
class Dimension<T> implements Singularity<T> {
private T unique;
public Dimension(T unique){
this.unique=unique;
public T unique() {
return (T)null;
public class Test {
public static void main(String[] args) {
Dimension dim=new Dimension<Integer>(new Integer(0));
Map<String, Dimension> map = new HashMap<String, Dimension>();
map.put(dim.unique(), dim);
UniqueArrayList<String, Dimension> list = new UniqueArrayList<String, Dimension>();
list.add(dim);
}When using the map the compiler complains about a not compatible method call. When using the array List he doesn't although I think he should.
I am not sure if this really is bug or if I missunderstand something about the genreics in Java.
Similar Messages
-
How to pass type variable in a procedure as IN parameter
CREATE OR REPLACE PROCEDURE APPS."QFJS_LMO_TIMESLOT_PROC"
a_std IN VARCHAR2,
TYPE str_table IS TABLE OF CLOB INDEX BY BINARY_INTEGER;
timeStr OUT str_table;
This is giving error!!
Please help!!This is what you're looking for? (you can also create the type in your database)
CREATE OR REPLACE PACKAGE APPS.MY_PACKAGE AS
PRAGMA SERIALLY_REUSABLE;
TYPE str_table IS TABLE OF CLOB INDEX BY BINARY_INTEGER;
PROCEDURE "QFJS_LMO_TIMESLOT_PROC"(a_std IN VARCHAR2,
post_std IN VARCHAR2,
a_time IN VARCHAR2,
post_hc IN NUMBER,
pre_hc IN NUMBER,
ods_schedule_date IN DATE,
timeStr IN OUT str_table);
END MY_PACKAGE;
CREATE OR REPLACE PACKAGE BODY APPS.MY_PACKAGE IS
PRAGMA SERIALLY_REUSABLE;
PROCEDURE "QFJS_LMO_TIMESLOT_PROC"(a_std IN VARCHAR2,
post_std IN VARCHAR2,
a_time IN VARCHAR2,
post_hc IN NUMBER,
pre_hc IN NUMBER,
ods_schedule_date IN DATE,
timeStr IN OUT str_table) IS
v_clob clob;
BEGIN
FOR i IN 1 .. timeStr.COUNT LOOP
v_clob := timeStr(i);
END LOOP;
END "QFJS_LMO_TIMESLOT_PROC";
BEGIN
NULL;
END MY_PACKAGE;
BEGIN
APPS.MY_PACKAGE.QFJS_LMO_TIMESLOT_PROC('1','2','3',4,5,sysdate,APPS.MY_PACKAGE.str_table('clob1', 'clob2', 'clob3'));
END;
/ -- Hugs, Philips -
How to convert element to mesasge type variable in BPEL
Hi,
I have xml message in element type variable. I want to create one variable of message type and have same elements values what element type variable has.
I modified my xsd and created of same type like element namespace. Now when i use assign activity to copy from top root another top root. I get error Variable not initialized.
How to correct?
My XML message is like
<CMISAPPL>
<APPLICANT_FULL_NAME>Abhi</APPLICANT_FULL_NAME>
<MANAGER_FULL_NAME>Jack</MANAGER_FULL_NAME>
<INTERVIEWER_FULL_NAME>jack</INTERVIEWER_FULL_NAME>
<JOB_TITLE>Test</JOB_TITLE>
<INTERVIEW_DATE>2-Oct-2007</INTERVIEW_DATE>
<PASSED_DAYS>5</PASSED_DAYS>
<INT_SCH_PROFILE_VALUE>1,2,4,7</INT_SCH_PROFILE_VALUE>
<FILE_PATH_PROFILE_VALUE/>
<PAPERWORK_REQ_SEGMENTS_VALUE/>
<PAPERWORK_REQ_SEGMENTS_NAME>App test</PAPERWORK_REQ_SEGMENTS_NAME>
<VACANCY_NAME>test</VACANCY_NAME>
<INTERVIEWER_EMAIL>t</INTERVIEWER_EMAIL>
<INTERVIEWER_MANAGER_EMAIL>t</INTERVIEWER_MANAGER_EMAIL>
</CMISAPPL>Looks like a namespace issue. There is no namespace defined in your payload.
Marc
http://orasoa.blogspot.com -
How to Populate a table type variable from a cursor
Hi
I have a stored procedure (P1) that returns a ref cursor as the output.
Another procedure (P2) receives this ref cursor (C).
In this procedure (P2), I want to do a Bulk Collect from this ref cursor (C) in
a table type variable that has been declared locally in the procedure P2. I have created appropriate Object Type and Table Types at the database level.
Please advise how to do it. I tried to do it in different ways, but was not able to do it - each time I faced incompatible data-type related issues.
Regards
MadhupWhat I wrote was unclear. Syntactically it is valid and does something. But consider the advantage of a decent design.
SQL> create or replace procedure p1 (o out sys_refcursor) as
2 begin
3 open o for select * from emp;
4 end p1;
5 /
Procedure created.
SQL> create or replace procedure p2(i sys_refcursor) as
2 type emp_tab is table of emp%rowtype;
3 l_emp_tab emp_tab;
4 begin
5 fetch i bulk collect into l_emp_tab;
6 close i;
7
8 for i in 1..l_emp_tab.count loop
9 NULL;
10 end loop;
11 end p2;
12 /
Procedure created.
SQL> CREATE OR REPLACE PROCEDURE p3 IS
2
3 TYPE myarray IS TABLE OF emp%ROWTYPE;
4 l_data myarray;
5
6 CURSOR r IS
7 SELECT * FROM emp;
8
9 BEGIN
10 OPEN r;
11 LOOP
12 FETCH r BULK COLLECT INTO l_data;
13
14 FOR j IN 1 .. l_data.COUNT
15 LOOP
16 NULL;
17 END LOOP;
18
19 EXIT WHEN r%NOTFOUND;
20 END LOOP;
21 CLOSE r;
22 END p3;
23 /
Procedure created.
SQL> set serverout on
SQL> set timing on
SQL> declare
2 r sys_refcursor;
3 begin
4 FOR i IN 1 .. 10000 LOOP
5 p1(r);
6 p2(r);
7 END LOOP;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.71
SQL> begin
2 FOR i IN 1 .. 10000 LOOP
3 p3;
4 END LOOP;
5 end;
6 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.21
SQL> Again sorry for being less than clear. -
How to pass table type variable into function from SQL*PLUS ?
How to pass a table type variable from sql*plus prompt into a function ?
Thanx in advance.Krishna,
Do you mean like this?SQL> DECLARE
2 TYPE t_tbl IS TABLE OF VARCHAR2(20);
3 l_sample_tbl t_tbl;
4
5 FUNCTION print_contents ( p_tbl IN t_tbl )
6 RETURN VARCHAR2
7 IS
8 l_string VARCHAR2(1000);
9 BEGIN
10 FOR i IN 1..p_tbl.COUNT LOOP
11 IF (i = 1) THEN
12 l_string := p_tbl(i);
13 ELSE
14 l_string := l_string || ', ' || p_tbl(i);
15 END IF;
16 END LOOP;
17 RETURN (l_string);
18 END print_contents;
19
20 BEGIN
21 l_sample_tbl := t_tbl();
22 l_sample_tbl.EXTEND;
23 l_sample_tbl(1) := 'one';
24 l_sample_tbl.EXTEND;
25 l_sample_tbl(2) := 'two';
26 l_sample_tbl.EXTEND;
27 l_sample_tbl(3) := 'three';
28 l_sample_tbl.EXTEND;
29 l_sample_tbl(4) := 'four';
30 l_sample_tbl.EXTEND;
31 l_sample_tbl(5) := 'five';
32 DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
33 END;
34 /
one, two, three, four, five
PL/SQL procedure successfully completed.
SQL> HTH,
T. -
How can I have both date and time for a Date type variable?
If I have a Date type variable: Date today=new Date(), Is it possible to also give the current time to "today" but still keep the type as Date?
I mean , for exmaple I want to store this "today" to database as Date type, and the value in database is "2007-05-05 13:30:13". I do not want to use SimpleDateFormat to do that, because I want to use Date type not String. Is that possible? how to implement this?I'd say he means you should use Timestamp to store
the time value, because that's what it's there for.
Because java.sql.Date is defined not to store a
time value.Correct. The OP should read the Javadoc for java.sql.Timestamp. -
How can I obtain an object-type variable in Forms 6i?
i create an object-type in oracle 8i database like this:
TYPE OBJ_TYPE_NUMBER AS OBJECT
FIELD1 NUMBER,
MEMBER PROCEDURE INIT, ...
i create a variable of this object-type in a stored procedure in Oracle 8i:
v_Number OBJ_TYPE_NUMBER(10);
and then call it's method:
v_Number.INIT;
it work's!
But when I try to compile a previous variable declaration
(v_Number OBJ_TYPE_NUMBER;) in Oracle Forms 6i I see only an error message.
So my question is How can I declare and use an object-type variable in Forms 6i?Hi,
the release after Forms 6i is Forms9i. Forms9i does have the PLSQL engine of Oracle 9.0.0.2 database which means that it should knwo how to handle object types in PLSQL.
Frank -
How to access the Custom Data type variable given in Expression edit control To and From LabVIEW
Hello, I would like to know how to access the custom data type variable given in the Espression Edit Control from LabVIEW and vice-versa
Say, the FileGlobals.Reference_Handle (Custom Data Type Variable) contains the
VISA I/O session (Which in turn contains VISA_DeviceName: String, Session: Number),
Channel1: Number and
Channel2: Number
I am expecting the user to give FileGlobals.Reference_Handle as the input at the ExpressionEdit Control in the edit screen of the VI Call.
I would like to know how to get the values of this custom data type to LabVIEW?
Say, if I have the Cluster in LabVIEW like VISA I/O session (Deive Name and Session Number), Channel1 and Channel2
how do i need to set this cluster to the Custom Data type variable in TestStand?
Thanks and Regards
PrakashHi,
TestStand to LabVIEW: i didnt understand what you r trying to achieve. But if you are using references, Use Property nodes and Invoke nodes to achieve what you want in LabVIEW.
LabVIEW to TestStand: check the image below: You need to click the button next to 'container'. I have used a cluster output in the VI.
Hope this helps
.......^___________________^
....../ '---_BOT ____________ ]
...../_==O;;;;;;;;_______.:/
Attachments:
1.JPG 187 KB -
How to insert into table type variables
hi all,
how to assingn values to table type variable, i am getting error.
declare
dept1 dept%rowtype;
begin
dept1:=(100,'SHIPPING','HYDERABAD');
end;
ERROR at line 4:
ORA-06550: line 4, column 8:
PLS-00382: expression is of wrong type
regards,
Sri Ram.You can do like this
declare
dept1 dept%rowtype;
begin
dept1.deptno := 10;
dept1.dname := 'IT';
end;
/ -
I want to write record type variable in ult file.How to i can write record type varable without column name.
type rec_format_type is record
format1 VARCHAR(3),
format2 VARCHAR(3),
my_record rec_format_type;
UTL_FILE.PUT_LINE(file_out, my_record);ibney wrote:
I have below requirement.
DECLARE
emp_data UTL_FILE.FILE_TYPE;
BEGIN
emp_data := UTL_FILE.FOPEN ('EXDATAPUMP','TEST_BC_NN_PARALLEL.csv','W',32000);
FOR TEST1 IN (SELECT /*+ PARALLEL(TEST_BC_NN,4) */ * FROM TEST_BC_NN) LOOP
UTL_FILE.PUT_LINE (emp_data, TEST1);---Here i want to write record in utl file.without knowing the structure of table
END LOOP;
UTL_FILE.FCLOSE (emp_data);
END;
Why all the ugly upper case? You do realise that NO programming standard, ranging from Java and .Net, to C/C++ and Ada (of which PL/SQL is an implementation of), use upper-case-for-reserved-words as a standard.
The easiest and simplest way to address your requirement is as follows:
SQL> create or replace type TStringArray is table of varchar2(4000);
2 /
Type created.
SQL>
SQL>
SQL> begin
2 for c in(
3 select
4 TStringArray(
5 to_char(empno,'000000'),
6 ename,
7 to_char(hiredate,'yyyy-mm-dd')
8 ) as COLS
9 from emp
10 order by empno
11 ) loop
12 for i in 1..c.Cols.Count loop
13 dbms_output.put( c.Cols(i) ); -- write column
14 if i < c.Cols.Count then
15 dbms_output.put( '|' ); -- write column separator
16 end if;
17 end loop;
18 dbms_output.put_line( ' *end*' ); -- write record terminator
19 end loop;
20 end;
21 /
007369|SMITH|1980-12-17 *end*
007499|ALLEN|1981-02-20 *end*
007521|WARD|1981-02-22 *end*
007566|JONES|1981-04-02 *end*
007654|MARTIN|1981-09-28 *end*
007698|BLAKE|1981-05-01 *end*
007782|CLARK|1981-06-09 *end*
007788|SCOTT|1987-04-19 *end*
007839|KING|1981-11-17 *end*
007844|TURNER|1981-09-08 *end*
007876|ADAMS|1987-05-23 *end*
007900|JAMES|1981-12-03 *end*
007902|FORD|1981-12-03 *end*
007934|MILLER|1982-01-23 *end*
PL/SQL procedure successfully completed.
SQL> -
SSIS Programming- How to declare a variable of type Object?
Hello, I have a very specific coding question. I am trying to create a pkg using SSIS Object model. I am trying to create a variable of type Object. But I could not find any reference in KB or forums on creating variable of this data type.
Example:
// Create the package.
Application a = new Application();
Package p = new Package();
p.Name = "MyDataExtractPkg";
//Add Variables to the pkg
Variables pkgVars = p.Variables;
Variable var8 = p.Variables.Add("varHour", false, "User", (System.Int16)0);
Variable var9 = p.Variables.Add("varHourDiff", false, "User", 0);
Variable var10 = p.Variables.Add("varIntervalWaitInMS", false, "User", 5000);
Variable var11 = p.Variables.Add("varJobCnt", false, "User", 0);
Variable var12 = p.Variables.Add("varjobID", false, "User", 0);
Variable var13 = p.Variables.Add("varJobRS", false, "User", (System.Object)0);
Variable var14 = p.Variables.Add("varProcessDate", false, "User", "abc");
As you can see I was able to successfully variables of Type Int16, Int32(default) & String.
But I need to create a variable of type Object for "varJobRS" and above code is generating int. Appreciate any direction or help on how to create Object variable type.
Thanks,
DW GuyI have been continuing with my work with intention to approch MS, but I came across the solution in one of the Blog site. The solution is :
var13.Value =
new
Object();
This converts the variable of type Object.
The link that gave this soluion is:
http://ssisbi.com/building-ssis-packages-programmatically-part-5/
Thanks,
DW Guy -
How to set a date type variable to null, nothing or such
I created an User Defined Type that holds a Deadline property which is date type. Whenever there is no Deadline set yet, I would like such property to be set to Null, Nothing or such. I noticed that if I just Dim a Date Type variable its value will be
already set to 12:00 AM, and the same value takes place if I set the variable to a blank cell value. Any ideas to get around of this problem?
Jorge Barbi Martins ([email protected])A variable of type Date cannot be empty. Its default value is 0, which corresponds to Midnight on 30 December 1899.
If you want to be able to make it empty, declare it as Variant instead of as Date. You can then set its value to Null.
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
How to pass session variable value with GO URL to override session value
Hi Gurus,
We have below requirement.Please help us at the earliest.
How to pass session variable value with GO URL to override session value. ( It is not working after making changes to authentication xml file session init block creation as explained by oracle (Bug No14372679 : which they claim it is fixed in 1.7 version Ref No :Bug 14372679 : REQUEST VARIABLE NOT OVERRIDING SESSION VARIABLE RUNNING THRU A GO URL )
Please provide step by step solution.No vague answers.
I followed below steps mentioned.
RPD:
****-> Created a session variable called STATUS
-> Create Session Init block called Init_Status with SQL
select 'ACTIVE' from dual;
-> Assigned the session variable STATUS to Init block Init_Status
authenticationschemas.xml:
Added
<RequestVariable source="url" type="informational"
nameInSource="RE_CODE" biVariableName="NQ_SESSION.STATUS"/>
Report
Edit column "Contract Status" and added session variable as
VALUEOF(NQ_SESSION.STATUS)
URL:
http://localhost:9704/analytics/saw.dll?PortalGo&Action=prompt&path=%2Fshared%2FQAV%2FTest_Report_By%20Contract%20Status&RE_CODE='EXPIRED'
Issue:
When I run the URL above with parameter EXPIRED, the report still shows for ACTIVE only. The URL is not making any difference with report.
Report is picking the default value from RPD session variable init query.
could you please let me know if I am missing something.Hi,
Check those links might help you.
Integrating Oracle OBIEE Content using GO URL
How to set session variables using url variables | OBIEE Blog
OBIEE 10G - How to set a request/session variable using the Saw Url (Go/Dashboard) | GerardNico.com (BI, OBIEE, O…
Thanks,
Satya -
@ Decimal Places in Packed Type Variable
How to check if a packed type variable has decimal placed or not?
Hi,
Try to use the statement DESCRIBE. See the help to understand the usage. The syntax is:
DESCRIBE FIELD <field> DECIMALS <dec>.
This will show the number of decimals place.
Then, you can use a condition to test.
Regards
RP -
How to create Presentation variable for columns and to use it in Narrative?
Hi All,
Anybody know how to create presentation variable for a column (i.e., i need to create it in edit formula section itself). And then, I should use it in Narrative section to display that column value. Is it possible? Or do i need to use any other variable for this requirement? If so please let me know, how to create it? This is very urgent requirement.
Thanks in Advance
ThenmozhiHi Satya,
I just want to create a table that should horizontally display the values like below:
SUID Tag # :123456 Year Mfg: 2007
Description: computer corporation FA ID#: 4576
Model Number: 4569 hESC: #ert
Serial Number: 78945 Flags: c
Department: Hematology
User: thenmozhi
Database: OLAP
I think we can create this type of report using either Narrative or Static Text. But I am not sure whether it is possible or not? And also another thing is that sectioning is applied for SUID Tag # column. So, depending on the dashboard prompt if the SUID Tag # retrieves two or more values.
Then the first value for example 123456 and the values for the other columns related to this SUID Tag # value should display in the first page (i.e., page 1). And if the next value of the SUID Tag # for example say 678901 then the values should move to second page that is like this:
SUID Tag # :678901 Year Mfg: 2008
Description: Computer Manufacturing FA ID#: 4577
Model Number: 4570 hESC: #eth
Serial Number: 78946 Flags: G
Department: Hematology
User: Rehman
Database: OLAP
Thanks
Thenmozhi
Maybe you are looking for
-
Upgrade from 4.6C to ECC6.0 - development quality and production
Upgrade from 4.6C to ECC6.0 I have got three systems right now... Development(D1) Quality(Q1) Production(P1). These three systems need to be upgraded to ECC6.0 The recommended process is to copy D1 to a new temporary server(D2) and then upgrad
-
Flash video image problem with newest nVidia driver
I've got a very weird display error since the last update. Basically, whenever I play flash video and afterwards close the browser (chromium), any purely black surfaces will display the full flash player image. The effect is only visible in the "firs
-
Write to pdf generating text as images
I am using Windows 8 Billquick 2014 (project management software) and Adobe acrobat pro XI. When I try to print a document of text + logo, some of the text does not print to text in the pdf - ie if I open the pdf the text is blurry, and not able to
-
How Do I Get back scroll bar arrows Back
Is there a way to get back scroll bar arrows back in OS 10.8.4 ? Thats all.
-
I am curious about importing images into FCP. I understand that pixels in an image are square and that in video they are rectangular. When I import an image into FCP it looks great, until I export and then they take on a "fatter" look. I know that wh