Computing average accessing multiple tables
I have a teaser in creating a list of students and computing their average grade by accessing multiple tables.. can someone help me with this?
I have following tables:
class( class_id, class_name)
student(student_id, student_name, class_id)
exam ( exam_id , class_id , exam_date )
grade( exam_id , student_id, grade )
create a list of students and ther avg grade in their last N ( n can be any number ) tests
Any help in getting this sql will be useful
Hi,
Welcome to the forum!
I'd approach the problem in these steps
(1) Join the tables to show all grades for all students: one row per student per grade
(2) Use the analytic ROW_NUMBER (or RANK, depending on how you want to deal with ties) to see which is the 1st, 2nd, 3rd, ... most recent for each student. (Let's call this number rnum).
(3) In a super-query, compute the average "WHERE rnum <= n".
Break these steps down, if necessary, and test that your query is doing what you want before going on to the next step.
For example, (1) is a lot to do at once. Take baby steps. for example:
(1a) Start with just the grade table. Write a query that gets the relevant onformation from the grade table. When that is working perfectly,
(1b) Add one more table (either exam or student will work). Make sure you're getting all the data you need from these 2 tables.
If you get stuck, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), your query, and the results you want to get from that data with that query.
Similar Messages
-
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 -
SQL performance - multiple tables or one bigger one?
One product will have 5 different types of media that need to
be
associated with it.
Some products will have, perhaps many items in one column
while none in
other columns
For Example
Product ID | ###
images | photoID1, PhotoID2
multimedia |
testimonials |
Pdfs | pdfid1
INserts | insertid1, insertid2 insertid3
Anyways, I am wondering if creating one table with multiple
columns is
better than many tables with just one of each of these
categories?
In other words, would it be better to have a table for
multi-media, a
table for pdfs and so on or one table for all of them. Some
rows will be
empty.
does the server take a bigger hit accessing multiple tables
win
individual items or one table with more columns that are,
perhaps empty?.oO(Lee)
>One product will have 5 different types of media that
need to be
>associated with it.
>
>Some products will have, perhaps many items in one column
while none in
>other columns
>
>For Example
>
>Product ID | ###
>images | photoID1, PhotoID2
>multimedia |
>testimonials |
>Pdfs | pdfid1
>INserts | insertid1, insertid2 insertid3
>
>Anyways, I am wondering if creating one table with
multiple columns is
>better than many tables with just one of each of these
categories?
>
>In other words, would it be better to have a table for
multi-media, a
>table for pdfs and so on
That would be one possible way.
>or one table for all of them. Some rows will be
>empty.
Don't do that, at least not in the way you described above.
But you
could do it with a single table if you would add a column
that describes
the media type:
productId
mediaType
mediaId
There would be a record for every single associated media. A
product
with 3 PDFs and 5 images would have 8 records in the media
table.
Micha -
Adding data to multiple tables using one form in Access 2010?
Hi All,
I have a access database with two tables and I want to create a single form to enter data into that tables.
How to adding data to multiple tables using one form in Access 2010?
I don't have to much knowledge of access database?
Please help me
Thanks
BalajiYou really don't enter identical data into 2 tables. You enter dat into one single table, and then you have an unique identifier that maps to another table (you have a unique relationship between two tables).
Maybe you need to read this.
http://office.microsoft.com/en-001/access-help/database-design-basics-HA001224247.aspx
Think about it this way... What is you update data in 2 tables, and then the data in one of those tables changes, but the data in the other table does NOT change. WHOOPS!! Now, you've got a BIG problem. For instance, you have a customer
named Bill Gates. In one Table you update Bill's address to 1835 73rd Ave NE, Medina, WA 98039 and in the other table you accidentally update Bill's address to 183 73rd Ave NE, Medina, WA 98039. Now you have 2 addresses for Bill. Why would
you want that??? Which is right? No one knows. If you have one address, you just have to update one address and if there is a mistake, you just have to update one address, but you don't have to waste time trying to figure out which is right
and which is wong...and then update the one that is wrong.
Post back with specific questions.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
POWL accessing data from multiple tables/objects
Hello,
I have a query on the POWL applications.
If the powl application has to access data from multiple tables/objects, then the solution would be creating a data structure of those tables/objects and referring to that structure in GET_OBJECT_DEF methods.
Is there any other soln? or I am right here?
The queries which are saved for a particular user are transportable? if not, how can they be made transportable?
Thanks & regards,
Ravishyou are right, you can do in get_objects method.
POWL_QUERIES are transportab;e, you can save them in POWL_QUERY transaction.
Best regards,
Rohit
http://wiki.sdn.sap.com/wiki/display/WDABAP/POWL -
Can we use single DB Adapter for multiple tables
Hi,
I have 3 tables. ONE is the Master table and other 2 tables having Primary and foreign key relationships with the Master Table.
Data is enter in the Tables 2 & 3 (based on Master Table Primary key)
I have to use a DB Adapter in BPEL Process which will be in Transaction (what type of Transaction is Best in such a Scenario).
- How do i implement it in BPEL.
- Can i use a Single DB Adapter for Multiple Tables ? (*Views* should not be created for tables 1, 2 & 3),
as we want to avoid using multiple DB Adapters, as in future Tables may increase or decrease...
- while in Transaction if Table 2 fails in Inserting / Updating, it should roll back on error and also if Table 3 fails in Inserting / Updating, it should roll back table 2 and Table 3.
- how access to concurrent users is maintained / managed in such a scenarios.
But everything should be done using Single DB Adapter without creating a separate view.
Is this Possible in BPEL..
If not, How do we design, Implementation such a BPEL Process in Transaction with a best in Performance (both BPEL Process & DB Resources)
thanks in advance
thanks & regards,
anvv sharmaHi,
Thanks for your quick response.
I have few quires.
If we use PL/SQL, how do we implement transaction and Exception Handling appropriately based on the Error / Exception in BPEL.
If the Table 2 or Table 3 gives out Error / Exception, i have to handle it separately and intimate accordingly.
Suppose, if Table 2 got Error / Exception - Error Handling would be 'Roll back due to error in Table2'
Thanks & regads, -
Error ODS activation - sql error when accessing a table.
Hi,
sometimes occurs an error by activation ODS. I have proces chain and when is loaded second packet an error occurs. In monitor>>
-RSMPC 128, datapacket 3 is wrong, with status number 9
-RSMPC 131
-RSDRO 108 - communcation error (sql error when accessing a table)
In sm21>
-sql error when accessing a table
-The exception, which is assigned to the class 'CX_SY_OPEN_SQL_DB', was
either caught nor passed along using a RAISING clause, in the procedure <b>"UPDATE_ATAB"</b> "(FORM)"
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
The database system recognized that your last operation on the database
would have led to a deadlock.
Therefore, your transaction was rolled back
to avoid this.
ORACLE always terminates any transaction that would result in deadlock.
The other transactions involved in this potential deadlock
are not affected by the termination.
I have BW 3.5.
Thank You very much.There are a few different scenarios that I can think of where this might come up that all involve what might resulting in parallel (concurrent)processes:
Loading packets in parallel - that is there are X number of processes loading packets concurrently. This could be set in your IMG settings system wide or in the InfoPackage for just this datasource. You seem to indicate that you don't have this.
Database parallel processing - RSAMDIN - ORA_PARALLEL_DEGREE ( there was a different RSADMIN parm for older versions - forget what SP the change came with).
You have multiple InfoPackages for the datasource, each loading what should be a different range of data, and they run atthe same time.
You could be loading from two different datasources to the ODS at the same time.
If any of these are true, I would look at bumping the INITRANS setting up. Your DBA will probably need to do this for table and its indices. There is a Note - 831234 that allows you to create a parameter in RSADMIN that will specify a INITRANS value (e.g. 20) rather than using the default. The ODS would need to be activated to pick this new setting up for the table to be altered.
You could also look at the Processing settings for the InfoPackage and change to PSA first, then target to see if that helps.
Or if you are loading from two different datasources at the same time, you might adjust your schedule so that doesn't happen.
Pizzaman -
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 -
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 -
Accessing multiple PSD layers in Adobe Photoshop Touch from Creative Cloud is important to me. When will Touch be updated with this function? Want the ability to view multiple layers the same way Creative Cloud website can. Having the ability to turn multiple layers on an off in Touch from and uploaded PSD file. As it stand Touch flattens imported Layered PSD files. (Not very useful)
Hi Bford225,
I moved your post over to the Photoshop Touch forum because it seemed mostly about Photoshop Touch.
Currently, I'd recommend converting RAW images to Jpeg in either Photoshop or Lightroom and then uploading them to Creative Cloud for working with them in Photoshop Touch. I know raw support is something our developers are considering so please add your vote here:
http://forums.adobe.com/ideas/1227
How you best incorporate Photoshop Touch into your workflow is hard to say. What works best for one person may not be true for everyone. Photoshop Touch obviously doesn't have all the capabilities of its desktop counterpart but it does have the ease of use and portability of being on a tablet. Personally, I like using Photoshop Touch for editing images taken with the iPad or my iPhone for convience versus transferring to transfer to the computer, or even if I still do, I can do some of the initial edits from the tablet first. Its nice when I only have the tablet available and not a computer. For images I take with my DSLR I always do my editing in Photoshop and Lightroom. I'm able to make any adjustments on the computer much faster than on a tablet.
If you have the option to shoot in both Jpeg and RAW that might be good option (best of both worlds). Do you have the ability to import images from the camera without using a computer - using a camera connectivity kit or something like that? My recommendation would be expermentation, test out different workflows on the tablet and see how you like it and find what works best for you.
-Dave -
Hi,
I have a method that has to access records from multiple tables and store them all in a file. It's something like this:
switch (tableId){
case 'A' : query="SELECT * FROM TABLE_A
WHERE ID = '" + tempId + "'";
ResultSet rs = stmt.executeQuery (query);
rs.close();
break;
case 'B' : query="SELECT * FROM TABLE_B
WHERE ID = '" + tempId + "'";
rs = stmt.executeQuery (query);
rs.close();
break;
case 'C' : query="SELECT * FROM TABLE_C
WHERE ID = '" + tempId + "'";
rs = stmt.executeQuery (query);
rs.close();
break;
My problem is that I get an "Invalid cursor" error the second time I enter the loop. I've been reading up on cursors but I still don't know what to do. Can I use ResultSet to return multiple rows from multiple tables? If not, what can I use? Please help!
Thanks in advance.remove the "rs.close()" from the switch statement. use "rs.close()" after your loop ends.
prem -
How to alter a Form to modify multiple tables
I want to create a form that will insert or update into multiple tables at once.
I have provided a picture of what i have in mind: http://imageshack.us/photo/my-images/21/custformexample.jpg
In this example I have 3 tables:
Customer (Cust_ID, Name,Address,Email,Phone);
Account_Manager(AM_ID, Name,Address,Email);
Customer_Account_Managers(Cust_ID,AM_ID);
A customer can have 0 to many Account Managers.
I have created a form on table with report with which I can see a report of all customers and click Edit to edit a customer or Create to create a new one.
In this form I want to add a select list that includes all Managers (I know how to create a select list and how to access it's value). I also want a report on the Account Managers which are associated with the customer, and I want to be able to add to this list, which will be saved into the Customer_Account_managers table as soon as i click Save.
Please provide me with some tips as to how to do this.
Thanks a lot!Always include the following information when asking a question:
<ul>
<li>Full APEX version</li>
<li>Full DB/version/edition/host OS</li>
<li>Web server architecture (EPG, OHS or APEX listener/host OS)</li>
<li>Browser(s) and version(s) used</li>
<li>Theme</li>
<li>Template(s)</li>
<li>Region/item type(s)</li>
</ul>
popovitsj wrote:
I want to create a form that will insert or update into multiple tables at once.
I have provided a picture of what i have in mind: http://imageshack.us/photo/my-images/21/custformexample.jpg
In this example I have 3 tables:
Customer (Cust_ID, Name,Address,Email,Phone);
Account_Manager(AM_ID, Name,Address,Email);
Customer_Account_Managers(Cust_ID,AM_ID);
A customer can have 0 to many Account Managers.
I have created a form on table with report with which I can see a report of all customers and click Edit to edit a customer or Create to create a new one.
In this form I want to add a select list that includes all Managers (I know how to create a select list and how to access it's value). I also want a report on the Account Managers which are associated with the customer, and I want to be able to add to this list, which will be saved into the Customer_Account_managers table as soon as i click Save.You can create a database views based on these tables, and create a instead of insert/update/delete trigger to populate the corresponding tables when fired.
Create an APEX form using wizard based on this database view. -
Dear All,
My database is 11gR1 and Linux is the platform.
I have more then 50 very important tables and around 15 database users.
I want to implement fine grained auditing on these important tables.
This is how I am going to implement it:
SQL>BEGIN
DBMS_FGA.add_policy(
object_schema => 'Scott',
object_name => 'SAL',
policy_name => 'SALARY_CHK_AUDIT',
audit_condition => NULL,
handler_schema => 'imran',
statement_types => 'SELECT,INSERT,UPDATE,DELETE',
audit_column => NULL);
END;
what is i have to pass multiple tables in object_schema and multiple users in handler_schema.
I hope i am able to clear my question, any doubts please let me know.
Regards, ImranHi,
object_schema - The schema of the object to be audited. (If NULL, the current log-on user schema is assumed.)
in case if you like to audit for multiple users - then try to test by holding a null value and test access the important tables -where the relevant auditing records are generated as per your requirement or not. i have not tested.. try it
- Pavan Kumar N -
Using Single Datasource to Access Multiple Databases
Hi,
We would like to know the pros and cons of accessing multiple
databases through a single datasource, versus accessing each
database through its own datasource. Our environment includes
multiple web servers w/ the latest version of ColdFusion MX 7,
clustered through a load balancer. Each web server has 800+ dsns
pointing to different SQL databases on the same SQL server. We have
noticed that the ColdFusion administrator is taking a long time to
display or verify all datasources and sometimes it even times out.
Another problem is that sometimes the neo-query file gets corrupted
(for unknown reasons) which results in the deletion of one, or
more, or all datasources on the web server.
Because of the issues above we are researching the
possibility of removing most of the datasources, and then accessing
each database through a single bridge datasource. In that regard we
plan to change our queries by inserting the sql db name and user in
front of each table in the query such as:
<cfquery name="query" datasource="single_dsn_name">
select * from [#dbname#].dbo.tableName
</cfquery>
In the example above, obviously #dbname# would be a variable
that will hold the name of the requested database. The code above
would similarly apply to queries using, update, insert and join
words.
Are there any limitations or negatives from scalability,
performance, and reliability perspective in implementing the above
scenario versus having one datasource for each database.
Also, if there is a better way of accomplishing this, we
would love to hear about it.Here is my opinion, because I work with both schemas. The
main advantage to use one datasource for all DBs in a SQL Server is
the simplicity of administration.
But the main disadvantage is security, because you are using
a single user to access all DB in a server, you don't have
isolation, and a user that knows your schema can access data of
other DBs that he sould not be authorized.
Another issue is is a user must access 2 differents DB with
different permissions (a DB only read and the other read/write),
you'll have to create another datasource, user, etc for it.
But the decision depends in the enviroment. If you are a
hosting company, I would use 1 datasource for user or DB. If the
servers and DBs are of the same company, I could use one datasource
for each SQL server.
Best regards -
Dbms_xmlgen.newcontext query from multiple tables and ||
I have two questions
How do I get a dbms_xmlgen.context to query from multiple tables? I have been able to make it work with using one table only, but not with multiple tables.
And how to get the || (concat) to work within my query for my output to an xml file?
Here is my current query:
create or replace function get_xml return clob is
result clob;
qryctx dbms_xmlgen.ctxHandle;
SELECT DBMS_XMLGEN.getxml('select prefix, suffix, fiscal_yr
FROM rcv.recv_accessions ra
where ra.prefix = 8 and ra.fiscal_yr = 11')xml into result FROM dual;
result := DBMS_XMLGEN.getXML(qryCtx);
This is what I desire:
SELECT DBMS_XMLGEN.getxml('select ra.prefix||'-'|| ra.suffix||'-'|| ra.fiscal_yr accession, ss.date_in, st.test
FROM rcv.recv_accessions ra, ser.sero_samples ss, ser.sero_tests st
where ra.prefix = 8 and ra.fiscal_yr = 11 and ss.raid = ra.id and st.ssid = ss.id')xml into result FROM dual;
On this both the reference to multiple tables and the concat function cause errors.
Thank you
Edited by: user583094 on Mar 2, 2011 3:36 PMHi,
for the concat do I use xmlconcat?No, XMLConcat is used to concatenate XMLType fragments.
The || operator will do fine, but you must escape any single quote inside the string :
SELECT DBMS_XMLGEN.getxml(
'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = 8
AND ra.fiscal_yr = 11
AND ss.raid = ra.id
AND st.ssid = ss.id'
INTO result
FROM dual;Or, use the quoting operator to define a custom string delimiter :
SELECT DBMS_XMLGEN.getxml(
q'{SELECT ra.prefix ||'-'|| ra.suffix ||'-'|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = 8
AND ra.fiscal_yr = 11
AND ss.raid = ra.id
AND st.ssid = ss.id
INTO result
FROM dual;BTW, a good practice would be to use bind variables for the query. DBMS_XMLGEN can handle them nicely :
CREATE OR REPLACE FUNCTION get_xml
RETURN CLOB
IS
qryctx DBMS_XMLGEN.ctxHandle;
v_out CLOB;
qrystr VARCHAR2(4000) :=
'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = :b_prefix
AND ra.fiscal_yr = :b_fiscal_yr
AND ss.raid = ra.id
AND st.ssid = ss.id';
BEGIN
qryctx := DBMS_XMLGEN.newContext(qrystr);
DBMS_XMLGEN.setBindValue(qryctx, 'b_prefix', '8');
DBMS_XMLGEN.setBindValue(qryctx, 'b_fiscal_yr', '11');
-- to generate empty elements if necessary :
DBMS_XMLGEN.setNullHandling(qryctx, DBMS_XMLGEN.EMPTY_TAG);
v_out := DBMS_XMLGEN.getXML(qryctx);
DBMS_XMLGEN.closeContext(qryctx);
RETURN v_out;
END;
Maybe you are looking for
-
Hi All, Fairly new at this, and a little confused with dates and date formats. I run the following: alter session set nls_date_format = 'dd/mm/yyyy' If I select sysdate from dual: 02/11/2008 --> so this is correct. Now what I can't figure out is why
-
Getting error message - itunes.exe not a win32 application
not sure what else to do..i did "run" and also did "save" when i downloaded itunes. same error message. what else do i do? my daughter got a gift card and i can't go any further with this message coming up. help!
-
Will the full version of adobe allow you to review and scroll 2 documents at the same time?
will the full version of adobe allow you to review and scroll 2 documents at the same time?
-
Can anyone tell my how I can print/create a pdf from my printer - I used to be able to & now I can't it doesn't give me the option anymore
-
So I bought my white 16 Gig iPhone and after activating the phone, we waited to see that AT&T made a connection and after that was established we waited to see if it connected via 3G. It took a while actually and then the guy at the Mac store said th