Indexing multiple Tables
Hi !
I´ve got a question. Is it possible to create an index with three base tables that hold the information to be indexed.
table1 {
proj_id number,
name varchar2,
thema varchar2
table2 {
proj_id number,
abstract clob}
table3 {
proj_id number,
gutachten clob
I want to index name, thema, abstract and gutachten. The examples i found use only one table to index. Is it possible to create a view with all the rows needed and then to index the view?
Thanks
Holger
You can build a USER_DATASTORE on your 'master' table (table1). Then build a procedure which collects the information from you other two tables:
This will show you the way:
procedure my_datastore ( in v_rowid
v_proj_id number;
v_name varchar2;
v_abstract CLOB;
v_gutachten CLOB;
v_result CLOB;
select proj_id, name
into v_proj_id, v_result
from table1
where rowid = v_rowid;
select abstract
into v_abstract
from table2
where proj_id = v_proj_id;
select gutachten
into v_gutachten
from table3
where proj_id = v_proj_id;
v_result = v_name || v_abstract || v_gutachten;
Similar Messages
-
Indexing multiple columns of multiple tables
Hi,
I'm trying to index multiple columns of multiple tables.
As I have seen, the way to do this is using User_Datastore.
have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
I want to get the different tagnr belonging to the same description etc.
Can I do this?
Has anyone a Samplecode indexing multiple tables?
Any suggestion would be helpful.
ArsinehA USER_DATASTORE works like this:
create table A
( id number primary key,
textA varchar2(100));
create table B
( id number primary key,
textB varchar2(100));
procedure foo (rid in rowid, v_document in out varchar2)
v_textA varchar2(2000);
v_idA number;
v_textB varchar2(2000);
begin
select id, textA
into v_idA, v_textA
from A
where rowid = rid;
select textB
into v_textB
from B
where id = v_idA;
v_document := textA | | ' ' | | textB;
end;
create preferences for USER_DATASTORE
create index ...
on table A ( text) ...
you also can build on table B
This depends where you want the
trigger to be build to sync the
documents.
null -
Context index can't be used in complicated multiple tables join?
hello
thank you for view this page.
i have a comlicated sql :
SELECT count(*)
from
((app_AssetBasicInfo left join app_AssetBasicInfoExt on
app_AssetBasicInfo.id=app_AssetBasicInfoExt.id) left join
(app_AssetCustominfo1 left join app_AssetCustominfoExt1 on
app_AssetCustominfo1.id=app_AssetCustominfoExt1.id) on
app_AssetBasicInfo.id=app_AssetCustominfo1.id) WHERE
app_AssetBasicInfo.CategoryID=1 AND Del_tag=0 and contains(description,'department')>0;
the table app_AssetBasicInfo and app_AssetBasicInfoExt have multiple columns and large recoord size. i create a context index on app_assetbasicinfoext(description) which description is 4000 varchar2.
but the sql doesn't use context index. i suspect that the complicated multiple table join can't use context index? does it correct?
thanks very much!Could you please post an explain plan? I'm not quite sure what is the issue.
-
Indexing multiple columns in multiple tables
I have a multiple tables in which I want to search. I need to do text search that supports fuzzy logic for which I've currently set up a context index using the user_datastore. I also need to search columns such as numbers/dates/timestamps which from what I understand is not supported with the context search. I'm looking at setting up a second index of type ctxcat for this purpose - but I will need to index multiple columns in multiple tables. Is this possible?
Can someone advise on the best way to create indexes and search when a table schema such as the following exists. I've tried to keep it simple by just giving a few example columns and tables.
Order Table
- Has columns related to the order details - order name (varchar2), description (varchar2), date order placed (timestamp), date order completed (date), order amount (number), customer Id
Customer Table
- Has columns related to the customer information - customer name, address, city, state, telephone etc (all varchar2 fields)
Items Table
- Has details about the items being ordered - item name (varchar2), item description (varchar2), cost (number) etc
Order-Item Table
- Table that maps an order to the items in that order - orderId, itemId, quantity
Comments Table
- Logs any comments with the customer - comment description (varchar2), call type (varchar2), comment date (timestamp)
Currently with the Context index, I have it set up so I can search all text columns in all tables for a search term. This works fine.
I now need to be able to do more advanced searches, where I can search for a specific text in all orders as well as orders created after a certain date or orders above a certain amount or orders with a item quantity purchase of more that 10. The text has to be searched across the all text columns in all tables. How can I achieve this with Oracle Text?There was a similar discussion with various ideas that may help you here:
How can I make CONTAINS query work for a date range -
Index Multiple Column of Multiple Tables
Hi All,
I would like to know how to create a index which can search through all column in my database tables. Eg: I have 30
tables and every tables have around 10 columns. I want to create a index which can search through the columns in
these tables.
I know that User_DataStore can helps in create multiple column search across multiple tables. But in my case the BLOB
created will be very huge. Any work around? I mean is there any solutions like concatenated datastore?
Thank You.
Regards,
LG TanHi,
I figured out how to do this today. The first thing is that the type of index you need is a USER_DATASTORE.
The idea behind this type of index is pretty straight forward but the documentation does a very good job of not drawing attention to just how powerful it is.
The idea behind a USER_DATASTORE is that you can write your own stored procedure to extract the data that you want to index and return it to the indexer. Take an example where you have a master table which contains enough information to allow you to find associated data in other tables i.e. a shared key. The idea is that when you set up a USER_DATASTORE index, you specify the name of a stored procedure that the indexer will call for each row in the master table. The stored procedure has one input and one output parameter, rowid (in) and clob (out).
When the index is created, the stored procedure you specify is, as I said above, called for each row in the master table. Your stored procedure uses this ROWID to extract the shared key (this can be anything you want) from the master table and uses this to build the necessary SELECT statement to retrieve the related data from the other tables. The rest of the stored procedure simply appends the data returned from your select statement to the return CLOB. The indexer then indexes the inforamation in this CLOB and discards the data.
The index can of course only return hits against the master table. It's up to your application to extract shared key from the returned row(s), bind to the other tables and present the results.
You will find a basic example of how to implement USER_DATASTORES in the Oracle Text Reference Guide (http://download.oracle.com/otndoc/oracle9i/901_doc/text.901/a90121.pdf). Feel free to email me if you want some example code.
Dean -
Multiple tables with the possibility of multiple records in each table
Post Author: viper
CA Forum: .NET
Hi
I have been trying for a few days now to come up with a CR solution to displaying data from multiple tables. These tables, in some cases, have more then one record that needs to be displayed. This is basically what I am trying to do.....
I am developing a .net web application(vb) using vs2005 and an oracle 10g backend. There is a data entry part of the site that users will enter data related to a property. Other users will be able to search these records and have a list of records returned based on the search criteria. The user then can click on one of these records to view a pop up CR report containing all the data related to that one property. The PropID is passed to the pop up page and is used in the WHERE clause of my SQL statement to bring back only one property. This data can come from as many as 18 tables if all the fields have been entered for this property. I have tried many different solutions to get the data from multiple tables...and have had some that were close to what I need. The best one I have will display data from multiple tables but only one record per table.....which doesn't work in my case since some of the tables have more then one record per table.
Is there anybody that has had success in setting up similar reports?
Does anybody know how I could use the "Group Expert" to group by the tables in my application? I can only figure out how to group within a single table.
It would be great if I could group by table....then just display the record(s) in each table that had the same PropID. I am not sure if the pdf export would show all the data in that situation but it would be worth a try. If fact...maybe I could create a new table called MyTables and just add two colums like MyTableID and MyTableName. Then add all the table names to MyTables that I want to see in the report and add the associated MyTableID value to each table as a new column. I could then group by MyTableID and PropID. Just guessing here.
Any ideas would be appreciated.Post Author: quafto
CA Forum: .NET
Your query is not too clear so I'll do my best to answer it broadly.
You mentioned that you have a .NET web application where your users enter data on one screen and then may retrieve it on another. If the data is written in real time to a database then you can create a standard Crystal Report by adding multiple tables. The tables should be linked together using the primary and foreign keys in order to optimize the database query and give you a speedy report. Using unlinked tables is not recommended and requires the report engine to index the tables (it is quite slow).
You also mentioned you have a "PropID" to be used in a WHERE clause. This is a great place to use a parameter in your report. This parameter can then be used in your record selection formula inside Crystal Reports. The report engine will actually create the WHERE clause for you based on the parameter value. This is helpful because it allows you to simply concentrate on your code rather than keeping track of SQL queries.
Now, what Crystal does not do well with is uncertainty. When you design a report with X number of tables the report engine expects X number of tables to be available at processing time. You should not surprise the print engine with more or less tables because you could end up with processing errors or incorrect data. You may need to design multiple reports for specific circumstances.
Regarding the group expert question. I'm not sure how you would/could use the group expert to group a table? A table is a collection of fields and cannot be compared to another table without a complex algorithm. The group expert is used to group and sort records based on a field in the report. Have a look at the group expert section of the help file for more information.
Hopefully my comments have given you a few ideas. -
How to update fields in multiple tables ?
Dear all,
What is the fastest way to update fields in multiple tables... from a single change table...as below is my code to update the fields but it is taking long time to update as i need to keep log file if any one update fails....
CREATE OR REPLACE
package body DO_DC_NAME_UPDATE_OTHER_TAB
as
type rowidArray is table of rowid index by binary_integer;
type custRec is record
n_cust_ref_no dbms_sql.number_table,
v_name dbms_sql.varchar2_table,
v_name_chg dbms_sql.varchar2_table,
rowid rowidArray,
changed dbms_sql.varchar2_table
procedure VALIDATE_CUST_NAME( p_n_cust_ref_no in number,p_v_name_chg in out NOCOPY varchar2, p_changed in out NOCOPY varchar2 )
is
begin
FOR cr_cust IN (SELECT --a.n_cust_ref_no,a.v_name,UPD_V_NAME, a.n_weight,a.V_LASTUPD_INFTIM
from GNMT_CUSTOMER_MASTER_CHG where n_cust_ref_no=p_n_cust_ref_no)
loop
-- v_name
if nvl(trim(cr_cust.v_name),0) != nvl(p_v_name_chg,0)
then
p_v_name_chg := p_v_name_chg;
--p_v_name := p_v_name;
p_changed := 'Y';
end if;
end loop;
end;
procedure DO_NAME_UPDATE_OTHER_TAB
is
l_record custRec;
l_array_size number default 20000;
l_done boolean;
l_cnt number default 1;
cursor c is select a.n_cust_ref_no, a.v_name,a.v_name_chg, a.rowid, 'N'
from GNMT_CUSTOMER_MASTER_CHG a--,GNMT_CUSTOMER_MASTER b
where a.v_name <> trim(a.v_name_chg); --and a.n_cust_ref_no in (1434775,1561181,1601870);
begin
open c;
loop
dbms_application_info.set_client_info
( 'processing ' || l_cnt || ' thru ' || (l_cnt+l_array_size-1) );
fetch c bulk collect into l_record.n_cust_ref_no, l_record.v_name,l_record.v_name_chg,l_record.rowid, l_record.changed
LIMIT l_array_size;
l_done := c%notfound;
--dbms_output.put_line ('message10');
for i in 1 .. l_record.n_cust_ref_no.count
loop
VALIDATE_CUST_NAME(l_record.n_cust_ref_no(i),l_record.v_name_chg(i),l_record.changed(i) );
end loop;
--dbms_output.put_line (l_record.n_cust_ref_no(i)||','||l_record.V_OCCUP_CODE(i)||','||l_record.CHANGED(i));
/*forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_CUSTOMER_MASTER q
set q.v_name = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y';*/
-- update v_name in all the related tables
forall i in 1 .. l_record.n_cust_ref_no.count
update ADE_CUSTOMER_MASTER q
set q.v_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_POLICY_DETAIL q
set q.v_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_QUOTATION_DETAIL q
set q.v_NAME =l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update NBDT_BENEFICIARY q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSDT_NOMINATION_TRANSACTION q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_POLICY_BENEFICIARY q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_POLICY_TRUSTEE q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_QUOTATION_BENEFICIARY q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_QUOTATION_TRUSTEE q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNDT_BLACKLIST_DETAIL q
set q.v_FNAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_FNAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_FNAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update INDT_LIAM_DETAIL q
set q.v_FNAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_FNAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_FNAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_POLICY q
set q.V_PAYER_NAME = l_record.v_name_chg(i)
where q.N_PAYER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PAYER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PAYER_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_QUOTATION q
set q.V_PAYER_NAME = l_record.v_name_chg(i)
where q.N_PAYER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PAYER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PAYER_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_QUOTATION q
set q.V_PROPOSER_NAME = l_record.v_name_chg(i)
where q.N_PROPOSER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PROPOSER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PROPOSER_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_POLICY q
set q.V_PROPOSER_NAME = l_record.v_name_chg(i)
where q.N_PROPOSER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PROPOSER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PROPOSER_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update CLMT_CLAIM_MASTER q
set q.V_CLIENT_NAME = l_record.v_name_chg(i)
where q.N_CLIENT_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_CLIENT_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_CLIENT_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update CLMT_CLAIM_MASTER q
set q.V_INTIMATOR_NAME = l_record.v_name_chg(i)
where q.N_CLIENT_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_INTIMATOR_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_INTIMATOR_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PYMT_VOU_MASTER q
set q.V_PAYEE_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_PAYEE_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PAYEE_NAME is not null;
/*forall i in 1 .. l_record.n_cust_ref_no.count
INSERT INTO GNMT_CUSTOMER_MASTER_LOG
(N_CUST_REF_NO, V_TITLE_CODE, V_NAME, D_BIRTH_DATE, V_SEX, V_RELIGION_CODE, V_NATION_CODE, V_OCCUP_CODE, V_ALIVE, V_SMOKER,
N_NO_STICKS, D_DEATH_DATE, V_BUMI_NON_BUMI, V_AGE_ADMITTED, V_SHORT_NAME, V_FIRST_NAME, V_LAST_NAME, V_EMAIL, V_DESIGNATION,
N_HEIGHT,N_WEIGHT,V_TITLE_CODE_CHG, V_NAME_CHG, D_BIRTH_DATE_CHG, V_SEX_CHG,V_RELIGION_CODE_CHG,V_NATION_CODE_CHG, V_OCCUP_CODE_CHG, V_ALIVE_CHG,
V_SMOKER_CHG, N_NO_STICKS_CHG, D_DEATH_DATE_CHG,V_BUMI_NON_BUMI_CHG, V_AGE_ADMITTED_CHG, V_SHORT_NAME_Chg, V_FIRST_NAME_Chg,
V_LAST_NAME_Chg, V_EMAIL_Chg, V_DESIGNATION_Chg,N_HEIGHT_Chg,N_WEIGHT_Chg, V_UPD_STATUS_DC,-- V_LASTUPD_PROG, V_LASTUPD_INFTIM,
V_LASTUPD_USER_DC, V_LASTUPD_PROG_DC,V_LASTUPD_INFTIM_DC
SELECT N_CUST_REF_NO, V_TITLE_CODE, V_NAME, D_BIRTH_DATE, V_SEX, V_RELIGION_CODE, V_NATION_CODE, V_OCCUP_CODE, V_ALIVE, V_SMOKER,
N_NO_STICKS, D_DEATH_DATE, V_BUMI_NON_BUMI, V_AGE_ADMITTED, V_SHORT_NAME, V_FIRST_NAME, V_LAST_NAME, V_EMAIL, V_DESIGNATION,
N_HEIGHT,N_WEIGHT,V_TITLE_CODE_CHG, V_NAME_CHG, d_birth_date_chg, V_SEX_CHG, V_RELIGION_CODE_CHG,V_NATION_CODE_CHG, V_OCCUP_CODE_CHG, V_ALIVE_CHG,
V_SMOKER_CHG, N_NO_STICKS_CHG, D_DEATH_DATE_CHG, V_BUMI_NON_BUMI_CHG, V_AGE_ADMITTED_CHG, V_SHORT_NAME_Chg, V_FIRST_NAME_Chg,
V_LAST_NAME_Chg, V_EMAIL_Chg, V_DESIGNATION_Chg,N_HEIGHT_Chg,N_WEIGHT_Chg--, V_LASTUPD_USER, V_LASTUPD_PROG, V_LASTUPD_INFTIM
,'PROCESSED'
,user,--P_USER,
'DC_PAKAGE',
sysdate--P_DATE
FROM GNMT_CUSTOMER_MASTER_CHG where n_cust_ref_no =l_record.n_cust_ref_no(i)
--and n_cust_ref_no not in (select n_cust_ref_no from GNMT_CUSTOMER_MASTER_LOG);*/
exit when (l_done);
l_cnt := l_cnt + l_array_size;
end loop;
commit;
end;
end;
thank YouDear SeánMacGC thanks for reply,
But "a.changed" is not a field in GNMT_CUSTOMER_MASTER_CHG. what i am doing in this procedure is i am collecting bulck data and validating field by field from GNMT_CUSTOMER_MASTER_CHG with GNMT_CUSTOMER_MASTER table as their structure is same.. if v_name is not same as v_name_chg then i am setting changed flag to "Y" changed is "changed dbms_sql.varchar2_table" and updating GNMT_CUSTOMER_MASTER in bluck where changed flag ='Y'...
type custRec is record
n_cust_ref_no dbms_sql.number_table,
v_name dbms_sql.varchar2_table,
v_name_chg dbms_sql.varchar2_table,
rowid rowidArray,
*changed dbms_sql.varchar2_table*
i cannot use simple SQL as i need to validate field for each records with GNMT_CUSTOMER_MASTER_CHG and insert into log file as well.....
to run this procedure:
execute DO_DC_NAME_UPDATE_OTHER_TAB.DO_NAME_UPDATE_OTHER_TAB;
Thanks... -
User Datastore for multiple tables and columns!
Hi,
I hop so much, someone can help me.
I've made a user datastore to index multiple columns of multiple tables.
Now, the Documentation of Oracle explains the idexing of one table.
I have multiple tables, which have all, the columns descr and tagnr. I want to make a query sth like this:
select table1.column, table2.columnd... where contains(indexed field,'gas within descr',1)>0
is it possible to index 4 seperate tables, without having a collective key? I dont want to make a Concatenated Datastore.
I have wrote this code.
But it doesn't work. It's been compiled fine. But I don't get any result with my queries.
create or replace
procedure My_Proc_Wide
Must be in ctxsys schema.
In a full-scale example, this would be a wrapper
for a proc in the user schema.
rid in rowid,
tlob in out NOCOPY clob /* NOCOPY instructs Oracle to pass
this argument as fast as possible */
is
v_descr varchar2(80);
v_tagnr varchar2(30);
v_descr_name constant varchar2(20) := 'descr';
v_descr_start_tag constant varchar2(20) := '<' || v_descr_name || '>';
v_descr_end_tag constant varchar2(20) := '</' || v_descr_name || '>';
v_tagnr_name constant varchar2(20) := 'tagnr';
v_tagnr_start_tag constant varchar2(20) := '<' || v_tagnr_name || '>';
v_tagnr_end_tag constant varchar2(20) := '</' || v_tagnr_name || '>';
v_buffer varchar2(4000);
v_length integer;
begin
/* verify the env which called this */
if Dbms_Lob.Istemporary ( tlob ) <> 1
then
raise_application_error ( -20000,
'"IN OUT" tlob isn''t temporary' );
end if;
/* the real logic */
/* first tabel to be indexed */
select t1.tagnr, t1.descr
into v_tagnr, v_descr
from tweb.pdp_positions t1
where t1.rowid = rid;
v_buffer := v_tagnr_start_tag ||
v_tagnr ||
v_tagnr_end_tag ||
v_descr_start_tag ||
v_descr ||
v_descr_end_tag;
v_length := length ( v_buffer );
Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
/* second table to be indexed */
select t2.tagnr, t2.descr
into v_tagnr, v_descr
from tweb.pdp_schema_equ t2
where t2.rowid = rid;
v_buffer := v_tagnr_start_tag ||
v_tagnr ||
v_tagnr_end_tag ||
v_descr_start_tag ||
v_descr ||
v_descr_end_tag;
v_length := length ( v_buffer );
Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
/*third table to be indexed */
select t3.tagnr, t3.descr
into v_tagnr, v_descr
from tweb.pdp_equipment t3
where t3.rowid = rid;
v_buffer := v_tagnr_start_tag ||
v_tagnr ||
v_tagnr_end_tag ||
v_descr_start_tag ||
v_descr ||
v_descr_end_tag;
v_length := length ( v_buffer );
Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
/* fourth table to be indexed */
select t4.tagnr, t4.descr
into v_tagnr, v_descr
from tweb.pdp_Projcode t4
where t4.rowid = rid;
v_buffer := v_tagnr_start_tag ||
v_tagnr ||
v_tagnr_end_tag ||
v_descr_start_tag ||
v_descr ||
v_descr_end_tag;
v_length := length ( v_buffer );
Dbms_Lob.WriteAppend(tlob, length(v_buffer) + 1, v_buffer || ' ');
end My_Proc_Wide;
what have I to do, to make this work?
Any Help would be appriciated!!
Kind Regards,
ArsinehArsineh,
I realise that it has been quite some time since you posted this question but I thought I'd reply just in case you never did manage to get your user datastore working.
The reason your procedure will not work is simple. A user datastore procedure accepts a rowid input parameter. The rowid is the ID of the row that Oracle Text is currently trying to index. In the example you have given, you are attempting to use the supplied rowid as the primary key for multiple tables, this will simply never work as the rowid's across multiple tables will never correspond.
The best way to achieve your goal is to create the index on a master table which contains the common primary keys for each of your four tables e.g.
MASTER_TABLE
COL:COMMON_KEY (NUMBER(n))
COL:USER_INDEX_COLUMN (VARCHAR2(1))
If you create the user datastore index on the MASTER_TABLE.USER_UNDEX_COLUMN column your stored proc simply needs to read the correct row from the MASTER_TABLE (SELECT t.common_key into v_CommonKey FROM master_table t WHERE t.rowid = rid) and issue subsequent queries to extract the relavant data from the t1..t4 tables using the common key e.g.
SELECT t1.tagnr, t1.descr into v_tagnr, v_descr FROM t1 WHERE t1.[PRIMARY_KEY_FIELD] = v_CommonKey;
SELECT t2.tagnr, t2.descr into v_tagnr, v_descr FROM t2 WHERE t2.[PRIMARY_KEY_FIELD] = v_CommonKey;
and so on...
Hope this helps
Dean -
Best way to remove duplicates based on multiple tables
Hi,
I have a mechanism which loads flat files into multiple tables (can be up to 6 different tables) using external tables.
Whenever a new file arrives, I need to insert duplicate rows to a side table, but the duplicate rows are to be searched in all 6 tables according to a given set of columns which exist in all of them.
In the SQL Server Version of the same mechanism (which i'm migrating to Oracle) it uses an additional "UNIQUE" table with only 2 columns(Checksum1, Checksum2) which hold the checksum values of 2 different sets of columns per inserted record. when a new file arrives it computes these 2 checksums for every record and look it up in the unique table to avoid searching all the different tables.
We know that working with checksums is not bulletproof but with those sets of fields it seems to work.
My questions are:
should I use the same checksums mechanism? if so, should I use the owa_opt_lock.checksum function to calculate the checksums?
Or should I look for duplicates in all tables one after the other (indexing some of the columns we check for duplicates with)?
Note:
These tables are partitioned with day partitions and can be very large.
Any advice would be welcome.
Thanks.>
I need to keep duplicate rows in a side table and not load them into table1...table6
>
Does that mean that you don't want ANY row if it has a duplicate on your 6 columns?
Let's say I have six records that have identical values for your 6 columns. One record meets the condition for table1, one for table2 and so on.
Do you want to keep one of these records and put the other 5 in the side table? If so, which one should be kept?
Or do you want all 6 records put in the side table?
You could delete the duplicates from the temp table as the first step. Or better
1. add a new column WHICH_TABLE NUMBER to the temp table
2. update the new column to -1 for records that are dups.
3. update the new column (might be done with one query) to set the table number based on the conditions for each table
4. INSERT INTO TABLE1 SELECT * FROM TEMP_TABLE WHERE WHICH_TABLE = 1
INSERT INTO TABLE6 SELECT * FROM TEMP_TABLE WHERE WHICH_TABLE = 6
When you are done the WHICH_TABLE will be flagged with
1. NULL if a record was not a DUP but was not inserted into any of your tables - possible error record to examine
2. -1 if a record was a DUP
3. 1 - if the record went to table 1 (2 for table 2 and so on)
This 'flag and then select' approach is more performant than deleting records after each select. Especially if the flagging can be done in one pass (full table scan).
See this other thread (or many, many others on the net) from today for how to find and remove duplicates
Best way of removing duplicates -
Heap tables and index organized tables
I performing migration from mssql server to oracle 10gr2 rdbms, in mssql all tables have clustered pk, index. Is it necessary to use index organized tables for that migration, or enough ordinal heap organized tables and what differences between those tables, and mssql tables
ThanxIn Oracle, the typical table is a standard 'heap' table. Stuff goes into the heap table randomly, and randomly comes out.
An Index Organizaed Tables is somewhat similar to a Cluster Index in SS. It can have some performance advantages over heap tables - when the heap table has an associated index on the primary key.
The IOT can also have some disadvantages, such as the need for an Overflow table to handle the extra data when a row doesn't conveniently fit in a block (implying multiple I/Os), and an extra translation table if bitmap indexes are required (implying extra I/Os).
An unintelligent developer will generally believe that Oracle and SQL Server are the same - after all they both run SQL - and will attempt to port by a simple translation of syntax.
An intelligent developer will test both styles of tables, during a port. Such a developer will also be quick to learn about the changes in internals (such as locking mechanisms) and will realize that different styles of coding are required for many application situations.
I recommend reading Tom Kyte's books to get handle on pros and cons as well as testing techniques to help a developer become intelligent. -
ACCESSING MULTIPLE TABLES THRU ONE SELECT STATEMENTS
How to access multiple tables through one single select statement and also using where condition in it for multiple fields which are from different tables. please give me any example from any tables ....thanks in advance
See the below example code :
REPORT ZMM_COST no standard page heading
line-size 255
message-id zwave .
type-pools
type-pools : slis.
Tables
tables : mara,
makt,
mbew,
konp,
pgmi,
marc,
RMCP3,
sscrfields,
mvke.
Internal Table for MARC and MARA
data : begin of i_join occurs 0,
matnr like mara-matnr, " Material #
meins like mara-meins, " Unit of Measure
werks like marc-werks, " Plant
zzdept like marc-zzdept," Department
end of i_join.
Internal table for PGMI
data : begin of i_pgmi occurs 0,
werks like pgmi-werks, " Plant,
nrmit like pgmi-nrmit, " Material #
wemit like pgmi-wemit, " Plant
end of i_pgmi.
Internal Table for MBEW
data i_mbew like mbew occurs 0 with header line.
Internal Table for Output
data : begin of i_output occurs 0 ,
matnr like mara-matnr, " Material #
maktx like makt-maktx, " Material Desc
VPRSV like mbew-VPRSV, " Price Control Indicator
VERPR like mbew-VERPR, " Moving Avg Price
meins like mara-meins, " Base Unit of Measure
STPRS like mbew-STPRS, " Standard Price
LPLPR like mbew-LPLPR, " Current Planned Price
ZPLPR like mbew-ZPLPR, " Future Planned Price
VPLPR like mbew-VPLPR, " Previous Planned Price
kbetr like konp-kbetr, " Sales Price
KMEIN like konp-KMEIN, " Sales Unit
margin(5) type p decimals 2,
vmsta like mvke-vmsta, " Material Status.
end of i_output.
Internal Table for A004
data : i_a004 like a004 occurs 0 with header line.
Variables
data : wa_lines type i,
wa_maktx type makt-maktx,
v_flag type c.
ALV Function Module Variables
DATA: g_repid like sy-repid,
gs_layout type slis_layout_alv,
g_exit_caused_by_caller,
gs_exit_caused_by_user type slis_exit_by_user.
DATA: gt_fieldcat type slis_t_fieldcat_alv,
gs_print type slis_print_alv,
gt_events type slis_t_event,
gt_list_top_of_page type slis_t_listheader,
g_status_set type slis_formname value 'PF_STATUS_SET',
g_user_command type slis_formname value 'USER_COMMAND',
g_top_of_page type slis_formname value 'TOP_OF_PAGE',
g_top_of_list type slis_formname value 'TOP_OF_LIST',
g_end_of_list type slis_formname value 'END_OF_LIST',
g_variant LIKE disvariant,
g_save(1) TYPE c,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_exit(1) TYPE c,
gx_variant LIKE disvariant.
data : gr_layout_bck type slis_layout_alv.
Selection-screen
selection-screen : begin of block blk with frame title text-001.
parameters : p_werks like marc-werks default '1000' obligatory.
select-options : s_dept for marc-zzdept obligatory,
s_matnr for mara-matnr,
s_mtart for mara-mtart,
s_vprsv for mbew-VPRSV,
s_PRGRP for RMCP3-PRGRP MATCHCODE OBJECT MAT2 ,
s_vmsta for mvke-vmsta.
selection-screen: end of block blk.
*SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
*PARAMETERS: p_vari LIKE disvariant-variant.
*SELECTION-SCREEN END OF BLOCK b3.
At slection screen events *
*-- Process on value request
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
PERFORM f4_for_variant.
Initialization *
Initialization.
g_repid = sy-repid.
sscrfields-functxt_01 = 'Clear Selection'.
selection-screen function key 1.
AT SELECTION-SCREEN.
case sscrfields-ucomm.
when 'Clear Selection' or 'FC01'.
clear: s_matnr,
p_werks.
refresh: s_matnr,
s_dept,
s_mtart,
s_vprsv,
s_PRGRP,
s_vmsta.
endcase.
Start-of-selection.
start-of-selection.
Clear the all data.
perform clear_data.
Get the data from PGMI Table
perform get_pgmi.
Get the data from MARC and MARA Table
perform get_mara_marc.
Get the data from MBEW Table
perform get_mbew.
Move the data into OUTPUT Table
perform move_output_internal.
*end-of-selection.
end-of-selection.
if not i_output[] is initial.
ALV Function Module
perform print_alv.
endif.
*& Form get_pgmi
Select the data from PGMI Table
FORM get_pgmi.
clear v_flag.
If Product group has a value at Selection-screen.
if not s_prgrp is initial.
select werks nrmit wemit from pgmi into table i_pgmi
where prgrp in s_prgrp
and werks = p_werks
and wemit = p_werks.
v_flag = 'X'.
endif.
ENDFORM. " get_pgmi
*& Form get_mara_marc
Select the data from MARA and MARC
FORM get_mara_marc.
if v_flag = 'X'.
select amatnr ameins bwerks bzzdept into table i_join
from mara as a inner join marc as b on amatnr = bmatnr
for all entries in i_pgmi
where a~matnr in s_matnr
and b~werks = p_werks
and b~zzdept in s_dept
and a~mtart in s_mtart
and a~matnr = i_pgmi-nrmit
and b~werks = i_pgmi-werks.
else.
Get the data from MARA and MARC Table
select amatnr ameins bwerks bzzdept into table i_join
from mara as a inner join marc as b on amatnr = bmatnr
where a~matnr in s_matnr
and b~werks = p_werks
and b~zzdept in s_dept
and a~mtart in s_mtart.
endif.
clear wa_lines.
describe table i_join lines wa_lines.
if wa_lines is initial.
message i000(zwave) with 'List contains no data'.
stop.
endif.
sort i_join by matnr werks zzdept.
ENDFORM. " get_mara_marc
*& Form get_mbew
Select the data from MBEW Table
FORM get_mbew.
Get the data from MBEW.
select * from mbew into table i_mbew
for all entries in i_join
where matnr = i_join-matnr.
clear wa_lines.
describe table i_mbew lines wa_lines.
if wa_lines is initial.
message i000(zwave) with 'List contains no data'.
stop.
endif.
sort i_mbew by matnr bwkey.
ENDFORM. " get_mbew
*& Form move_output_internal
Final Results
FORM move_output_internal.
loop at i_join.
clear wa_maktx.
Compare the data with MVKE Table
select single vmsta from mvke into mvke-vmsta
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'
and vmsta in s_vmsta.
if sy-subrc ne 0.
continue.
else.
i_output-vmsta = mvke-vmsta.
endif.
read table i_mbew with key matnr = i_join-matnr
bwkey = i_join-werks
binary search.
if sy-subrc eq 0.
Price Control Indicator
i_output-VPRSV = i_mbew-VPRSV.
Moving Average Price
i_output-VERPR = i_mbew-VERPR / i_mbew-peinh.
Standard Price
i_output-STPRS = i_mbew-STPRS / i_mbew-peinh.
Current Planned Price
i_output-LPLPR = i_mbew-LPLPR / i_mbew-peinh.
Future Planned Price
i_output-ZPLPR = i_mbew-ZPLPR / i_mbew-peinh.
Previous Planned Price
i_output-VPLPR = i_mbew-VPLPR / i_mbew-peinh.
Base Unit of Measure - Added by Seshu 01/09/2007
i_output-meins = i_join-meins.
else.
continue.
endif.
Get the sales Price.
perform get_sales_data.
if i_mbew-VPRSV = 'V'.
Get the Percentage of Margin
if i_output-kbetr ne '0.00'.
i_output-margin = ( ( i_output-kbetr - i_mbew-VERPR )
/ i_output-kbetr ) * 100 .
endif.
else.
Get the Percentage of Margin
if i_output-kbetr ne '0.00'.
i_output-margin = ( ( i_output-kbetr - i_output-stprs )
/ i_output-kbetr ) * 100 .
endif.
endif.
Get the material Description from MAKT Table
select single maktx from makt into wa_maktx
where matnr = i_join-matnr
and spras = 'E'.
if sy-subrc eq 0.
i_output-matnr = i_join-matnr.
i_output-maktx = wa_maktx.
endif.
append i_output.
clear : i_output,
i_join,
i_mbew.
endloop.
ENDFORM. " move_output_internal
*& Form get_sales_data
Get the Sales Price for each material
FORM get_sales_data.
Get the data from A004 table to get KNUMH
Added new field Sales Unit - Seshu 01/09/2006
refresh : i_a004.
clear : i_a004.
data : lv_kbetr like konp-kbetr," Condition value
lv_KPEIN like konp-kpein , "per
lv_KMEIN like konp-KMEIN. " Sales Unit
select * from a004 into table i_a004
where matnr = i_join-matnr
and vkorg = '0001'
and vtweg = '01'.
if sy-subrc eq 0.
sort i_a004 by DATAB descending.
Get the Latetest Date
read table i_a004 with key matnr = i_join-matnr
vkorg = '0001'
vtweg = '01'
binary search.
Get the Sales Value
select single kbetr KPEIN KMEIN from konp
into (lv_kbetr,lv_KPEIN, lv_KMEIN)
where knumh = i_a004-knumh
and kappl = i_a004-kappl
and kschl = i_a004-kschl.
if sy-subrc eq 0.
i_output-kbetr = lv_kbetr / lv_KPEIN.
i_output-KMEIN = lv_KMEIN.
endif.
endif.
clear : lv_kbetr,
lv_kpein,
lv_KMEIN.
ENDFORM. " get_sales_data
*& Form print_alv
ALV Function Module
FORM print_alv.
Fill the Fiedlcat
PERFORM fieldcat_init using gt_fieldcat[].
gr_layout_bck-edit_mode = 'D'.
gr_layout_bck-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = g_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = g_user_command
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gr_layout_bck
IT_FIELDCAT = gt_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = g_save
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = i_output
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " print_alv
*& Form fieldcat_init
Fieldcat
FORM fieldcat_init USING e01_lt_fieldcat type slis_t_fieldcat_alv.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
Material #
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MATNR'.
LS_FIELDCAT-ref_fieldname = 'MATNR'.
LS_FIELDCAT-ref_tabname = 'MARA'.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material'.
ls_fieldcat-seltext_M = 'Material'.
ls_fieldcat-seltext_S = 'Material'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Description
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MAKTX'.
LS_FIELDCAT-OUTPUTLEN = 35.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Description'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Price Indicator
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VPRSV'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Price Control Indicator'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Moving Avg Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VERPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Moving Avg Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Base Unit of Measure
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MEINS'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Base Unit'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Standard Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'STPRS'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Standard Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Current Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'LPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Current Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Future Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'ZPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Future Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Previous Planned Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VPLPR'.
LS_FIELDCAT-OUTPUTLEN = 11.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Previous Planned Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Sales Price
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KBETR'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Sales Price'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Sales Unit
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'KMEIN'.
LS_FIELDCAT-OUTPUTLEN = 7.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Sales Unit'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
% of Gross Margin
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'MARGIN'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = '% of Gross Margin'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
Material Status
CLEAR LS_FIELDCAT.
LS_FIELDCAT-FIELDNAME = 'VMSTA'.
LS_FIELDCAT-OUTPUTLEN = 13.
LS_FIELDCAT-TABNAME = 'I_OUTPUT'.
ls_fieldcat-seltext_L = 'Material Status'.
APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
ENDFORM. " fieldcat_init
**& Form f4_for_variant
text
*FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = g_variant
i_save = g_save
i_tabname_header = g_tabname_header
i_tabname_item = g_tabname_item
it_default_fieldcat =
IMPORTING
e_exit = g_exit
es_variant = gx_variant
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF g_exit = space.
p_vari = gx_variant-variant.
ENDIF.
ENDIF.
*ENDFORM. " f4_for_variant
*& Form clear_data
Clear the Internal table
FORM clear_data.
clear : i_output,
i_join,
i_mbew,
i_a004,
i_pgmi.
refresh : i_output,
i_join,
i_mbew,
i_a004,
i_pgmi.
ENDFORM. " clear_data
FORM USER_COMMAND *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield. "#EC CALLED
CASE R_UCOMM.
WHEN '&IC1'.
read table i_output index rs_selfield-tabindex.
SET PARAMETER ID 'MAT' FIELD i_output-matnr.
SET PARAMETER ID 'WRK' FIELD p_werks.
if not i_output-matnr is initial.
call transaction 'MD04' and skip first screen.
endif.
ENDCASE.
ENDFORM.
Reward Points if it is helpful
Thanks
Seshu -
Select from multiple tables without join statement
Hey Gurus,
I would like to make a select from a multiple tables to check if there is any reference to my data. I would like to do it with some elegancy, but I don't know how.
Is in abap sql possible to do it only with the select statement?
Or I was also think about a solution that I should fill some data structure with all of the tables which I want to select from and then just loop that data structure and do the select seperately from all of the tables. I just need to check if it founds some results, so no need to store it. If this solution would be fine what data structure should I use?
Or can tell me what would be the best for this?
My code for select from one table, which I want to make for multiple tables:
SELECT SINGLE id_kniznice FROM zbr_t_autori INTO wa_id
WHERE id_kniznice EQ ls_extract-zview-id_kniznice.
IF sy-dbcnt > 0.
MESSAGE i000(zbr_msgc_lib).
ls_extract-flags-vim_mark = '*'.
MODIFY extract FROM ls_extract.
ENDIF.
Thank you for any posts.
Regards,
RobertAnd there we go again...
Read this topic:
For All Entries is NOT better than INNER JOIN in most cases
And this one:
inner join vs for all entries
Also that one:
Re: LOOP AT vs INNER JOIN
JOINs are really better than for all entries in most cases. Problem is people tend to ignore basic things like using pks or indexes while making them. -
Single result set across multiple tables
Hi - what's the best way to perform a single query that can pull
a single result set across multiple tables, ie., a master table
containing subject details and child table containing multiple
records with detail.
I know how to do this for two columns in the same table via
indexing, but how about across tables?
Cheers,
JohnI am not sure if I understood your question, but you can use
Intermedia Text with USER_DATA_STORE to create an index with data
source from multiple tables.
(see technet.oracle.com -> products -> oracle text)
Thomas -
How can one make a Distinct Multiplication Table ?
This Code make Multiplication Table :-
BEGIN
FOR I IN 1.. 12 LOOP
DBMS_OUTPUT.PUT_LINE('---------------------['
||I
||']----------------------');
FOR J IN 1.. 12 LOOP
DBMS_OUTPUT.PUT_LINE(I
||'*'
||J
||'='
||I * J);
END LOOP;
END LOOP;
END;
---------------------[1]----------------------
1*1=1
1*2=2
1*3=3
1*4=4
1*5=5
1*6=6
1*7=7
1*8=8
1*9=9
1*10=10
1*11=11
1*12=12
---------------------[2]----------------------
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
11*7=77
11*8=88
11*9=99
11*10=110
11*11=121
11*12=132
---------------------[ 12 ]----------------------
12*1=12
12*2=24
12*3=36
12*4=48
12*5=60
12*6=72
12*7=84
12*8=96
12*9=108
12*10=120
12*11=132
12*12=144
PL/SQL procedure successfully completed.
=====================
that's good , but I want to change my code to perform a distinct results .
by accurate meaning , if this result happen ( 1*12=12) than I don't it repeat
again like (12*1=12) or (2*6=12) .... ect.
is there any suggest ?!Just store your results in hash table and before output check, whether results already been produced.
declare
type res_t is table of number index by binary_integer;
results res_t;
begin
for i in 1 .. 12 loop
dbms_output.put_line('---------------------[' || i ||
for j in 1 .. 12 loop
if not results.exists(i * j) then
dbms_output.put_line(i || '*' || j || '=' || i * j);
results(i * j) := i * j;
end if;
end loop;
end loop;
end;Best regards
Maxim -
Hi,
So far I have success using XSU to store an XML file to a single table datawise where each element of the XML correspond to the field name of the table.
But I have couple of questions.
1. I am still using ROWSET and ROW tags in my XML. Can i change it to something meaningful say...PRODUCTS and PRODUCT respectively? If so how can i do that?
2. How do i stored an XML onto more than one table. Each PRODUCT have some linked information to be stored in another table. How can i do this?
Basically this time the XML will look somewhat like this:
<?xml version="1.0" ?>
<ROWSET>
<ROW num="0">
<BRAND>brand name</BRAND>
<CATEGORY>category</CATEGORY>
<ROWSET1>
<ROW1>
<MERCHANT>merchant name</MERCHANT>
</ROW1>
</ROWSET1>
</ROW>
</ROW>
</ROWSET>
Please help me. Thank you.
Regards,
Abdul RasheedHi,
search this xml form for 'multiple tables' and you will learn a lot about it. it seems that using XSU you can only to save to one table or a view. Possible solutions are:
1. create a view over those tables. If your view is complex and not
updatable then you can use insteadof triggers with your
non-updatable view"
2. split your mutl-level XML to several single level XML files and save each xml seperately.
3. And another person was nice enough to mail me the following solution, which might be of help. i copy the mail here...
I saw your message in the XML oracle forum, and i've just finished a small project for my company in doing things like saving an XML document to a DB table.
I think that saving the XML document in one or many tables is not different because what you need is to build dynamic SQL queries to update your tables so you need to guess the setter part of the querry.
UPDATE my_table SET column1=value1,column2=value2... WHERE table_key=key_value.
the best way to do the job is to use an XSLT processor, you give it your XML document and an XSL document for filtering the output.
the output of the XSLT processor could look like:
<?xml version="1.0" ?>
<ROOT>
<TABLEROW table="table1">
<COLUMN1_1>value1_1</COLUMN>
</TABLEROW>
<TABLEROW table="table2">
<COLUMN1_2>value1_2</COLUMN>
</TABLEROW>
</ROOT>
now it's easier to guess the SQL queries all you have to do is to parse this output document and say in you code something like:
String[NBR_OF_TABLES] Queries;
int i=0;
-- Loop inside the xml document {
Queries="UPDATE ";
Queries[i]=+(curent_node.getAttribute("table")).getNodeValue();
-- Loop inside the curent node {
column_name=current_node.getNodeName();
column_value=curent_node.getChild().getNodeValue();
Queries[i]=+" SET "+column_name+"="+column_value; //FIRST TIME
Queries[i]=+","+column_name+"="+column_value; //2,3,4...
you may need some type conversion, from string to numbers,and dates, and the WHERE part of the query is up to your indexation mecanism
of course you can put the tables primary keys values and names rigth in the yout XML document.
and last you simply execute the Array of queries you have:
for (int i=0i<NBR_OF_TABLES;i++)
execute(Queries[i]) .
hope this helps.
abdul rasheed
Maybe you are looking for
-
Unable to access options in Adobe Acrobat X Pro
I had to reinstall my copy of Adobe Acrobat X Pro on a new computer. I did the complete installation. However, I can no longer access certain options that I normally use. These options are all grayed out. For example, I cannot select the "insert
-
How to locate "save" on download ?
I am able to downlaod Adobe as I see the bar downloading but I can't find a "save" featufe as required. Hos o I save and successfully install?
-
When you "Send Movie to Final Cut Pro" and you cancel Rendering and how
I am moving from iMovie to Final Cut Pro and have multiple movies to send to Final Cut Pro. I would like to cancel the rendering in FCP until I actuall need it.
-
Fetching iviews not assigned to a page,workset or a role(orphaned iviews)
Hi All, I need to fetch iviews,pages ,worksets ,roles that have not been assigned and are not used.The iview is not assigned to a page,workset ,role,similarly a page need not be assigned to a page,workset,role and similarly for a workset and a role.
-
Hello, I've created a tree in web dynpro. This tree is filled with names of employees. I want to sort it by the names. 1: I create a Comparator: public class ElementsComparator implements java.util.Comparator{ public int compare(final Object