Variables collection using
Could Hi you please help me with grouping variable values (output of the query)Here's the example I tried, but confusing to use the record variable.
CREATE OR REPLACE PACKAGE Pkg_test
IS
----- Record Variable ----
TYPE rec_job IS RECORD
( job1 varchar2(50),
job2 varchar2(50),
Rank varchar2(50)
);
TYPE typ_job IS TABLE OF rec_job
INDEX BY VARCHAR2(500) ;
---- Procedure Declaration ----
PROCEDURE proc_job ( p_d1 IN number, p_d2 number
o_Rat OUT typ_job );
END Pkg_test
CREATE OR REPLACE PACKAGE BODY Pkg_test
IS
PROCEDURE proc_job ( p_d1 IN number default 10, p_d2 number default 20
o_Rat OUT typ_job )
IS
BEGIN
select e1_job,e2_job,
case when e1_job =e2_job
then '0'
else '1'
end as Rating into O_RAT -- How to use this collection variable
from (
select distinct e1_job,e2_job , rank () over (partition by e1_job ,e2_job order by e1_SAL )rn
from
(select e1.job e1_job,e1.sal e1_sal,e2.job e2_job from
emp e1 , emp e2 where e1.deptno =p_d1 and e2.deptno =p_d2 )
) where rn =1
order by 1,2
-- How can i keep e1_job ,e2_job ,Rating values into the collection variable o_Rat.
-- Could you hint me to do this
end;
Thank youPublished by: Smile on 7 may 2012 10:50
So many errors in the package Spec and body.
To extract the records in a grouping variable use COLLECT in BULK
See code below. I used the employees table. First of all try to understand the ESSENCE of COLLECT concept and then read below is the code.
CREATE OR REPLACE PACKAGE Pkg_test
IS
----- Record Variable ----
TYPE rec_job IS RECORD
( job1 varchar2(50),
job2 varchar2(50),
Rank varchar2(50)
);
TYPE typ_job IS TABLE OF rec_job;
---- Procedure Declaration ----
PROCEDURE proc_job ( p_d1 IN number, p_d2 number,
o_Rat OUT typ_job );
END Pkg_test;
-- Package Body
CREATE OR REPLACE PACKAGE BODY Pkg_test
IS
PROCEDURE proc_job ( p_d1 IN number, p_d2 number, o_Rat OUT typ_job )
IS
-- Declare collection variable
l_typ_job typ_job;
BEGIN
select e1_job,e2_job,
case when e1_job =e2_job
then '0'
else '1'
end as Rating BULK COLLECT into l_typ_job -- How to use this collection variable
from (
select distinct e1_job,e2_job , rank () over (partition by e1_job ,e2_job order by e1_SAL )rn
from
(select e1.job_id e1_job,e1.salary e1_sal,e2.job_id e2_job from
employees e1 , employees e2 where e1.department_id =p_d1 and e2.department_id =p_d2 )
) where rn =1
order by 1,2;
o_Rat:= l_typ_job;
END proc_job;
end;
Tags: Database
Similar Questions
-
How to locate where the shared Variables are used in the project.
I'm looking everywhere where a shared Variable is used in my project. Right-clicking does not provide a find. The display hierarchy does not help. In the Project Explorer, the appellants find displays only the names of the screw called, not the many places where the call is made.
Does anyone know how to find the location where a shared Variable is used?
Edit-> find and replace. For "Select object" click and access features-> Structures-> shared Variable.
-
How do I know where a variable was used?
How can I tell where a variable is used in a procedure of interface/package /?
Should I check using internal tables from the repository?
Thank you
Hello
You must do some queries to find the variable used in ODI object.
as he retrieves the variable with the name of the scenario and scénarion can meet your need.
Select v.i_var, v.var_name, s.scen_name of
ODEV91119_ODI_WORK.snp_var v, ODEV91119_ODI_WORK.snp_scen s
where
s.i_var = v.i_var
and s.scen_NAME = 'V_BTCH_NAME'
and agree with the answer SH
Thank you
-
Creating a variable to use in Javascript
I created a website with a search function where the user can use the drop down menus. It is in a small window that opens when you click on advanced search. They choose the first descent down, then the next menu drop down appears and has inside elements depending on what was chosen in the first menu drop-down. This works, except that it works on our www. site. If you do not type in the www., these drop-down menus do not work. These drop downs using Javascript and in this javascript, I have the full path of our web site to the .cfm file where it's more javascript to the bottom of the fall. This path has the www. in it. Does anyone know how I can write this while the two lanes or paths work - with and without the www. ? Do I need to set up some kind of variable to use? How to do that in Javascript. I think I can do it in Cold Fusion, but I don't think it will work in javascript. The web site is www.ironwoodelectronics.com here is the JavaScript below. Thank you.
Andy
<script>
function getICNumber() {
$('#ICNumber').load("http://www.ironwoodelectronics.com/incICNumber.cfm",{ManufacturerID:$('#select_ManufacturerID').val()});
}
function getPackage() {
$('#Package').load("http://www.ironwoodelectronics.com/incPackage.cfm",{ManufacturerID:$('#select_ManufacturerID').val(),ICNumber:$('#select_IC_Number').val()});
}
function getPackageType() {
$('#PackageType').load("http://www.ironwoodelectronics.com/incPackageType.cfm",{FunctionID:$('#select_FunctionID').val()});
$('#Pitch').html("");
}
function getPitch() {
$('#Pitch').load("http://www.ironwoodelectronics.com/incPitch.cfm",{FunctionID:$('#select_FunctionID').val(),PackageID:$('#select_PackageID').val()});
}
function getBody() {
$('#Pitch').load("http://www.ironwoodelectronics.com/incPitch.cfm",{FunctionID:$('#select_FunctionID').val(),PackageID:$('#select_PackageID').val(),PitchID:$('#select_PitchID').val()});
}
function getArray() {
$('#Pitch').load("http://www.ironwoodelectronics.com/incPitch.cfm",{FunctionID:$('#select_FunctionID').val(),PackageID:$('#select_PackageID').val(),PitchID:$('#select_PitchID').val(),BodyID:$('#select_BodyID').val()});
}
</script>You have two errors.
First of all, you have any hash of escape characters (#) located in CFOUTPUT which are not used for CF to output variables. Escape you by doubling their:
$('#ICNumber').load
should be
$('##ICNumber').load
Second, CGI. HTTP_HOST contains only the host, Protocol, etc. So, you have to do something like this:
$('##ICNumber').load ("http://#cgi.http_host#" "/...")
Dave Watts, CTO, Fig Leaf Software
Fig Leaf Software is a small business Veteran - Owned (VOSB) on
GSA Schedule and provides high caliber of the authorized seller
instruction at our training centers, online, or on-site.
Read this before posting:
-
Hi guys!
I'm trying to code a (variable) password using agent.s. My command looks like this:
And all I get is 255: code wrong process..../agent.sh encode #VARIABLE
Why is this?
Please help the gurus of ODI.
Kind regards
PsmakRHi guys,.
I would try to help.
Yes, it is possible to pass encrypted via an ODI variable values.
So simple as:
(1) create a package which, at runtime (for example), to receive the password
(2) create a procedure that receives this variable and use the command 'agent enconde #odivariable' in a file
(3) update the encrypted value generated in the variable (see [http://odiexperts.com/?p=243])
(4) now just use this variable directly in the tab order of the ftp tool and does not change the GUI (first tab) after that.
Works?
Cezar Santos
[www.odiexperts.com] -
I want to host my shared on a cRIO Variables, but use DSC to recording/alarm/SCADA
Hello world
What I try to do is the following:
-Host variable static on my goals of RT (cRIO-9022) for reliability
-Use the DSC module to log on to the database, followed by alarms, develop a distributed HMI
The problem that I am running is that the engine of the DSC (seems) should the shared variables, it is taken to be hosted on this computer. The DSC engine cannot run on a real-time target.
My ultimate goal is to create a wide network of the plant of the cRIO which are all connected to a central PC/server that runs DSC to collect and store data in a database. The HMI plant would also connect to the central server and get their information from there (not directly related to the process of cRIO). Is it possible / have ideas on how to do this effectively?
Thanks for the help.
I have a similar architecture. I host my NSV libraries on of my cRIO and then create linked libraries 'mirrors' on the host computer that is running my HMI and logging of DSC in my database of the Citadel. The project of LV has a tool to create related libraries. I have also written a tool create me a library cloned with the original library on the cRIO liaison. The NI PSP Protocol makes this type of very effective bound library.
-
Bulk collect using some different column insert a table
Hi all
I gave an example of emp table in my original 100 million table record are I need to change group (IE deptno) 10 to 20 copy the same records
about these codes, I get exception
ORA-06550: line 11, column 53:
PLS-00386: concordance that is 'EMP_TAB' between FETCH cursor and IN variables of type
can help me please for these
declare
type row_tab is table emp % rowtype
INDEX BY PLS_INTEGER;
emp_tab row_tab;
cursor cur_emp is select ENAME, 20 DEPTNO, HIREDATE, emp COMM EMPNO;
Start
Open cur_emp;
loop
Cur_emp fetch bulk collect in the limit emp_tab 2000;
ForAll i in 1.emp_tab. COUNTY
Insert / * + APPEND * / into emp (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)
values (emp_tab (i). EMPNO, emp_tab (i). Ename, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.) ;
When the output cur_emp % notfound;
END LOOP;
close cur_emp;
end;
/
Thank you
VSM
I use the user define the type of record to over come error
declare
type emp_rt is record (empno, ename emp.ename%type,deptno NUMBER (2) emp.empno%type, hiredate emp.hiredate%type,comm emp.comm%type);
TYPE row_type IS the emp_rt INDEX TABLE OF pls_integer;
emp_tab row_type;
cursor cur_emp is select empno, ename, 20 deptno, hiredate, comm from emp where deptno = 10;
Start
Open cur_emp;
loop
Cur_emp fetch bulk collect in the emp_tab limit 2;
ForAll i in 1.emp_tab. COUNTY
Insert / * + APPEND * / into EMP (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)
values (emp_tab (i). EMPNO, emp_tab (i). ENAME, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.)
;
When the output cur_emp % notfound;
END LOOP;
close cur_emp;
end;
/
records are successful inserted, I do not know is not the right approach for 100 million documents?
Thank you
VM
-
Hello
I'm using the version of oracle 11g.
How can I access the data in the table variable V_emp?
Set serveroutput size unlimited
declare
type emp_type is table emp % rowtype
index of directory;
v_emp emp_type;
Start
Select emp.* bulk collect into v_emp
EMP;
because me in 1.v_emp.count
loop
dbms_output.put_line (How can I display all the data in the v_emp array variable?);
end loop;
end;
/
Thank you
DECLARE
CURSOR c1 IS (SELECT * FROM emp);
TYPE typ_tbl IS TABLE c1% rowtype;
v typ_tbl;
BEGIN
OPEN c1;
LOOP --Loop added
C1 FETCH BULK COLLECT IN v LIMIT 3; -treat 3 records at a time
-treat the first 3 max records
DBMS_OUTPUT. Put_line ('Treatment' | v.COUNT |) "documents.");
I'm IN v.first... v.Last LOOP
DBMS_OUTPUT. Put_line (v (i) .empno);
END LOOP;
OUTPUT WHEN c1% NOTFOUND;
END LOOP;
DBMS_OUTPUT. Put_line ('all done');
END;
-
Package global Variable - Collection - Associative Aray
All,
What we are doing is...
(1) fill us tab_emp_sal_comm with big collect and browse in a loop.
(2) check if the deptno success is available in the tab_emp_sal_comm collection.
(3) if it is available to fill a collection called tab_emp_sal_comm_1 and push corresponding only files inside.
(4) of the corresponding collection, we want to fill at the table of global collection of package which is again of the same type.
(5) by default for each new call old values are replaced, but I want to add the global variable at each call and finally do a big update to the corresponding tables.
(6) l_deptno will be a parameter and values will change at each call of this procedure in the code in real-time.
For the sake of ease, given an example simulated the EMP table. Goal is to add the global table in the package. Because each call, the previously loaded values are replaced. I want them to be available and additional calls should only add the values in the next set of lines instead of over writing.
How to achieve it, please discuss.CREATE OR REPLACE PACKAGE employees_pkg IS type rec_sal_comm is record(esal emp.sal%type, ecomm emp.comm%type,edeptno emp.deptno%type); type at_emp_sal_comm is table of rec_sal_comm index by pls_integer; pkg_tab_emp at_emp_sal_comm; pkg_tab_emp_1 at_emp_sal_comm; END; / -- Block Starts declare -- Local variables here type emp_sal_comm is record( esal emp.sal%type, ecomm emp.comm%type, edeptno emp.deptno%type); type at_emp_sal_comm is table of emp_sal_comm index by pls_integer; tab_emp_sal_comm at_emp_sal_comm; tab_emp_sal_comm1 at_emp_sal_comm; l_deptno dept.deptno%type := 30; l_comm number(7, 2) := 0; M_CNTR NUMBER(7, 2) := 0; begin select sal, comm, deptno bulk collect into tab_emp_sal_comm from emp; for indx in 1 .. tab_emp_sal_comm.count loop if tab_emp_sal_comm(indx).edeptno = l_deptno then tab_emp_sal_comm1(indx).ecomm := tab_emp_sal_comm(indx).ecomm * 0.5; tab_emp_sal_comm1(indx).esal := tab_emp_sal_comm(indx).esal * 0.75; end if; end loop; dbms_output.put_line(tab_emp_sal_comm1.count); dbms_output.put_line('**'); m_cntr := tab_emp_sal_comm1.FIRST; loop exit when M_CNTR is null; -- dbms_output.put_line(M_CNTR || ' ** ' ||nvl(tab_emp_sal_comm1(M_CNTR).ecomm, 0)); employees_pkg.pkg_tab_emp(m_cntr).ecomm := tab_emp_sal_comm1(M_CNTR) .ecomm; employees_pkg.pkg_tab_emp(m_cntr).edeptno := tab_emp_sal_comm1(M_CNTR) .edeptno; employees_pkg.pkg_tab_emp(m_cntr).esal := tab_emp_sal_comm1(M_CNTR).esal; m_cntr := tab_emp_sal_comm1.next(m_cntr); --- other computations and calculations made based on the matched records end loop; employees_pkg.pkg_tab_emp_1 := employees_pkg.pkg_tab_emp; -- dbms_output.put_line('**'); -- dbms_output.put_line(employees_pkg.pkg_tab_emp_1.count); end; -- Code will work in a Scott Schema with Emp Table.
Hi Ramarun,
(1) operator MULTISET, AFAIK, is to always give a dense nested table. To create a sparse nested table, the only way is to delete some items with the DELETE method.
(2) using the 1... NesTableVar.count is valid only when the collection is dense. With the release of MULTISET UNION you won't have a problem. But if you have a loop in a rare collection, you must use another method.
Below is an example:declare type t_set is table of number; set1 t_set := t_set(1,2,3,4,5,6,7,8,9,10); idx integer; begin -- make collection sparse set1.delete(3); set1.delete(7); idx := set1.first; while idx is not null loop dbms_output.put_line('Set('||idx||'): '||set1(idx)); idx := set1.next(idx); end loop; end; / Output: Set(1): 1 Set(2): 2 Set(4): 4 Set(5): 5 Set(6): 6 Set(8): 8 Set(9): 9 Set(10): 10
(3) you can use FORALL update/insert/Delete with the help of a nested table. It is dense, you can use 1... NesTableVar.count, if it is rare, then you must use another method as explained here.
Kind regards.
AlPublished by: Alberto Faenza on 2 December 2012 13:35
-
Hi all
I want to create a copy of the collection arraycollection from a table of existing collection variable.
but when I change the collection newly created arraycollection variable that is showing the other oldest.
How can I protect the changes the new is does not reflect the older one.
I use the code below
var aa:ArrayCollection = new ArrayCollection();
var aa1:ArrayCollection = new ArrayCollection (aa.source.concat ());
Thanks in advance;
Hi Niranjan,
You can make use of ObjectUtill class to clone, or make a copy of a collection arraycollection.
In the forum, he is also already talked several times...
var aa:ArrayCollection = new ArrayCollection();
var aa1:ArrayCollection = ObjectUtil.copy (aa) like collection ArrayCollection;
If this post answers your question or assistance, please mark it as such.
Thank you
Jean Claude Chari
-
I collect a quadrupole encoder using CounterReader and AsyncCallback. At any time, I would like to know how much value is currently stored/collected before receiving the AsyncCallback and calling EndReadMultiSampleDouble.
Hi MYR.
If I understand what you're asking, you should try the DaqStream.AvailableSamplesPerChannel property:
If you perform a task of counter entry in the buffer, then this property can be used to query the number of samples available in the input buffer that have not yet been read in the application memory.
Best regards
John
-
Conversion from decimal to octal variables labels using TestStand expression?
Hi all
I am currently using TestStand for read and write ARINC data for my application. Now, the card of the ARINC does only decimal values, so I have to convert all decimal octal labels and set them in TestStand, such that the map of the ARINC accepts it. So, when I read the variables that come out, I their name for the log file, but I need to convert the decimal values in octal labels such as test operators should not be confused.
Overall, I need to know is it an expression to take the decimal value and convert it to octal in the space of expression?
Thank you!
Convert to octal string: Str (Locals.Local, '%#o')
Remove # if you do not want the radix prefix.
Convert to decimal string if you want an integer:
Str (Locals.Local, "%I")
or for floating point:
Str (Locals.Local, '%g")
Hope this helps,
-Doug
-
With the help of semaphore with a Global Variable - correct use?
Hi all
I looked in the use of global variables and in my case, it seemed with the help of a semaphore is the appropriate solution.
In my case, I use a global variable to store the State of the system. Asynchronous two with screw environment (same VI) will follow two COM ports to see if they get a ' login:' command prompt. If the COM port is associated with Alpha, Charlie, or Echo, it increments by 1, and if it is associated with the Bravo, Delta, or Foxtrot, is incremented by 2 GV. If the GV is 3, the rest of the code will run. In this case, it must be a port COM A, C or E; the other should be B, D or F.
A VI parent is called inside a loop. He works for the first loop. He never adds up to 3 on the second loop, however. I can't understand why. Please let me know if my code is a poor use of semaphores, or if there is debugging I can try.
I'm still relatively new to LV, so I'm sorry if my screws are difficult to read. I created this in LV2011.
Thanks for any help!
CelerityEDS wrote:
The output of my time looping (wait GV = 3) goes to the structure of the case on the bottom right (clear SGS, PasswordEntry, etc.), so the GV get indeed consulted by the upper case structure right.
??
Your right upper case structure does not run until your time ends in a loop. The while loop does not stop until the total is equal to 3. Where can increment you the world besides structures case you cannot yet?
Have you tried in your point culminating execution of the VI in order to see how they are actually running?
Another problem that I see. Assuming that your first while the loop is going to end. In the structures of your case, you lock the semaphore. But you can never unlock the semaphore unless you have the right combination of conditions that allow you to get to the case that unlocks the semaphore. The conditions are based on data that are read before the start of the case of structure, which means that data will not be read and changed until it all ends. You have the timeout of your lock semaphore connected on one of the cases, but your semaphore lock can never timeout because you do not have a value on his entry time-out. I think you have a situation where you can lock a semaphore, then arrive at a situation where you can not unlock, then wind locking up of your cold code.
I don't really think that you need a semaphore at all. I think you can protect reading and writing functional your overall using a global variable, i.e. the motor action. Overall, I think you need to rethink the architecture of your code.
-
OBI, variable presentation using results
Hello!
I have the text field with long text strings.
I want to get results, using the filter "contains all" by this field
Example:
Values aaaa000 aa000aa bbbaa I have entry to filter "a0" and I want to get results according to:
Values aaaa000 aa000aa If the filter field will be empty, I get the error, but I want to get all the rows in the result.
How can I do?
I did the following:
1. in the analysis I marked new filter, type "CONSTAINS ALL". ": number" used as a variable presentation
2. I did new dashboard prompr, where I did prompt variable, named ": number", type "Variable presentation."
3. I did the new dashboard, where I dragged my dashboard prompr and analysis
Now, when the filter-field 'number' is empty, I get the error (and I agree with OLIVIER, because I did not specify the terms of null value):
And when I write all values in the filter field, everything works
I tried to fix it in the analysis, used 'Convert this SQL filter' and wrote the following sql text:
"presentation_tmp"."WB_NUMBER" LIKE CASE WHEN @{:number} IS NULL THEN "presentation_tmp"."WB_NUMBER" ELSE concat(concat('%',@{:number}),'%') END
But it did not help me
How can I get all the lines, when the filter-field 'number' is empty?
Hello
Not really sure how you get this error when the field is empty (you should only get no result) but if you change your filter in the report to:
WB_NUMBER contains all @{: number}
TO
WB_NUMBER contains all @{: number} {%}
You should get all the values when you do not have any value in the dashboard line. Basically, put '%' in the default value of your filter.
-
SQL how to use a variable and use the result as a reference for the name of the table
Hi all
I have new in the declaration of Oracle, sorry in advance if something is easy for you all. BTW, I have this scenario:
I have a table OL structured in this way:
Date - it contains dates, for example 11/01/2015
TableName - it contains strings, for example, OL1, OL2, OL3 and so on...
Then I have a different table, the name of these tables are of the same name in the table of the OL, so I have table table, OL1, OL2, OL3 table and so on. The structure of these tables is the same. And Yes.
table OL1
---------------------------------------------------------------
ID LAST NAME FIRST NAME PHONE
---------------------------------------------------------------
1 JOHN DOE 12345679
2 PAUL 111111122 TIBBS
table OL2
---------------------------------------------------------------
ID LAST NAME FIRST NAME PHONE
---------------------------------------------------------------
1 ANNA KRAIG (NULL)
NATHAN FRESHMANN 111111133 2
If the scenario is clear, I would like to retrieve the value (null), research in all the OL * tables by using the value of the OL table (tablename) max.
If I'm going to do these simple steps, I got the result:
Select max (TableName) OL
the result will be OL2
# I know not how to use the option set to avoid changing the table name in the sql statement all the time.
set mytable = 'OL2.
Select Name, family name
of & mytable
When the phone is null
Any idea?
Thank you very much in advance.
Hello
run immediately "select dt.log_id, obj.presentation_name, dl.begin_time
bulk collect into v_result_set
of ' | v_ol |' dt join internal ol_object obj on
DT.object_type_id = obj.object_type_id
inner join ol_chunk_log dl on
DT.log_id = DL.log_id
where dt.data_value is null';
dbms_output.put_line (v_ol);
end;
Correct the code such as:
run immediately "select dt.log_id, obj.presentation_name, dl.begin_time
of ' | v_ol |' dt join internal ol_object obj on
DT.object_type_id = obj.object_type_id
inner join ol_chunk_log dl on
DT.log_id = DL.log_id
where dt.data_value is null' bulk collect into v_result_set;
for i in v_result_set.first ... v_result_set. Last
loop
dbms_output.put_line ('LOG ID: ' | ) ( v_result_set.log_id (i)) ;
dbms_output.put_line (' NAME CLOSELY: ' |) v_result_set.presentation_name (i));
dbms_output.put_line (' START TIME: ' |) ( v_result_set.begin_time (i)) ;
end loop;
end;
Kind regards.
Maybe you are looking for
-
Qosmio G30-175: DVD player - RAM, it's a CD player
Hello people, I once again. My 2 week old Qosmio G30 - 175 has a DVD-RAM drive that now appears in my computer as a CD player. As a result (I think) it will not automatically DVD playback. I can play manually through the media library or WMP, but no
-
Cisco E3000 Cascded Configuration.
I would appreciate any guidance on how to configure my Cisco E3000 to use in the configuration of the attachment. I can't the router to work. He negotiated the link with the bridge, but there is no connectivity to the internet wireless or wired. Tha
-
The error message is Windows telling me it will find a solution and warn me, however, I do not get a message for me to rectify the problem.
-
Error installing quicken on vista 2.0
I have an old Quicken 2.0 prgram that I really need to install on my computer. I have a gateway GT5428 PC with Windows Vista Home Premium. When I try to install Quicken 2.0 I get an error message "file system (COMMDLG reading." (DLL) removed but not
-
Printer is not working on Windows 8
Hello. I recently got a new laptop running window 8. (I HATE IT) as im not very technical to begin with. Its driving me crazy. Someone suggested downloading the classic interface, I think 'a bit' better, but even that's confusing to me. My main issue