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
Similar Messages
-
How to join THREE different tables into internal table using one select statement .
How to join THREE different tables into internal table using one select statement .
Hi experts,
I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
Scenario:
Database tables:
SPFLI
SFLIGHT
SBOOK.
Table Fields:
SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
SEATSOCC_C SEATSMAX_F SEATSOCC_F
SBOOK - CARRID CONNID CLASS
MY INTERNAL TABLE IS IT_XX.
Your help much appreciated.
Thanks in advance.
Pawan.Hi Pawan,
please check below codes. hope it can help you.
TYPES: BEGIN OF ty_xx,
carrid TYPE spfli-carrid ,
connid TYPE spfli-connid ,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom ,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto ,
fldate TYPE sflight-fldate ,
seatsmax TYPE sflight-seatsmax ,
seatsocc TYPE sflight-seatsocc ,
seatsmax_b TYPE sflight-seatsmax_b,
seatsocc_b TYPE sflight-seatsocc_b,
seatsmax_f TYPE sflight-seatsmax_f,
seatsocc_f TYPE sflight-seatsocc_f,
class TYPE sbook-class,
END OF ty_xx,
t_xx TYPE STANDARD TABLE OF ty_xx.
DATA: it_xx TYPE t_xx.
SELECT spfli~carrid
spfli~connid
spfli~countryfr
spfli~cityfrom
spfli~countryto
spfli~cityto
sflight~fldate
sflight~seatsmax
sflight~seatsocc
sflight~seatsmax_b
sflight~seatsocc_b
sflight~seatsmax_f
sflight~seatsocc_f
sbook~class
INTO TABLE it_xx
FROM spfli INNER JOIN sflight
ON spfli~carrid = sflight~carrid
AND spfli~connid = sflight~connid
INNER JOIN sbook
ON spfli~carrid = sbook~carrid
AND spfli~connid = sbook~connid.
Thanks,
Yawa -
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. -
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 usefulHi,
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. -
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 -
Add to Multiple Tables from One Page
Hello,
I am building an application that handles hardware inventory (APEX 4.0). I have an input page that adds data to two or more tables all at once. The page has two forms on it that point to two separate tables. However when I try to run the page, it fails and returns an error:
ORA-06550: line 1, column 437: PL/SQL: ORA-00904: "ORH_LAST_UPDATE_DATE": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored
Error Unable to process row of table IDD_ID_DATA.
So far as i can see within the App, that column is not at issue (I am not even doing anything to it and it is nullable). I have looked into the App itself as well as doing some online research but have found nothing helpful...
So my question is this: Is it possible to add to multiple tables from one page? If so how do I do it?
I am new to APEX so any help would be greatly appreciated!UPDATE:
I received an email from the APEX Support Team:
"The simple answer is that you will need to manually code the DML (and query) processes if you wish to maintain multiple tables from one page (There is a limit of one table when using the built-in processes).
In order to do this I suggest you delete the processes generated by the wizards and create PL/SQL processes with insert, update, delete statements as necessary. Such coding is not difficult but is more time consuming than when you can use built-in processes."
I have been playing around with PL/SQL code and the end result is this:
begin
INSERT INTO table1
VALUES(
:P2_Item_Field1,
:P2_Item_Field2);
INSERT INTO table2
VALUES(
:P2_Item_Field1,
:P2_Item_Field2);
end;
I used this code in a custom PL/SQL Process in the Processing>Processes section of Page Processing and it seems to work fine now. The only downside to this method is if the name of a Page Item is changed the code will also have to be changed. Other than that i have had no problems. -
How to use bind variable value for table name in select statement.
Hi everyone,
I am having tough time to use value of bind variable for table name in select statement. I tried &p37_table_name. ,
:p37_table_name or v('p37_table_name) but none worked.
Following is the sql for interactive report:
select * from v('p37_table_name') where key_loc = :P37_KEY_LOC and
to_char(inspection_dte,'mm/dd/yyyy') = :P37_INSP_DT AND :p37_column_name is not null ;
I am setting value of p37_table_name in previous page which is atm_state_day_insp.
Following is error msg:
"Query cannot be parsed, please check the syntax of your query. (ORA-00933: SQL command not properly ended) "
Any help would be higly appreciated.
RajInterestingly enough I always had the same impression that you had to use a function to do this but found out from someone else that all you need to do is change the radio button from Use Query-Specific Column Names and Validate Query to Use Generic Column Names (parse query at runtime only). Apex will substitute your bind variable for you at run-time (something you can't normally do in pl/sql without using dynamic sql)
-
How to get number of records in all user tables in one select
Please advise how to retrieve the number of records in all user tables in one select. I would likt to extract the data to excel file.
Many thanks,
AndrewYou could always analyze the tables:
declare
begin
for X in (select owner, table_name from all_tables
minus
select owner, table_name from all_external_tables) LOOP
dbms_stats.Gather_Table_Stats(X.Owner, X.Table_Name) ;
end loop;
end;
/Then: Select Owner, Table_Name, Num_Rows from All_Tables ; -
Importing CSV files into Multiple Tables in One Database
I have a web based solution using Microsoft SharePoint and SQL Server that is created to centralize dat collection and reporting of program metrics used in montly reviews.
A person from each program enters dat manual or by pushing the data using automated data import tools. The user then is able to generate reports and provide presentations to their stakeholders.
There are are programs that are located in US and 2 that are located in Japan. All, including programs in Japan use the MS Project with a plug-in tool that allows them to auto input data. When the user click the "Send To.." button, the data goes
in to multiple tables in one database.
Everything is set up exactly the same for every program; however, we have discovered becase of a firewall, along with some of the different settings that the MS Project has over in Japan, the 2 program users are not able to auto import their data.
The suggestion is to have the program users export the MS Project file into a CSV and email it. I will then take it and convert the data, such as the dates and place them on a Network Drive. There will be 2 folders, one for each program.
I feel it will be an easy process just to load the data from the Network Drive into the same tables that are created for auto import.
My Concerns/Questions:
1. Should I create 1 SSIS package or should there be 2, one for each program?
2. US and Japan program users send their data once a month. The converted files are going to be saved in the location marked with a date (ex:201402). How can i have it to where SSIS will automatically load the data every time i place new files in the designated
folders or when i update an exsisting file?
Can you provide an example with your suggestion please?
I greatly appreciate the assistance!
Y_TylerHello Vikash,
Thank you! This will help me get started.
There will be 2 folders, one with files with Program A data and the other with files with Program B data. All will have the same fields, just coming from different programs. You stated that I will be able to to load both in one package. Would there be two
paths since there will be two separate folders?
Using the example you provided, i am confident that I can create the package using one path into one table but not sure how to get the files from 2 paths (if there is) into multiple tables.
Can you help clarify this for me?
Thank you!
Y_Tyler -
Export multiple tables into one flat file
I have data in multiple tables on a processing database that I need to move up to a production database. I want to export the data into a flat file, ftp it to the production server and have another job pick up the file and process it. I am looking for
design suggestions on how to get multiple tables into one flat file using SSIS?
Thank You.Hey,
Without a bit more detail, as per Russels response, its difficult to give an exact recommendation.
Essentially, you would first add a data flow task to your control flow. Create a source per table, then direct the output of each into an union all task. The output from the union all task would then be directed to a flat file destination.
Within the union all task you can map the various input columns into the appropriate outputs.
If the sources are different, it would probably be easiest to add a derived column task in-between the source and the union all, adding columns as appropriate and setting a default value that can be easily identified later (again depending on your requirements).
Hope that helps,
Jamie -
Can you really update two tables in one SQL statement
Ok a post in the forum has got me awefully curious:
Can you update two tables in one update statement i.e something like this
update table a , b
set b.<column> = something
a.<column> = something
Something to this effect.
If you are curious to know what post I am talking about it is called "updating a single row"No. You can only update one table in one SQL statement.
-
Is it Possible to join 4 or more tables in a Select Statement?
Hello guys,
Can I do Inner Join 4 or 5 tables in a select statement?U HAVE TO SERCH FOR KEY FIELD FOR THAT . MEANS HOW TABELS ARE RELATED EACH OTHE FOR THIS U ALSO USE SQ02
FOR EXAMPLE
SELECT bkpf~belnr
bkpf~gjahr
bkpf~bukrs
bkpf~blart
bkpf~bldat
bkpf~budat
bkpf~usnam
bkpf~tcode
bkpf~xblnr
bsik~lifnr
bsik~bupla
bsik~secco
INTO CORRESPONDING FIELDS OF TABLE itab_pur
FROM bkpf INNER JOIN bsik
ON bkpfbelnr = bsikbelnr
and bkpfbukrs = bsikbukrs
WHERE bkpf~bukrs IN co_code
AND bkpf~budat IN pos_dt
AND bkpf~tcode IN t_code
AND bsik~secco IN se_code.
U CAN ALSO ADD MORE TABLE BASED ON CONDITION -
Selecting from multiple tables, into one internal table
Hi,
What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
Thanks,
John
Points will be rewarded and all responses will be highly appreciated.I have simple example :
First one - Join 5 tables
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 4 or 5 tables join.
get run time field f2.
f3 = f2 - f1 ( Total time).
Second one - joins 3 table and use for all entries
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 3 tables join and use for all entries
get run time field f2.
f3 = f2 - f1. ( Total time )
Finally you can have time diffrence between the both sql statement. -
How to drop multiple tables in one statement
I could used to run the below syntax to drop multiple tables in MS SQL, but it doesn't work in Oracle seems like, I am using free Oracle SQL Developer. Not a big deal but wanna know if this can be done. Thanks,
DROP TABLE A, B, C, D, FI'm not so sure in 1 select statement is it possible or not but you can try to use in this manner to see what happens ->
drop table &tab;
Enter value for tab: A
Table A Successfully dropped.
Enter value for tab: B
Table B Successfully dropped.Regards.
Satyaki De. -
Hi,
I am working on a report what has 10 datasets derived from 10 different select statements.
Is it possilbe to save those 10 select statements as a macro / stored procedure and then use that macro to generate those dataset in the ssrs report builder ?
AshishSinghalHi AshishSinghal84,
According to your description, you want to write multiple select statements in a procedure, then use the procedure as dataset in the report, right?
According to my knowledge, when we write multiple select statements in a procedure, we have to create relationship between these select statements, otherwise it will only return the first one query's fields. If you are using SSRS 2008 R2, you can use Lookup
function to display these fields from different datasets on one data region control, but the prerequisite is that you must have one common field. For more information about lookup function, please see:
http://msdn.microsoft.com/en-us/library/ee210531.aspx
If all these solution you cannot achieve due to your special condition, the last workaround is to use subreport to display all the fields together.
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support
Maybe you are looking for
-
Adobe CS6 randomly asks for reactivation (Deployed using AAMEE 3.1)
Hi All We've deployed Adobe CS6 Design and Web Premium using AAMEE 3.1 to about 500 workstation across our school campus. However, we're having a really weird issue where either the licensing screen will randomly pop up asking for reactivation (7 da
-
Can't print in Quark 6.5; missing ppd for my printer
I just purchased the new 20" iMac w/the Intel Core Duo processor, and with it, bought a new printer, scanner, and updated all of my software. This computer replaced my trusty G4 Cube. I am now running strictly OS X (Classic isn't supported on the Int
-
Why wont my Logic Studio installer fully install?
i had manually uninstalled logic studio months ago.. now that i have an external hd im installing it again but it wont install many of the other components.. they are grayed out and uncheckable (soundtrack pro, compressor, apple loops, and many more)
-
Please can someone explain what the firmware numbers me
Hi, I would like to check whether I have the most up to date firmware for my Zen Micro but the number codes seem to be unfathomable. I have .02.05 and I don't need plays for sure because I don't use a subscription service. Is this the best one to hav
-
Anybody still fancy inspector?
new keynote feels weird, i think inspector a more efficient function, and the way to preview anmination is inconvenient. the buttom new slide is at the bottom of window, so eveytime i try to add new slide, it will make my dock( my dock is automatical