How to fetch rows from multiple tables
I have a page with items from 3 tables. I need to populate these items with values from the database. The page does not allow me to use multiple automated fetches. So instead I decided to use a pl/sql page process that runs a cursor to get my field values and the uses apex_util.set_session_state to set the field item values. IS there any isues with doing this? Is there a better way?
These tables are not really related so I gues I will stick with the pl/sql to populate and then page process to insert/update/delete. Here is the code I'm using.
Chris
DECLARE
CURSOR get_info IS
select A.FK_STU_BASE, A.FK_CONTACT, A.FK_RELATION, A.PRIORITY, A.CAN_PICK_UP_STUDENT,
A.GETS_STX, A.GETS_STG, A.GETS_STA, A.GETS_DIS, A.GETS_THX, A.GETS_MED,
A.GETS_MAIL, A.NOTES as STUDENT_NOTES, A.USER_FLD1, A.USER_FLD2, A.USER_FLD3,
A.USER_FLD4, A.USER_FLD5, A.LAST_UPDATE_DATE, A.LAST_UPDATE_USER,
B.PK_ID as CONTACT_PK_ID, B.FIRST_NAME, B.LAST_NAME, B.MIDDLE_INIT, B.PREFIX,
B.SUFFIX, B.FK_LANGUAGE, B.PHONE, B.PHONE_UNLISTED, B.PHONE_EXTENSION,
B.PHONE_DESCRIPTION, B.EMERGENCY_PHONE, B.EMERGENCY_UNLISTED, B.EMERGENCY_EXTENSION,
B.EMERGENCY_DESCRIPTION, B.CELL_PHONE, B.CELL_UNLISTED, B.CELL_EXTENSION,
B.CELL_DESCRIPTION, B.CELL2_PHONE, B.CELL2_UNLISTED, B.CELL2_EXTENSION,
B.CELL2_DESCRIPTION, B.WORK1_PHONE, B.WORK1_UNLISTED, B.WORK1_EXTENSION,
B.WORK1_DESCRIPTION, B.WORK2_PHONE, B.WORK2_UNLISTED, B.WORK2_EXTENSION,
B.WORK2_DESCRIPTION, B.FAX_PHONE, B.FAX_DESCRIPTION, B.EMAIL1, B.EMAIL2,
B.NOTES as CONTACT_NOTES, B.FK_LODGING, B.FK_EDUCATION_LEVEL,
C.PK_ID as LODGING_PK_ID, C.FK_ZIP, C.FK_DISTRICT, C.HOUSE_NO, C.LETTER,
C.DIRECTION, C.STREET, C.STREET2, C.PLUS4, C.APT, C.FK_GRIDCODE,
C.FK_MUNICIPALITY, C.OPTIONAL_INFO1, C.OPTIONAL_INFO2, C.OPTIONAL_INFO3,
C.FK_DWELLING, C.OPTIONAL_ZIPCODE
from contact_link A,
contact B,
lodging C
where A.PK_ID = :P470_CONTACT_LINK_PK_ID and
B.PK_ID (+) = A.FK_CONTACT and
C.PK_ID (+) = B.FK_LODGING;
BEGIN
FOR x in get_info LOOP
-- Set Contact Link Items
APEX_UTIL.SET_SESSION_STATE('P470_FK_STU_BASE',X.FK_STU_BASE);
APEX_UTIL.SET_SESSION_STATE('P470_FK_CONTACT',X.FK_CONTACT);
APEX_UTIL.SET_SESSION_STATE('P470_FK_RELATION',X.FK_RELATION);
APEX_UTIL.SET_SESSION_STATE('P470_PRIORITY',X.PRIORITY);
APEX_UTIL.SET_SESSION_STATE('P470_CAN_PICK_UP_STUDENT',X.CAN_PICK_UP_STUDENT);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_STX',X.GETS_STX);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_STG',X.GETS_STG);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_STA',X.GETS_STA);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_DIS',X.GETS_DIS);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_THX',X.GETS_THX);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_MED',X.GETS_MED);
APEX_UTIL.SET_SESSION_STATE('P470_GETS_MAIL',X.GETS_MAIL);
APEX_UTIL.SET_SESSION_STATE('P470_STUDENT_NOTES',X.STUDENT_NOTES);
APEX_UTIL.SET_SESSION_STATE('P470_USER_FLD1',X.USER_FLD1);
APEX_UTIL.SET_SESSION_STATE('P470_USER_FLD2',X.USER_FLD2);
APEX_UTIL.SET_SESSION_STATE('P470_USER_FLD3',X.USER_FLD3);
APEX_UTIL.SET_SESSION_STATE('P470_USER_FLD4',X.USER_FLD4);
APEX_UTIL.SET_SESSION_STATE('P470_USER_FLD5',X.USER_FLD5);
APEX_UTIL.SET_SESSION_STATE('P470_LAST_UPDATE_DATE',X.LAST_UPDATE_DATE);
APEX_UTIL.SET_SESSION_STATE('P470_LAST_UPDATE_USER',X.LAST_UPDATE_USER);
--Set Contact Items
APEX_UTIL.SET_SESSION_STATE('P470_CONTACT_PK_ID',X.CONTACT_PK_iD);
APEX_UTIL.SET_SESSION_STATE('P470_FIRST_NAME',X.FIRST_NAME);
APEX_UTIL.SET_SESSION_STATE('P470_LAST_NAME',X.LAST_NAME);
APEX_UTIL.SET_SESSION_STATE('P470_MIDDLE_INIT',X.MIDDLE_INIT);
APEX_UTIL.SET_SESSION_STATE('P470_PREFIX',X.PREFIX);
APEX_UTIL.SET_SESSION_STATE('P470_SUFFIX',X.SUFFIX);
APEX_UTIL.SET_SESSION_STATE('P470_FK_LANGUAGE',X.FK_LANGUAGE);
APEX_UTIL.SET_SESSION_STATE('P470_PHONE',X.PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_PHONE_UNLISTED',X.PHONE_UNLISTED);
APEX_UTIL.SET_SESSION_STATE('P470_PHONE_EXTENSION',X.PHONE_EXTENSION);
APEX_UTIL.SET_SESSION_STATE('P470_PHONE_DESCRIPTION',X.PHONE_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_EMERGENCY_PHONE',X.EMERGENCY_PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_EMERGENCY_UNLISTED',X.EMERGENCY_UNLISTED);
APEX_UTIL.SET_SESSION_STATE('P470_EMERGENCY_EXTENSION',X.EMERGENCY_EXTENSION);
APEX_UTIL.SET_SESSION_STATE('P470_EMERGENCY_DESCRIPTION',X.EMERGENCY_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_CELL_PHONE',X.CELL_PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_CELL_UNLISTED',X.CELL_UNLISTED);
APEX_UTIL.SET_SESSION_STATE('P470_CELL_EXTENSION',X.CELL_EXTENSION);
APEX_UTIL.SET_SESSION_STATE('P470_CELL_DESCRIPTION',X.CELL_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_CELL2_PHONE',X.CELL2_PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_CELL2_UNLISTED',X.CELL2_UNLISTED);
APEX_UTIL.SET_SESSION_STATE('P470_CELL2_EXTENSION',X.CELL2_EXTENSION);
APEX_UTIL.SET_SESSION_STATE('P470_CELL2_DESCRIPTION',X.CELL2_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_WORK1_PHONE',X.WORK1_PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_WORK1_UNLISTED',X.WORK1_UNLISTED);
APEX_UTIL.SET_SESSION_STATE('P470_WORK1_EXTENSION',X.WORK1_EXTENSION);
APEX_UTIL.SET_SESSION_STATE('P470_WORK1_DESCRIPTION',X.WORK1_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_WORK2_PHONE',X.WORK2_PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_WORK2_UNLISTED',X.WORK2_UNLISTED);
APEX_UTIL.SET_SESSION_STATE('P470_WORK2_EXTENSION',X.WORK2_EXTENSION);
APEX_UTIL.SET_SESSION_STATE('P470_WORK2_DESCRIPTION',X.WORK2_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_FAX_PHONE',X.FAX_PHONE);
APEX_UTIL.SET_SESSION_STATE('P470_FAX_DESCRIPTION',X.FAX_DESCRIPTION);
APEX_UTIL.SET_SESSION_STATE('P470_EMAIL1',X.EMAIL1);
APEX_UTIL.SET_SESSION_STATE('P470_EMAIL2',X.EMAIL2);
APEX_UTIL.SET_SESSION_STATE('P470_CONTACT_NOTES',X.CONTACT_NOTES);
APEX_UTIL.SET_SESSION_STATE('P470_FK_LODGING',X.FK_LODGING);
APEX_UTIL.SET_SESSION_STATE('P470_FK_EDUCATION_LEVEL',X.FK_EDUCATION_LEVEL);
--Set Lodging Items
APEX_UTIL.SET_SESSION_STATE('P470_LODGING_PK_ID',X.LODGING_PK_ID);
APEX_UTIL.SET_SESSION_STATE('P470_FK_ZIP',X.FK_ZIP);
APEX_UTIL.SET_SESSION_STATE('P470_FK_DISTRICT',X.FK_DISTRICT);
APEX_UTIL.SET_SESSION_STATE('P470_HOUSE_NO',X.HOUSE_NO);
APEX_UTIL.SET_SESSION_STATE('P470_LETTER',X.LETTER);
APEX_UTIL.SET_SESSION_STATE('P470_DIRECTION',X.DIRECTION);
APEX_UTIL.SET_SESSION_STATE('P470_STREET',X.STREET);
APEX_UTIL.SET_SESSION_STATE('P470_STREET2',X.STREET2);
APEX_UTIL.SET_SESSION_STATE('P470_PLUS4',X.PLUS4);
APEX_UTIL.SET_SESSION_STATE('P470_APT',X.APT);
APEX_UTIL.SET_SESSION_STATE('P470_FK_GRIDCODE',X.FK_GRIDCODE);
APEX_UTIL.SET_SESSION_STATE('P470_FK_MUNICIPALITY',X.FK_MUNICIPALITY);
APEX_UTIL.SET_SESSION_STATE('P470_OPTIONAL_INFO1',X.OPTIONAL_INFO1);
APEX_UTIL.SET_SESSION_STATE('P470_OPTIONAL_INFO2',X.OPTIONAL_INFO2);
APEX_UTIL.SET_SESSION_STATE('P470_OPTIONAL_INFO3',X.OPTIONAL_INFO3);
APEX_UTIL.SET_SESSION_STATE('P470_FK_DWELLING',X.FK_DWELLING);
APEX_UTIL.SET_SESSION_STATE('P470_OPTIONAL_ZIPCODE',X.OPTIONAL_ZIPCODE);
END LOOP;
END;
Similar Messages
-
How to fetch rows from a table like search engines do?
Is it possible to fetch rows from a table like Google does? I want to fetch row number 20-40 after the select has ordered the rows.
Pseudo code: select * from log where rownum > 20 and rownum < 40 order by date;
Rownum doesn't work with ordering so I tried:
select * from log where (select * from log order by date) and rownum <20;
But that still doesn't do what I want. I get the "top 20" rows but I can't get rows 20-40.
My real table has 70000 rows and I want to select 69000-70000 so I really need a SQL do fetch only the rows I need.
Any help would be very appreciated!
Best regards,
Christer NordvikSELECT alias_for_rownum, column_names
FROM (SELECT ROWNUM AS alias_for_rownum, column_names
FROM (SELECT column_names
FROM table_name
ORDER BY columns_to_order_by)
WHERE ROWNUM <= last_row_you_want)
WHERE alias_for_rownum >= first_row_you_want
Example:
-- (This example uses the Oracle dept demo table.
SET AUTOTRACE ON EXPLAIN
SELECT rn, deptno, dname, loc
FROM (SELECT ROWNUM AS rn, deptno, dname, loc
FROM (SELECT deptno, dname, loc
FROM dept
ORDER BY deptno)
WHERE ROWNUM <= 3)
WHERE rn >= 2
RN DEPTNO DNAME LOC
2 20 RESEARCH DALLAS
3 30 SALES CHICAGO -
How to delete rows from multiple tables when pressing button
Hi, I'm wondering how do I delete a row from two different tables at the same time when I press the Delete button. Both tables have GROUP_ID as their primary key.
Nevermind! I realized that I had "reset" before my process to delete from the 2nd table.
-
Generic datasource by function module to fetch data from multiple tables?
I'm writing a function module to fetch price, for generic datasource.
At first, extract test is OK. But InfoPackage never stop when loading data to PSA in BW.
And I find the example codes:
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT
WHERE CARRID IN L_R_CARRID AND
CONNID IN L_R_CONNID.
ENDIF. "First data package ?
* Fetch records into interface table.
* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDS
OF TABLE E_T_DATA
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
ENDIF.
There using Cursor to fetch data package by package, and raise exception NO_MORE_DATA to stop the loading process.
Now I fetch data from multiple tables, I don't think I can use Cursor.
Then How can I handle this?
Thanks a lot.Thanks
IF IT_999[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
( ( A~KSCHL = 'ZPRC' AND VKORG = 'Z000' AND VTWEG = 'Z1' ) OR
( A~KSCHL = 'ZPRD' AND VKORG = 'A000' AND VTWEG = 'Y3' ) ) AND
* A~DATBI >= SY-DATUM AND
LOEVM_KO = ''.
SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A999 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_999
WHERE
* A~KNUMH = IT_999-KNUMH AND
A~KSCHL = 'ZPR3' AND A~VKORG = 'I000' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_997[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A997 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_997
WHERE
* A~KNUMH = IT_997-KNUMH AND
A~KSCHL = 'ZPRA' AND VTWEG = 'Y1' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
IF IT_996[] IS INITIAL.
SELECT A~KNUMH A~MATNR A~KSCHL A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
TABLE TP_DATA
FROM A996 AS A
INNER JOIN KONP AS B
ON A~KNUMH = B~KNUMH
INNER JOIN MARA AS C
ON A~MATNR = C~MATNR
* FOR ALL ENTRIES IN IT_996
WHERE
* A~KNUMH = IT_996-KNUMH AND
A~KSCHL = 'ZPRB' AND
* DATBI >= SY-DATUM AND
LOEVM_KO = ''.
ENDIF.
SELECT MATNR "u7269u6599u53F7u7801
MEINH "u4ED3u50A8u5355u4F4Du7684u5907u7528u8BA1u91CFu5355u4F4D
UMREZ "u57FAu672Cu8BA1u91CFu5355u4F4Du8F6Cu6362u5206u5B50
UMREN "u8F6Cu6362u4E3Au57FAu672Cu8BA1u91CFu5355u4F4Du7684u5206u6BCD
FROM MARM
INTO CORRESPONDING FIELDS OF TABLE IT_MARM
FOR ALL ENTRIES IN TP_DATA
WHERE MATNR = TP_DATA-MATNR AND MEINH = TP_DATA-KMEIN.
LOOP AT TP_DATA.
IF TP_DATA-KPEIN NE 0.
TP_DATA-KBETR = TP_DATA-KBETR / TP_DATA-KPEIN.
TP_DATA-KHETR = TP_DATA-KHETR / TP_DATA-KPEIN.
ENDIF.
IF TP_DATA-KSCHL = 'ZPRA'.
* TP_DATA-MEINH = 'ZI'.
* TP_DATA-KSCHL = 'B4'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'CT'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRB'.
* TP_DATA-KSCHL = 'L0'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPRC' OR TP_DATA-KSCHL = 'ZPRD'.
* TP_DATA-MEINH = 'ZI'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'WZI'.
TP_DATA-KBETR = TP_DATA-KBETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
ENDIF.
ELSEIF TP_DATA-KSCHL = 'ZPR3'.
* TP_DATA-KSCHL = 'B2'.
IF TP_DATA-KMEIN = 'ZI'.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ELSE.
READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
* READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
* * WA_MARM2-UMREZ / WA_MARM2-UMREN.
TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
ENDIF.
ENDIF.
TP_DATA-MEINH = '01'.
MODIFY TP_DATA.
E_T_DATA-MATNR = TP_DATA-MATNR.
E_T_DATA-KSCHL = TP_DATA-KSCHL.
E_T_DATA-KHETR = TP_DATA-KHETR.
E_T_DATA-KBETR = TP_DATA-KBETR.
E_T_DATA-KMEIN = TP_DATA-KMEIN.
E_T_DATA-DATAB = TP_DATA-DATAB.
E_T_DATA-DATBI = TP_DATA-DATBI.
APPEND E_T_DATA.
CLEAR WA_MARM1.
CLEAR WA_MARM2.
ENDLOOP.
Edited by: Shen Peng on Oct 20, 2010 10:09 AM -
Deleting Multiple Rows From Multiple Tables As an APEX Process
Hi There,
I'm interesting in hearing best practice approaches for deleting multiple rows from multiple tables from a single button click in an APEX application. I'm using 3.0.1.008
On my APEX page I have a Select list displaying all the Payments made and a user can view individual payments by selecting a Payment from the Select List (individual items are displayed below using Text Field (Disabled, saves state) items with a source of Database Column).
A Payment is to be deleted by selecting a custom image (Delete Payments Button) displayed in a Vertical Images List on the same page. The Target is set as the same page and I gave the Request a name of DELETEPAY.
What I tried to implement was creating a Conditional Process On Submit - After Computations and Validations that has a source of a PL/SQL anonymous block as follows:
BEGIN
UPDATE tblDebitNotes d
SET d.Paid = 0
WHERE 1=1
AND d.DebitNoteID = :P7_DEBITNOTEID;
INSERT INTO tblDeletedPayments
( PaymentID,
DebitNoteID,
Amount,
Date_A,
SupplierRef,
Description
VALUES
( :P7_PAYMENTID,
:P7_DEBITNOTEID,
:P7_PAID,
SYSDATE,
:P7_SUPPLIERREF,
:P7_DESCRIPTION
DELETE FROM tblPayments
WHERE 1=1
AND PaymentID = :P7_PAYMENTID;
END;
The Condition Type used was Request = Expression 1 where Expression 1 had a value of DELETEPAY
However this process is not doing anything!! Any insights greatly appreciated.
Many thanks,
Gary....the "button" is using a page level Target,...
I'm not sure what that means. If the target is specified in the definition of a list item, then clicking on the image will simply redirect to that URL. You must cause the page to be submitted instead, perhaps by making the URL a reference to the javaScript doSubmit function that is part of the standard library shipped with Application Express. Take a look at a Standard Tab on a sample application and see how it submits the page using doSubmit() and emulate that.
Scott -
How to fetch data from PTREQ tables
I need to display data in the customised webdynpro application from PTREQ tables.
Can anyone help me out how to fetch data from these tables.use the standard modules like
PT_ARQ_REQUEST_CHECK
PT_ARQ_REQUEST_EXECUTE
PT_ARQ_REQUEST_PREPARE -
How to fetch data from cluster tables
hi
i need to know how to fetch data from cluster tables please update me if any
i know that we cannot use joins in cluster table we use view etc
but i need detailed inforation on methods for fetching data from cluster tables
regards
NishantHi,
Check the following links
http://fuller.mit.edu/hr/cluster_tables.html
The specified item was not found.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33 -
How to fetch rows from PL/SQL table(Collections)
Hi,
I retrived rows from the table and stored in to table type.
Now I want fetch these rows and display on the screen. Pls guide me.
following code is my code:
DECLARE
type t1 is table of emp%rowtype index by binary_integer;
var1 t1;
v_counter number:=0;
BEGIN
select * bulk collect into var1 from emp;
for vr in var1.first..var1.last
loop
dbms_output.put_line(var1(1)); --Got an Error Here. Acually I don't Know how to fetch.
update dept set deptno=var1.deptno --Here also Error occured.
end loop;
END;Fetching rows to display them is a task for the client tool. You need to define a ref cursor therefore.
If you just want to play around, here we go
SQL> DECLARE
2 type t1 is table of emp%rowtype index by binary_integer;
3 var1 t1;
4 v_counter number:=0;
5 BEGIN
6 select * bulk collect into var1 from emp;
7 for vr in 1..var1.count loop
8 dbms_output.put_line(var1(vr).ename);
9 update dept set deptno=var1.deptno Here also Error occured.
10 end loop;
11 END;
12 /
SCOTT
ADAMS
PL/SQL procedure successfully completed.
SQL> -
Sender JDBC Adapter : Fetch records from multiple tables
Hi Friends,
I am using sender JDBC adapter to select few records from DB2 database table.
This scenario is working fine.
Now my requirement is to fetch records from 3 tables. These table are independent to each other. There is no primary key or foreign key.
Please let me know how to write the sql in sender JDBC adapter to fetch records from these 3 tables.
Thanks,
Sandeep Mauryahi sandeep...
if the tables are completely independent and do not share any primary / foreign key relation ship...
why dont u think towards creating a seperate interface for each of them..
or if u still want to select from multiple table at once..the best way would be to write a stored procedure on the sender side which do all the fetching n processing and pass the final resultset to PI
or u can think towards fetching the data from 1 table and then in UDF do lookup from other tables..which again is tricky and performace intensive -
How to extract data from multiple tables (always got errors)
Dear Experts,
I have a simple mapping to extract data from multiple tables as a source (A, B, C) to a target table (X). Below is the picture:
(Sources)....(Target)
A----------------***
B----------------X
C----------------***
Sample Source Data:
Table A:
ColA1
100
200
etc
Table B:
ColB1 ColB2 ColB3
10 Y Ten
20 Y Twenty
30 Y Thirty
etc
Table C:
ColC1 ColC2
11
12
13
etc
Target table (X) should be (just has 1 group INGRP1):
ColA1 ColB1 ColB3 ColC1
100 10 Ten 11
100 10 Ten 12
100 20 Twenty 21
etc
Scenarios:
1. Directly map from A, B, C to X. Unable to map with error message: "API8003: Connection target attribute group is already connected to an incompatible data source. Use a Joiner or Set operator to join the upstream data first before connecting it into this operator."
2. Map each source to Expression Operator and then map from each Expression to target table. I am able to map all attributes successfully but got error when validating it with message: "VLD-1104: Attributes flowing into TEST.EXPR_SRC.INGRP1 have different data sources."
How can I achieve the correct mapping for this purpose?
Use Joiner? I have no key to join the sources
Use Set? The sources have different number of columns
Thanks in advance
PratThanks Nico,
I think it will results data like this:
100 10 Ten 11
200 20 Twenty 12
300 30 Thirty 13
etc
and not the expected:
100 10 Ten 11
100 10 Ten 12
100 20 Twenty 21
etc
But it inspired me to solve this by adding key expression in each source table (B & C) to be joined to table A with this formula:
100+TRUNC(INGRP1.COLB1,-2)
Regards
Prat -
JDBC-XI-FILE scenario. How to extract data from multiple tables
Hi,
At this moment I didn't have the access for XI system. So here I have some silly question. Could you please clarify the same ??
If I got to extract data from single table using JDBC adapter I can put the below query in communication channel
SELECT *FROM orders WHERE new='true'.
But if I got to extract data from multiple tables, logic to be used should be like as shown below. ( from previous thread------prabhu).
SELECT <Table_2>.EID, <Table_2>.FName, <Table_2>.LName, <Table_1>.REC_DAT, <Table_1>.DESCRP
FROM <Table_1> INNER JOIN <Table_2> on
<Table_1>.CARDNO = <Table_2>.CARD
where REC_DAT = <condition>
union
SELECT <Table_2>.EID, <Table_2>.FName, <Table_2>.LName, <Table_1>.REC_DAT, <Table_1>.DESCRP
FROM <Table_1> INNER JOIN <Table_2> on
<Table_1>.CARDNO = <Table_2>.CARD
where REC_DAT = <condition>
But my query is ........how to put the above entire code in one line. (i.e in Qery place of communication channel ) ??
Thanks
KumarHi Palnati,
You either use a select query with join or a stored procedure which will contain the logic to extract the data from multiple tables. But, the limitation in case of stored procedure is u can hv only one selct query in it.
You write ur actual query provided in the parameter 'Query SQL Statement". u can also wrt a stored procedure in it. Also, u can provide a update statement in it which will update a certain flag so tht u don selct the data again.
Check the following link
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm</a>
Regards,
Akshay
Message was edited by:
Akshay Salunke -
Hey guys how to fetch data from db table using subroutine
hi guys,
I am fetching data from db table "mcha". now in the follwing code i get it in "HSDAT1_DATE."
now when i read out_tab with key "HSDAT1". it wont come in out_tab-value.plz tell me what is wrong whether some key condition in out_tab or any thing else.
and what should i write in changing && in script.
thanks in advance
FORM DATE_MGF TABLES IN_TAB STRUCTURE ITCSY
OUT_TAB STRUCTURE ITCSY.
tables :MCHA ,QALS.
DATA : WERKS1 LIKE QALS-WERK.
DATA : HSDAT1 LIKE MCHA-HSDAT.
DATA : DATE(2),
MONTH(2),
YEAR(4).
DATA : HSDAT1_DATE(10).
READ TABLE IN_TAB WITH KEY 'QALS-WERK'.
LOOP AT IN_TAB.
IF SY-TABIX EQ 1.
WERKS1 = IN_TAB-VALUE.
IF WERKS1 NE SPACE.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
SELECT SINGLE HSDAT INTO HSDAT1
FROM MCHA
WHERE WERKS = WERKS1.
DATE = HSDAT1+6(2).
MONTH = HSDAT1+4(2).
YEAR = HSDAT1+0(4).
CONCATENATE DATE '.' MONTH '.' YEAR INTO HSDAT1_DATE.
READ TABLE OUT_TAB WITH KEY 'HSDAT1' .
IF SY-SUBRC = 0.
OUT_TAB-VALUE = HSDAT1.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.Hi,
Let me understanf clearly what you want.
initally mine out_tab is blank
According to you, your table out_tab is blank. And you need to add out_tab-value = HSDAT1_date.
READ TABLE OUT_TAB WITH KEY 'HSDAT1' .
IF SY-SUBRC = 0.
OUT_TAB-VALUE = HSDAT1.
MODIFY OUT_TAB INDEX SY-TABIX.
ENDIF.
So, if your table is blank, then read statement will fail.
Please let me know if your table out_tab in blank when you are reading the table and if this table contains any field called HSDAT.
Basically i would like to know your internal table out_tab declaration.
Thanks,
Archana -
How to fetch data from multiple fact tables from a normalized schema?
Hello everybody,
I am working on a normalized schema to build my repository. I have categorized the tables into dimensions and facts. I have 3 fact tables in my schema and they have a 1:m:1 relationship i.e. if I have table A, B, and C; A has 1:m relationship with B and C also has 1:m relationship with B. How can I use measures from these tables to create a star schema. If A = Sales, B = Transaction, C = Payment_Amount
Sales(Sales ID, Amount, Tax pct, ...)
Transaction(Transaction ID, Sales ID, Payment ID,Transaction Amt, ...)
Payment_Amount(Payment ID, Check ID, Payment Made, ...)
Please give me some direction to pursue.
Thank you!
DHi dcole,
Go through this link for snowflake schema http://gerardnico.com/wiki/datamodeling/snowflake_
http://www.rittmanmead.com/2007/06/19/obiee-data-modeling-tips-1-integrating-1-1-and-1-many-source-tables/
I suppose it should work with snowflake schema...Im interested in this topic please let me know what is your approach every now and then.
By,
KK -
How to return rows from tmp table created inside function??
Hi,
I'm trying to return rows from a cursor or table (created within
the function). How do I specify the return type?Hi,
Here is the code that examples to create a function that can
return data from table.This is achieved using REFCURSOR concept.
Hope this helps you.I'm giving all stuff in single PL/SQL
block.You can break it and create a package and declare
refcursor type and function in that as well.
DECLARE
-- Declare generic cursor type
TYPE gencur_type IS REF CURSOR ;
-- Declare generic cursor varaible
gencur gencur_type;
-- Declare record type
TYPE rec_type IS RECORD(descr emp.ename%type) ;
-- Declare record type variable
rec rec_type;
--This how you declare a local function that returns gencrtype
data set
--This function is called in main block
FUNCTION call_refcur return gencur_type
AS
rr gencur_type;
BEGIN
OPEN rr FOR SELECT descr FROM emp;
RETURN rr;
END;-- end of local function
-- Main block begins here
BEGIN
-- Call the local function so that gencur will have
-- the data set returned by select statement
gencur:= call_refcur;
-- Open a loop to test the stuff
LOOP
FETCH gencur INTO rec;
EXIT WHEN gencur%NOTFOUND;
null;
dbms_output.put_line(rec.ename);
END LOOP;
END;
Regards,
Sridhar -
How to populate rows from another table in new blank rows of other table
I have to convert an oracle form 6i to Jdeveloper application. In forms 6i we use create a cursor for other table and then populate the current table data block row using create record and assigning its values from cursor and then issuing next record until all cursor records are written in data block. After some manual editing we save the whole form and then all block records are saved as new rows in table.
Now how to create this functionality in jdeveloper application.
Kindly help.two steps-
1. get row from first VO.iterate them - like below -
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcIteratorBindings = bindings.findIteratorBinding("ViewObj1Iterator");
HSSFRow excelrow = null;
// Get all the rows of a iterator
oracle.jbo.Row[] rows = dcIteratorBindings.getAllRowsInRange();
int i = 0;
for (oracle.jbo.Row row : rows) {
row.getAttribute(colName).toString()); // by this you can get row attribute value..
2. inside iteration create row for VO 2 for example-
ViewObject employee= findViewObject("EmployeeVO");
// Create a row and fill in the columns.
Row row = employee.createRow();
row.setAttribute("Name", "Vinay");
row.setAttribute("EmpId", 1);
//Insert row in to the default row set
employee.insertRow(row);
Read more: http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html#ixzz2iL978UOD
http://www.techartifact.com/blogs/2012/12/creating-new-row-of-view-object-in-adf-techartifact.html
Maybe you are looking for
-
Based on http://forums.adobe.com/thread/1308132?tstart=0 I decided to add each question seperately: Hello, I'm quite interested in buying Lightroom 5.2. I tried the RC which ran out now. Yet, I have a several questions that I can't really find good c
-
I do not have "save as" listed on my file menu. Am I missing something?
I am missing the "save as" command on my toolbar in Pages. Therefore I am not able to save an existing document with a different name. Any suggestions?
-
OS X Yosemite or Mavericks-Which is better?
Hello, everyone, I want a professional, personal, and meaningful review of OS X Yosemite's new design/UI and the new features. Thank you!
-
Can't install itunes on a new Win7 machine. Get a message "There is a problem with this Windows installer package. A program required for this install to complete could not be run"
-
Hi All, I need to find the available OLAP variables in the system. Any one can suggest me how to do this. Regards karunakar