Select the column values in the collection
Greetings,I want to select column values from the collection (plsql tables or table), as the following code, would it be possible
Here tt is any collection
Select emp_no, name, date of birth, sal tt (1), tt (2), tt (3), tt (4) emp; -single line query
Select name, Department of justice, strength and dep_no in tt (5), tt (6), tt (7), tt (8) EMP; -single line query
Version
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
Thanks in advance
Not sure about your business needs. But technically you can do.
declare
type tbl is table of number;
lemp tbl := tbl();
begin
lemp.extend;
lemp.extend;
lemp.extend;
select empno
, mgr
, sal
into lemp(1)
, lemp(2)
, lemp(3)
from emp
where empno = 7369;
for i in 1..lemp.count
loop
dbms_output.put_line(to_char(lemp(i)));
end loop;
end;
Tags: Database
Similar Questions
-
Select the distinct value of a column in the collection in bulk.
Hi all
Collecting the data of a query to a variable of type table. I need to select a separate of a perticular column value in the collection.
Collection has followiing values inside.
I need to select distinct column values (for example: Col (c) .sourcecode) collection and the need to insert in the table if the value in this column does not exist in the table.Col(c).articleid, Col(c).userkey, Col(c).origin, Col(c).addnlorigindata, Col(c).avdest, Col(c).dispfmt, Col(c).sourcecode, Col(c).success_ind, Col(c).error_code, Col(c).entry_createddate, Col(c).createdby, Col(c).filenumber, Col(c).linenumber, Col(c).acctnum, Col(c).assetkey, Col(c).autocompletedterm, Col(c).accessionnumber, Col(c).requestdatetime, Col(c).requestorip, Col(c).articleordinal, Col(c).userinitiatedind, Col(c).captchastatus
Say, Col (c) .sourcecode has the value XYZ, ABC. If the "XYZ" value does not exist in the table, so I need to insert in the table and if "ABC" exists in the tables then don't insert it. (something like fusion) after seecting to the distinct values in a column in the collection.
Thanks n regards
Nana Akkivalli.The collection must be inserted before you can use this topic.
In the Begin block, you have to collect a loose and insert inside: something like
SELECT * BULK COLLECT INTO l_array FROM ALL_USER ...CONDITIONS...
-
How to export the collected addresses
I carried on a new machine (win 7). I have properly exported and imported my address book that contains only 7 entries in my opinion.
It is now only that I realize that Thunderbird uses the addresses of his "collected addresses" for a long time to suggest the person in the address bar, and that all of these hundreds of addresses are not registered in my address book.
How can I get access to my (what must be hundreds of) "collected addresses" and get them on my new machine?Thank you
Opens the address book, then select Tools-Export. Select the collected book to export.
http://KB.mozillazine.org/Moving_address_books_between_profiles -
Select the column name when the value = something
Is there a way to select the column name when there is a specific value in it?
As follows:
create table (abc123)
COLUMN1 VARCHAR2 (50).
COLUMN2 VARCHAR2 (50).
Column3 varchar2 (50)
);
insert into abc123 values ('yes', 'Yes', 'No');
insert into abc123 values ('no', 'Yes', 'No');
INSERT INTO ABC123 VALUES ('no ',' no', 'No');
insert into abc123 values ('yes', 'Yes', 'Yes');
SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?
WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?
WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?
Another null
finish as abc123 columnname
final results for the just Column1 would be:
COLUMN1
NULL VALUE
NULL VALUE
COLUMN1
I'm not sure what I use to get the name of column in there
Thank you.
Hello
708631 wrote:
Is there a way to select the column name when there is a specific value in it?
As follows:
create table (abc123)
COLUMN1 VARCHAR2 (50).
COLUMN2 VARCHAR2 (50).
Column3 varchar2 (50)
);
insert into abc123 values ('yes', 'Yes', 'No');
insert into abc123 values ('no', 'Yes', 'No');
INSERT INTO ABC123 VALUES ('no ',' no', 'No');
insert into abc123 values ('yes', 'Yes', 'Yes');
SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?
WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?
WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?
Another null
finish as abc123 columnname
final results for the just Column1 would be:
COLUMN1
NULL VALUE
NULL VALUE
COLUMN1
I'm not sure what I use to get the name of column in there
Thank you.
Thanks for posting the CREATE TABLE and INSERT for the sample data.
Don't forget to post the exact results you want from these sample data. If the results depend on the parameters you want to pass a run time, then give a few different examples, with the the desired results of each.
You can hardcode the values you want, such as the column names in a query. For example:
SELECT CASE WHEN column1 = 'Yes' THEN 'Column1' END like y1
CASE WHEN column2 = 'Yes' THEN 'Column2' END like y2
CASE WHEN Column3 = 'Yes' THEN 'Column2' END like y3
, a. *-If wanted
Of abc123 one
;
-
How to display the database column value in a component of choice selected?
Hello everyone;
I use Jdeveloper 11.1.1.4 and right now I have the .jspx UI page that includes < af:selectonechoice / > components and according to the requirment I have to fill one of the column in the table in this drop-down list.
can someone tell me how to fill the database column value in this drop-down list. I know I need to create the VO for the same thing, but I'm new to this technology. Then please suggest.
Thanks in advance.,
This will help u
https://blogs.Oracle.com/prajkumar/entry/create_lov_in_adf_application
How to create LOV in ADF 11 g | Techartifact
Oracle Fusion Middleware Technologies: 11G: how to create a list of Values (LOV)?
http://www.baigzeeshan.com/2010/03/creating-lov-in-ADF-application.html
http://husaindalal.blogspot.de/2010/05/How-to-default-lov-with-its-first-value.html
-
Oracle apex 5.0: not update the values in the Collection.
Hello again,
I have a problem in IR where content comes from the collection query.
Now the question is when I update the value of the column in the report and click on the custom button, that it will update the value of collection and insert the updated values of the collection member in another table that works well according to my condition, but when I will apply to any word in the search bar (say books in order not to update the values of books) and tries to update the value as a result of research above requirement does not work I mean the collection is not updated. Apex. Oracle.com
testdump/developer/Office
All of the Suggestions!
Thank you
Pranav.
Pranav.Shah wrote:
I have a problem in IR where content comes from the collection query.
Now the question is when I update the value of the column in the report and click on the custom button, that it will update the value of collection and insert the updated values of the collection member in another table that works well according to my condition, but when I will apply to any word in the search bar (say books in order not to update the values of books) and tries to update the value as a result of research above requirement does not work I mean the collection is not updated. Apex. Oracle.com
testdump/developer/Office
The "coll update" process fails with a ORA-01403: no data found error. This happens in line 11 because of the access attempt to the
wwv_flow.g_f01
using the variable array subscriptc
who has been incremented beyond the size of the table, which is now smaller because of the IR filter applied.begin declare c pls_integer := 0; begin for c1 in ( select seq_id,c001 from apex_collections where collection_name = 'MATRIX2' ) loop c:=c+1; apex_debug.message(c); apex_collection.update_member_attribute (p_collection_name=> 'MATRIX2', p_seq=> c1.seq_id,p_attr_number =>'2',p_attr_value=>wwv_flow.g_f01(c)); end loop; end; end;
I agree with fondant tabular forms on interactive reports, but you can meet your requirement as follows. In your application, see page 2.
1 Add a column of form element hidden IR containing the sequence number of collection:
select c001 col1 , apex_item.text(2, c002) col2 , apex_item.hidden(1, seq_id) seq from apex_collections where collection_name = 'MATRIX2'
2 place the question of the hidden form in the report using the COL1 Expression HTML attribute:
#COL1##SEQ#
3. change submit to the process if it is driven by the subject table, not the existing collection:
begin for i in 1..apex_application.g_f01.count loop apex_collection.update_member_attribute( p_collection_name=> 'MATRIX2' , p_seq=> apex_application.g_f01(i) , p_attr_number => '2' , p_attr_value=> apex_application.g_f02(i)); end loop; end;
-
Returns the selected table column header
I don't know there is probably a way to do this. But I have not yet found.
I am building an application that will act as a sort of "universal" reports generator for a MySQL database tables.
At startup, a drop-down list box is filled with the names of tables in the database. When the user selects one of these tables, the column names are taken from the base and used to fill the column headers for the table of LabVIEW.
The idea is that the user can select this column and enter the constraints of filter in a text box. These constraints will then be added to the WHERE statement for this column.
So far I've been able to find a way to return the Active cell or a selection of cells, when the user clicks on the actual data of the table.
Is there a direct way to retrun a selected in LabVIEW column header value?
I am dreaming that there may be some sort of workaround using transparent controls over the headers. But because different tables will have a different number of columns that the user defines the width, I'm not really sure that it will work more.
If you the editable headers, this allows Active cells specify that your column is - 1 column selected active line is the selected column. You may need to use the mouse down? to filter the possibility for the user to change the right column headings.
-
By the way a column value to Javascript
Hi all
I have an interactive relationship with the following SQL:
Select
EmpNo,
Ename,
"< a href =" # "onclick = 'test ("show it");' > ' |" jobs jobs | "< /a > ' job
de)
Select 10 empno, ename 'John', 'Manager' of the double job
Union
Select the 20 empno, ename 'Bookmark', 'Clerk' double work
)
Here is the definition of the test() function:
< script type = "text/javascript" >
function test (x) {}
Window.Alert (x);
}
< /script >
The report works very well. I can click on the column values of work e.g. Manager, the value hardcoded clerk alerts and function 'show it '. I want to show the value of employment, so if I click Manager, the alert must be 'Manager' and if I click on clerk then the alert should be "clerk." I tried to call the function like test(#job#) but no use.
Help, please.
Thank you
ZKay wrote:
I have an interactive relationship with the following SQL:
Select
EmpNo,
Ename,
'' | job |'' as job
de)
Select 10 empno, ename 'John', 'Manager' of the double job
Union
Select the 20 empno, ename 'Bookmark', 'Clerk' double work
)
Here is the definition of the test() function:
function test(x) {
window.alert(x);
}
The report works very well. I can click on the column values of work e.g. Manager, the value hardcoded clerk alerts and function 'show it '. I want to show the value of employment, so if I click Manager, the alert must be 'Manager' and if I click on clerk then the alert should be "clerk." I tried to call the function like test(#job#) but no use.
It does not seem very useful, but all that is needed is to concatenate the value of employment in the event hours code:
select empno, ename, '' || job || '' as job from( select 10 empno, 'John' ename, 'Manager' job from dual union select 20 empno, 'Mark' ename, 'Clerk' job from dual )
-
By using the link in the column to pass column values
Hello
I have a link to the column in my report which opens a modal page, now I want to use the value of the column clicked in the page that opens.
I don't want to put any article on the opening page of the column value of click rather I want to use the value of the column of the click in my sql query.
for example:
1 P1 has the report < column link by clicking on it opens P2 >
2. on page 2, I want to use the value of the clicked column.
So far, I did
1 link to page 2
2. ask - #column_value_clicked #.
3. in the sql query, I use the same above in the where clause.
Any help...
Thank you
Rakesh
fac586 wrote:
Sunil Bhatia wrote:
Hi Rakesh,
Make use of x 01 parameter included in apex 5.0
You can create a URL to page 1 as:
f? p = 103:1:3241341234123: & x 01: #column_value_clicked #.
Make use on request P2 in the form:
Select * from test_table where id = APEX_APPLICATION. G_X01;
You have not tested who, did you?
I tested it buddy.
Link https://apex.oracle.com/pls/apex/f?p=56971
Click any bar chart and then wait that he freshen up.
Click on report of ENAME and see that he went through the parameter.
Report URL: f? p = 56971:2: & APP_SESSION. : No.: & x 01 = #ENAME #.
-Sunil Bhatia
-
Hi all
We work in a custom oaf page subdivision. We have an obligation to fill the values in table advanced based on a value selection in an element of the lov (this LOV is not in the advanced table) .can share you it please me steps or examples of code to achieve this. Waiting for response.
Kind regards
I do not understand completely still. What do you mean by "default in the table values must be inserted".
You can create a dummy VO with the same columns and fix the VO in the advanced table.
In the normal scenario, when the user clicks on submit button, browse this VO, and copy the values to the validation according to VO and appeal EO. If values gets inserted into the database.
When the user selects the number of PO, simply run the other VO and fill this dummy VO so that values are available in the advanced table. When you click on send, do not copy these values to the EO based VO, so these lines won't get inserted.
It work?
See you soon
AJ
-
Transpose the unique column values online
Hi all
How to transpose the values of one column in a row,
COL
1
2
3
4
5
6
7
8
and I want to convert this column into the line as follows:
Line (each in a separate column value). Number of values is not constant.
1,2,3,4,5,6,7,8
Solution without converting them to XML:
WITH row_values
AS (SELECT DISTINCT property_name,
column_order
OF v_rd_property_definition
WHERE lp_id = 5171
ORDER BY column_order)
SELECT Regexp_substr(Wm_concat(property_name), "[^,] +' 1, 1") AS col1,.
Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 2"). AS col2.
Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 3") AS col3.
Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 4") AS col4,.
Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 5") AS col5,.
Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 6") AS col6,.
Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 7") AS col7
OF row_values;
-
Select the column in a table that is defined in the select previous in the statement
Hello
I want to write a procedure that selects all the data in a table has then records them in the text file. I tested on table hr.countries.
My code is like this:
echo off newpage 0 space 0 pagesize 0 feed head off trimspool check out serveroutput on the value
coil countries.txt
define dtable = COUNTRY;
declare
col_num NUMBER;
no_lig NUMBER;
line VARCHAR2 (100);
Col VARCHAR2 (100);
Start
Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable';
Select count (*) in no_lig of & dtable;
because me in 1.row_num
loop
1.col_num j
loop
Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;
Select the pass in the row (select col, rownum: nurse of (select col from & dtable)) where rn = i;
IF (j! = col_num) THEN
DBMS_OUTPUT. PUT(Row ||) ', ');
ON THE OTHER
DBMS_OUTPUT. PUT (Row);
END IF;
end loop;
DBMS_OUTPUT. NEW_LINE;
end loop;
end;
/
spool off
I have had no error, but the result is like this:
COUNTRY_ID, COUNTRY_NAME, REGION_ID
COUNTRY_ID, COUNTRY_NAME, REGION_ID
COUNTRY_ID, COUNTRY_NAME, REGION_ID
.. and so on for the whole table.
I want to have results with data not only the names of columns. No idea what is the problem? I thought that select col online would do the thing, but the line is identical to the col variable...
Thank you
Honza
Set serveroutput on;
define dtable = COUNTRY;
declare
col_num NUMBER;
no_lig NUMBER;
line VARCHAR2 (100);
Col VARCHAR2 (100);
Start
Select count (COLUMN_ID) in the col_num USER_TAB_COLUMNS WHERE table_name = '& dtable;
Select count (*) in the no_lig argument of &dtable;
because me in 1.row_num
loop
1.col_num j
loop
Select column_name from col FROM USER_TAB_COLUMNS WHERE table_name = '& dtable' and column_id = j;
run immediately 'select'. Col | "from (select ' |) Col |', rownum: nurse from (select ' |) Col |' of & dtable)) where rn =' | I have
Online;
IF (j! = col_num) THEN
DBMS_OUTPUT. PUT(Row ||) ', ');
ON THE OTHER
DBMS_OUTPUT. PUT (Row);
END IF;
end loop;
DBMS_OUTPUT. NEW_LINE;
end loop;
end;
/
Output
anonymous block filled
AR, Argentina, 2
To, Australia, 3
BEING, Belgium, 1
BR, Brazil, 2
CA, Canada, 2
CH, Switzerland, 1
CN, China, 3
OF (Germany), 1
DK, Denmark, 1
For example, Egypt, 4
FR, France, 1
HE, Israel, 4
IN, India, 3
IT, Italy, 1
JP, Japan, 3
KW, Kuwait, 4
ML, Malaysia, 3
MX, Mexico, 2
NG, Nigeria, 4
NL, Netherlands, 1
SG, Singapore, 3
UK, United Kingdom, 1
WE, United States of America, 2
ZM Zambia, 4
ZW, Zimbabwe, 4
-
Add the column in the collection
Hi gurus
I created 1 collection as below:
Create the Collection with the type of table emp
type c_emp is the table emp % rowtype;
v_emp:=c_emp() c_emp;
Now I want to add more than 2 columns in this collection, first name of the column is varchar2 (10) and and 2nd name column is varchar2 (10) s but unable to understand how will I achieve this?. Please guide. Thank you
Concerning
Shu
I created 1 collection as below:
Create the Collection with the type of table emp
type c_emp is the table emp % rowtype;
v_emp:=c_emp() c_emp;
Now I want to add more than 2 columns in this collection, first name of the column is varchar2 (10) and and 2nd name column is varchar2 (10) s but unable to understand how will I achieve this?.
You cannot change this collection. You must create a new. And you use no reserved words (for example, the "group") for the names.
DECLARE
CURSOR c1 IS (SELECT e.*, cast (null as varchar2 (10) GroupName, cast (null as name varchar2 (10))))
FROM emp e);
TYPE typ_tbl IS TABLE c1% rowtype;
v typ_tbl;
BEGIN
. . .
-
Compare the column values for multiple lines
I am new to oracle and I have a requirement to compare the values of column across multiple lines. If all column values are the same, I want to display that value, if the columns are not the same, I need to display 'no match' as value. I need id to group values and display a status value based on the above logic. Can anyone offer assistance with dispalying the result expected below?
Sample
Table
State ID
1 S
2 L
1 S
2 S
expected results
State ID
1 S
2 no match
Hello
That's what you asked for:
SELECT id
CASE
WHEN COUNT (DISTINCT status) > 1
THEN "no match."
For ANOTHER MIN (status)
The END as status
T
GROUP BY id
;
Want that if each State ID is NULL? The CASE expression above returns NULL in this situation.
-
Select the last Date of multicolumn and its value adjustent cust_id
I have a Table with 5 customer_id and 5 Dates with each belonging to its cust_id.
I need to take the last, in my example would be CUSTID_5. I know
this with the GREATEST who select the CHANGE_DATE_5 (in my example), but
How to choose the CUSTID_x? that goes along with the winning Date?
create table test_tbl)
number of custid_1
date of change_date_1,
number of custid_2
date of change_date_2,
number of custid_3
date of change_date_3,
number of custid_4
date of change_date_4,
number of custid_5
date of change_date_5
);
INSERT INTO test_tbl
(CUSTID_1, CHANGE_DATE_1, CUSTID_2, CHANGE_DATE_2, CUSTID_3, CHANGE_DATE_3, CUSTID_4, CHANGE_DATE_4, CUSTID_5, CHANGE_DATE_5)
VALUES
(111, sysdate, 222, sysdate + 1, 333, sysdate + 2, 444, sysdate + 3, 555, sysdate + 4);
commit;
Hello
Here's one way:
WITH unpivoted_data AS
(
SELECT custid, change_date
, EVALUATE () OVER (ORDER BY change_date DESC) AS r_num
OF test_tbl
UNPIVOT ((custid, change_date)
Label ((custid_1, change_date_1) AS 1)
, (custid_2, change_date_2) AS 2
, (custid_3, change_date_3) AS 3
, (custid_4, change_date_4) AS 4
, (custid_5, change_date_5) AS 5
)
)
)
SELECT custid, change_date
Of unpivoted_data
WHERE r_num = 1
;
Having several columns for several occurrences of basically the same thing is a bad table. This problem would be much simpler, but also more effective if each pair custid/change_date has been strored on a separate line. In addition, you would not be limited to 5 pairs.
Maybe you are looking for
-
Tried to uninstall. When you click on 'delete' again invited to restart to the new version. Still, it wouldn't uninstall. X 2 the computer unplugged. STIL told to restart. Tried to restore the system to yesterday, but always 'reboot' happened every t
-
Remote hp AIO cannot retrieve or download the scanned file
I scanned with my Ipad a big file as a result of more than 35 MB. I can't get the digital file download does not work (I tried with Google Drive and Dropbox). I don't know if the problem is wireless, the ipad or the software. I thought that I ignore
-
ProBook 650 G1: Fn + Esc does not
This used to work, but after reinstalling Windows from DVD HP and updated BIOS is not more. I installed the shortcut button, On Screen Display, quick launch... I rebooted. What Miss me? OSD for other Fn keys works (brightness etc) very well.
-
I recently bought a HP Envy 5530 printer. After the introduction, it wouldn't print. I am using the USB cable, but also tried the WiFi and no work. I have a HP Pavilion dv9500 laptop. It is currently running Windows 7 Home Premium with Service Pac
-
Use Schedule Auto dynamic locking
Hello The configuration is the following: My client wants to run 4 devices of individual test on the same PC. Each test set-up will take place at least 4 parallel trials at the same time by using the parallel model. For now, let's assume it's the sam