Retriving all table records
Hi,
To retrieve all records of the table, below procedure has been used, but on executing gets only one record in the output.
Procedure(proc_env) has been defined wrapped in the package (packg)
this package gets call from the java enviornment to retrieve all the records of the table.
Procedure wrapped in the package
PROCEDURE proc_test(cursor1 OUT TestCursor)
IS
BEGIN
OPEN cursor1 FOR
SELECT col1,
col2,
col3
FROM table_name
END;
procedure called for execution
DECLARE
v_col1 table.col_name%TYPE;
v_col2 table.col_name%TYPE;
v_col3 table.col_name%TYPE;
v_cur packg.TestCursor;
BEGIN
packg.proc_test(v_cur);
FETCH v_cur INTO v_col1,v_col2,v_col3;
DBMS_OUTPUT.ENABLE;
DBMS_OUTPUT.put_line(v_col1||','||v_col2||','||v_col3);
END;
How to retrieve all the records of the table ?
what is missing in the code ?
With Regards
SET SERVEROUTPUT ON
DECLARE
v_col1 table.col_name%TYPE;
v_col2 table.col_name%TYPE;
v_col3 table.col_name%TYPE;
v_cur packg.TestCursor;
BEGIN
DBMS_OUTPUT.ENABLE;
packg.proc_test(v_cur);
LOOP
FETCH v_cur INTO v_col1,v_col2,v_col3;
EXIT WHEN v_cur%NOTFOUND;
DBMS_OUTPUT.put_line(v_col1||','||v_col2||','||v_col3);
END LOOP;
CLOSE v_cur;
END;
/SY.
Similar Messages
-
How to retrive one table records into another table by multiple records
how to retrive table X records into another table Y by multiple records (means at once i want display 10 records) in form 6i .
when i am written cursor it is ftching only one record.But i want to display all records at once.
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae WHERE PROTOCOL_NO='KP229';
Begin
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Hi,
Make sure the cursor is in the detailed block. For that use 8GO_BLOCK* built-in. So the code will be
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae;
Begin
GO_BLOCK('<detailed_block_name>');
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Regards,
Manu.
If my response or the response of another was helpful or Correct, please mark it accordingly -
How to delete duplicate records in all tables of the database
I would like to be able to delete all duplicate records in all the tables of the database. Many of the tables have LONG columns.
Thanks.Hello
To delete duplicates from an individual table you can use a construct like:
DELETE FROM
table_a del_tab
WHERE
del_tab.ROWID <> (SELECT
MAX(dups_tab.ROWID)
FROM
table_a dups_tab
WHERE
dups_tab.col1 = del_tab.col1
AND
dups_tab.col2 = del_tab.col2
)You can then apply this to any table you want. The only differences will be the columns that you join on in the sub query. If you want to look for duplicated data in the long columns themselves, I'm pretty sure you're going to need to do some PL/SQL coding or maybe convert them to blobs or something.
HTH
David -
How can i get all the records from three tables(not common records)
Hi
I have four base tables at R/3-Side. And i need to extract them from R/3-Side.
And i dont have any standard extractor for these tables .
If i create a 'View' on top of these tables. Then it will give only commom records among the three tables.
But i want all the records from three base tables (not only common).
So how can i get the all records from three tables. please let me know
kumarYou can create separate 3 datasources for three tables and extract data to BW. There you can implement business login to build relation between this data.
-
How to update all the record for a particular column in a table based on search criteria.
Hi All,
I am new to ADF. I have a requirement, where i have to perform mass update on a table.
Scenario:
Ex: I have a dept manual search region. where i search with deptId: 20. I get 20 records in my table. now i have another region where i have a inputchoice list which contains all the columns names that exists in dept table. Beside that i have a input text box and an update button
Now user, first searches with dept id:20 and clicks on search button, where it shows 20 record in the table. He then select a column from input choicelist(ex: ManagerId), then enters new value in the input box(ex: abc) then clicks on update button.
Now i want, all the records in the ManagerId column with dept id:20 to be updated with the new value "abc"
Can anyone help me with the code.
Thanks in advance..Hi,
If you go to your VO and generate the ViewObjectImpl, in there you can create a method which will contain two parameters, 1 the attribute name and 2 the value.
Then you can follow something like explained in this post:
ADF Tutorial: How to apply bulk actions to a view object rows
The only difference is that you will need to create a method like this:
public void updateAttribute(String attribute, Integer value){
RowSetIterator iter = createRowSetIterator(null);
while (iter.hasNext()){
Row row = iter.next();
row.setAttribute(attribute, value);
Then you expose that as a client interface and then after you filter your table by your criteria you just need to execute this method passing the right parameters.
Regards -
Iterate through all the records in a table using Java API
Hi All,
What is the easiest way to iterate through all the records in a given table using Java API? I cannot find any methods that will return all records in a table and the only way I can use is to perform a free form search with a condition that is always true. The code works but is pretty ugly. Is there an alternative to this approach?
Thanks!
KennyHi Kenny,
You can construct a new Search object with your table's code name, a new ResultSetDefinition object for your table and just execute this search using the GetResultSet method of CatalogData.
Please look at the following code:
Search search = new Search(<code name of your table>);
ResultSetDefinition rsd = new ResultSetDefinition(<code name of your table>);
rsd.AddField<code name of a field>);
rsd.AddField(<code name of a field>);
String sortField = <code name of your sort field>;
boolean sortAscending = true;
int page = 0; //page number
A2iResultSet rs = <your CatalogData object>.GetResultSet(search, rsd, sortField, sortAscending, page);
for (int i = 0; i < rs.GetRecordCount(); i++)
Value fieldValue = rs.GetValueAt(i, <code name of a field>);
Hope this helps,
Nir
PS - I really recommend you to start using the new API, as it is much more efficient and straight-forward. -
Export specific records from all table? Please help me with my query
hi
there are around 200 tables, I want to take a export of all tables of xyz schema.
My requirement is just a few records of primary key and their relevant records from other tables to be exported by using exp or expdp utility.Hi Toni...
Thanks for your reply.
Could you please help me understand how to user this expdp query...
and what exactly should i mention in the parfile. I want all relevant records from all tables of primary key. please help me to write a query accordingly. -
Query to display all records count of all tables in a schema
Hi,
I need to count all the records of all my tables in a certain schema and display the max amount of the record count. Do you have a script for this one??SQL> create function countrec(in_tab in varchar2) return number is
2 retval number;
3 begin
4 execute immediate 'select count(*) from '||in_tab into retval;
5 return retval;
6 end;
7 /
Function created.
SQL> select table_name, countrec(table_name)
2 from tabs;
TABLE_NAME COUNTREC(TABLE_NAME)
QUERY_TOOL_DATA_COLLECTION 5
TEST01 0
T1 14
EMP 14
SALGRADE 5
FILES 0
PROVA 0
TEST 0
T_MASTER 1
T_CHILD 3
TAB_ONE 30
TAB_TWO 10
A 3
B 4
C 3
D 3
BONUS 0
DEPT 4
18 rows selected.Max -
Retrive last inserted record from database table
Hi,
some body inserting a record into table 'A' through some procedure/java program.i want to retrive the last inserted record from database table.records are not stored in order.Can any body help me.In general, unless you are storing a timestamp as part of the row or you have some sort of auditing in place, Oracle has no idea what the "first" or "last" record in a table is. Nor does it track when a row was inserted.
- If you have the archived logs from the point in time when the row was inserted, you could use LogMiner to find the timestamp
- If the insert happened recently (i.e. within hours), you may be able to use flashback query to get the value
- If you're on 10g or later and the table was built with ROWDEPENDENCIES and the insert happened in the last few days and you can deal with a granularity of a few seconds and you don't need 100% accuracy, you could get the ORA_ROWSCN of the row and convert that to a timestamp.
If this is something you contemplate needing, you need to store the data in the row or set up some sort of auditing.
Justin -
Should I use BCS my backend database will update all the record of the sql table daily.
Should I use the BCS where the database table is going to be updated daily.
All the records will be updated on daily basis.
Why should I use BCS when I can connect to the sql server directly and update the records that I need.
What additional benefits can I get from BCS , I do not need the search functionality.
RegardsHi,
According to description, my understanding is that you want to know if you need to use Business Connectivity Services to connect external SQL table.
Business Connectivity Services is a centralized infrastructure in SharePoint 2013 and Office 2013 that supports integrated data solutions.
Business Connectivity Service will provide a familiar user interface to manage sql table data. It is more security for reading and writing data to external sql table.
Here is a detailed article for your reference:
https://technet.microsoft.com/en-us/library/ee661740(v=office.15).aspx
https://msdn.microsoft.com/en-us/library/office/ee556440(v=office.14).aspx
Best Regards
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Jerry Guo
TechNet Community Support -
Remove all duplicate records and load into temp table
Hi
I have a table contains data like this.
Emp No Designation location
1111 SE CA
1111 DE CT
3456 WE NJ
4523 TY GH
We found that there are two duplicate records for emp no: 1111. I want to delete all duplicate records (in this case two records for emp no:1111) and load into the temp table.
Please advice me how to do it.Oh look, you can search the forums...
http://forums.oracle.com/forums/search.jspa?threadID=&q=delete+duplicates&objID=f75&dateRange=all&userID=&numResults=30 -
Retrive data base details of all tables
how can i retrive the
table name, no of rows in that table, no of indexs in that table, no of not null col's in that table
of in single data base(genuine query).Here's a starter...
The best way to count the number of rows on a table is not to look in the data dictionaries but to actually count the rows...
Laurent Schneider
http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
SQL> select
2 table_name,
3 to_number(
4 extractvalue(
5 xmltype(
6 dbms_xmlgen.getxml('select count(*) c from '||table_name))
7 ,'/ROWSET/ROW/C')) count
8 from user_tables
9 where iot_type != 'IOT_OVERFLOW';
TABLE_NAME COUNT
DEPT 4
EMP 14
BONUS 0
SALGRADE 5
Index Organized Table - Overflow Table
If such tables exist they cannot have "count(*)" done on them -
ORA-25191: cannot reference overflow table of an index-organized table Other information is in the various database dictionary views.
Edited by: BluShadow on Sep 3, 2008 12:18 PM
For some reason this new Jive forum doesn't allow "not equals" as in "<" and ">" when posted together in the code. Stupid forum. -
Collecting all the records in the item int table where the same matnr
Hi All,
I have two internal tables with records as below.
HEADER INTERNAL table
material num plant
50410 LV01
50411 AN01
50412 AN01
50413 LV01
ITEM TABLE
Material num stor loc
50410 ER01
50410 ALQW
50410 WFDD
50412 ER01
50413 ER01
50413 XK01
I want to move this to final internal table, here the record 50411 is not there in second int table still i want to move to final table.
in the final int table record should be as follows
material plant stor loc
50410 LV01 ER01
50410 LV01 ALQW
50410 LV01 WFDD
50411 AN01
50412 AN01 ER01
50413 LV01 ER01
50413 LV01 XK01
I'm not getting the full records in the final int table.How to do this.
Thanks & Regards,
SabuHi Sabu,
You can get the data in final internal table as follows :
**First Declare the Final Internal table as :
types : begin of wy_final,
matnr like mara-matnr, " Material Number
werks like mseg-werks, " Plant
lgort like mseg-lgort, " Storage Location
end of wy_final.
data : wt_final type standard table of wy_final with header line.
**Declare a temporary Header Internal Table
wt_header_temp[] = wt_header[].
Then loop at Item table as it has multiple entries for same material Number
loop at wt_item.
**Then read Header Table for mapping material Number & picking the corresponding Plant.
read table wt_header with key matnr = wt_item-matnr.
if sy-subrc eq 0.
wt_final-matnr = wt_item-matnr.
wt_final-werks = wt_header-werks.
wt_final-lgort = wt_item-lgort.
append wt_final.
clear wt_final.
endif.
read table wt_header_temp with key matnr = wt_item-matnr.
if sy-subrc eq 0.
delete wt_header_temp.
endif.
endloop.
loop at wt_header_temp.
read table wt_final with key matnr = wt_header_temp-matnr.
if sy-subrc ne 0.
wt_final-matnr = wt_header_temp-matnr.
wt_final-werks = wt_header_temp-werks.
append wt_final.
clear wt_final.
endif.
endloop.
sort wt_final by matnr.
I Think this would probably solve your purpose.
Thanks & Regards,
Bhavika
Edited by: bhavika kumar on Mar 19, 2009 5:46 AM -
Get records count of all tables
Hi ,
I am trying to get the record count of all tables using dynamic query. I don't know how to put the value in placeholder. I tried the below code.
SET SERVEROUTPUT ON SIZE 1000000
DECLARE
CURSOR table_list
IS
select OBJECT_NAME from user_objects
where object_type in ('TABLE')
and object_name not like '%AUDIT_DDL%'
AND object_name not like 'MD_%'
AND object_name not like 'EXT_%'
AND object_name not like 'STG_%'
AND object_name not like 'SYS_%'
AND object_name not like 'TMP_%'
AND object_name not like 'TEMP_%'
order by 1;
v_count NUMBER :=0;
query_str VARCHAR2(1000);
BEGIN
FOR table_name IN table_list
LOOP
query_str :='SELECT COUNT(1) FROM ' || table_name.OBJECT_NAME;
dbms_output.put_line(query_str);
dbms_output.put_line('Table Name:' || table_name.OBJECT_NAME );
v_count:= execute immediate query_str;
dbms_output.put_line('Table Name:' || table_name.OBJECT_NAME || ', Count ' || v_count );
END LOOP;
END;
I know I am doing wrong in the bold lines. But not sure how to fix it. Please help. Thanks in advance.Hi,
Welcome to the forum!
What you posted is basically right, assuming you really want to do dynamic SQL t all.
The only problem with
961618 wrote:
query_str :='SELECT COUNT(1) FROM ' || table_name.OBJECT_NAME; would be if the object name included special characters (such as single-quotes) or lower-case letters. To avoid any possible problems, I would put the object name inside double-quotes:
... query_str := 'SELECT COUNT (*) FROM "' || table_name.OBJECT_NAME
|| '"';
v_count:= execute immediate query_str;
The correct syntax is
execute immediate query_str INTO v_count;V_count will be the number of rows in a single table. Keep another variable (say total_v_count) that keeps the total count so far.
Do you really need dynamic SQL?
SELECT SUM (num_rows) AS total_rows
FROM user_tables
WHERE table_name NOT_LIKE '%AUDIT_DDL%
AND ...
;gets the same information, accurate as of the last time statistics were gathered, and some of the numbers may be approximate. Depending on how you use the results, that may be good enough for you. If you actually have 10,000,123 rows, and the query says you have 10,000,000, does it really matter? -
Walk thru all database table records until match is found then delete
I have a database connected form. It has a scipt that checks to see if that forms data has already been submitted by searching thru the records for the formID number. I want the records to be deleted if found and then add new records incase the form data has been changed. I can make this work once by using the script below. Is there a short way to make it continue searching and deleting all the records that start with that form ID number instead having to copy this script 12 times (maximum number of records allowed).
var oFile = Subform1.FileName.formattedValue;
var bFound = false;
while(!oDB.isEOF()){
if(xfa.record.DataConnection2.FileName.value == oFile){
bFound = true;
break;
oDB.next();
if(bFound){
oDB.delete();
oDB.update();types : begin of ty_jtab,
f1(10) type c,
end of ty_jtab.
data : jtab type standard table of ty_jtab with header line,
itab type standard table of ty_jtab with header line.
data : wa_jtab type ty_jtab,
wa_itab type ty_jtab.
*populate itab for say db
itab-f1 = '1000'. append itab.
itab-f1 = '2000'. append itab.
itab-f1 = '3000'. append itab.
*populate jtab
jtab-f1 = '1000'. append jtab.
jtab-f1 = '4000'. append jtab.
jtab-f1 = '8000'. append jtab.
jtab-f1 = '9000'. append jtab.
sort itab by f1.
sort jtab by f1.
clear: itab, wa_itab.
loop at itab into wa_itab.
read table jtab into wa_jtab with key f1 = wa_itab-f1
binary search.
if sy-subrc ne 0.
delete itab from wa_itab.
if sy-subrc ne 0.
write :/ 'fail', wa_itab-f1.
endif.
endif.
endloop.
*o/p is two times fail which shows the assumption.
br,
vijay
Maybe you are looking for
-
How can user attach file to interactive form, and be read by abap program?
Hello, I created an abap interactive form, sent to the user, then user fills out the form fields, then it is uploaded back to sap, then my program reads this data and process it. It works. Now I want users to be able to attach any file they want, and
-
How can I enable Plug-in in Adobe Acrobat Read
hello, I wrote a plug-in that works on Adobe Acrobat Pro 9.0, I want to load the plug-in for Adobe Reader 9.0, how can i do this? is there any free tools to do this work? thank you very much.
-
WEBUTIL_FILE_TRANSFER.getMaxTransfer will not work
oracle.forms.webutil.file Transfer.File Transfer bean not found. WEBUTIL_FILE_TRANSFER.getMaxTransfer will not work. while loading image from client machine through foms 10g in a three tier environement ,i am getting this error.can anyone help me wit
-
Hi, I am trying to create an ibook in Pages. My document has quite a few images which show up in the pages document and also when I export to PDF, However when I export to Epub some of my images disappear. I have checked that they are all inline and
-
Webutil Problem - Client_Win_API_Environment function
Hiya I am facing a peculiar problem. I want to use Webutil's functions in my form. I am calling client_Win_API_Environment.Get_Windows_Version function in my form. But I am getting "FRM-40734: Internal Error: PL/SQL error occurred" message. However i