]INTO CORRESPONDING FIELDS OF
When <u>INTO CORRESPONDING FIELDS OF</u> is used in a select statement?
HI
The INTO clause defines the target area into which the selection from the SELECT clause is written. Suitable target areas are variables whose data type is compatible with or convertible into that of the selection in the SELECT clause.
The SELECT clause determines the data type of the target area as follows:
· The linesspecification in the SELECT clause determines the depth of the target area, that is, whether it is a flat or a tabular structure.
· The colsspecification in the SELECT clause determines the structure (line type) of the target area.
To read data into one, use the following in the INTO clause
SELECT ... INTO wa ...
The target area wa must be at least as large as the line to be read into it. When you read the data into wa, its previous contents are overwritten. However, the components of wa that are not affected by the SELECTstatement retain their previous values.
If the work area is structured, you can use the CORRESPONDING FIELDS addition. This transfers only the contents of fields whose names are identical in the database table and the work area. This includes any alias column names that you specified in the selection.
Reward all helpfull answers
Regards
Pavan
Similar Messages
-
"Select into corresponding fields" on MaxDB 75
Dear all,
we just migrated from Linux/Sap DB to Win2003 64bit /MaxDB (KERNEL 7.5.0 BUILD 030-123-100-791)
The migration went well and the system is fully available. The perfromances in general have been improved with the new hardware..
The problem is that there is a customer program, Z* object obviously very important..., that in random way run in very bad way.
We compared it's execution on the old system and on the new machine , with the same variant.
In general on the old machine it ran more faster than on new machine, and in these cases on the new machines it need till 3 or 4 times (more than 10 hours) the execution on the old machine.
Sometimes insted on the new machine, with the same variant, it's executed in very fast way, requiring less time than on the old machine.
The Data Buffer cache on the new machine has been enlarged, and also the performance parameters from th note for MaxDB 7.5 have beed applied.
The statistics are refreshed every day.
When the performances on the new machine become bad for this program there are not exausted resources and there are free work process.
We noticed only the programm require a lot of time to execute this statement on the new machine:
SELECT * FROM BSAD
INTO CORRESPONDING FIELDS OF TABLE TB_BSAD
WHERE AUGBL EQ P_BELNR
AND BELNR NE P_BELNR
AND BUKRS EQ P_BUKRS
AND GJAHR EQ P_GJAHR.
Any idea ?
regardsHi Roberto,
INTO CORRESPONDING FIELDS is the problem.
The internal table structure ideally should be same as the fields retrieved in the select query.
Best regards,
Prashant -
Hi
I have one performance issue problem, in program i declare structure, internal table and work area. Here in select query i specify into corresponding fields table <it>. here i used into corresponding fields of table is it reduce the performance?
Please tell me.
Thanks.never use into corresponding fields when we are looking for perfromance issue. as you said 10 fields you are going to display. then
decalre the internal table body and work area by using those fields (which are required to display output).
select <require fields> into table <internal table body> from <dbtable> where <condition>.
if you declare your internal table like below which makes your performance better.
TYPES: begin of tw_itab,
end of tw_itab,
tt_itab type standard table of tw_itab.
DATA : lw_itab type tw_itab,
lt_itab type tt_itab.
regards.
sriram. -
Why we use INTO CORRESPONDING FIELDS OF TABLE
why we use INTO CORRESPONDING FIELDS OF TABLE
INTO CORRESPONDING FIELDS OF TABLE is transferring the value from select clause to itab where the field names are same.
suppose you have
data : begin of itab occurs 0,
matnr like mara-matnr,
menge like mseg-menge,
lgort like mard-lgort,
end of itab.
select matnr lgort into table from mard where....
it may give an error because you are not filling menge here or it may fetch the value in matnr and menge field.
but if you use INTO CORRESPONDING FIELDS OF TABLE then it will fetch the data to matnr and lgort field only.
INTO CORRESPONDING FIELDS OF TABLE is only matching by name not by datatype be careful.
regards
shiba dutta -
How to write the quires using into corresponding fields?
Hi,
How can i write the below quires using into corresponding fields statement.
DATA :ws_d_budat TYPE bkpf-budat,
ws_c_artnr TYPE ce10001-artnr,
1) SELECT SINGLE budat
INTO ws_d_budat
FROM bkpf
WHERE awtyp = 'VBRK'
AND awkey = wa_vbeln-vbeln.
2)SELECT vbeln posnr matnr
FROM vbrp
INTO TABLE i_matnr
FOR ALL ENTRIES IN i_vbeln
WHERE vbeln = i_vbeln-vbeln
AND matnr = ws_c_artnr
AND posnr NE ' '.
3) SELECT bukrs belnr gjahr budat awkey
INTO TABLE i_budat
FROM bkpf
FOR ALL ENTRIES IN i_awkey
WHERE awtyp = 'VBRK'
AND awkey = i_awkey-awkey.
Sudhakar1) SELECT SINGLE budat
INTO ws_d_budat
FROM bkpf
WHERE awtyp = 'VBRK'
AND awkey = wa_vbeln-vbeln. -
> <b>Not possible</b>
2)SELECT vbeln posnr matnr
FROM vbrp
INTO corresponding fields of TABLE i_matnr
FOR ALL ENTRIES IN i_vbeln
WHERE vbeln = i_vbeln-vbeln
AND matnr = ws_c_artnr
AND posnr NE ' '.
3) SELECT bukrs belnr gjahr budat awkey
INTO corresponding fields of TABLE i_budat
FROM bkpf
FOR ALL ENTRIES IN i_awkey
WHERE awtyp = 'VBRK'
AND awkey = i_awkey-awkey.
Reward points if helpful.
Regards.
Srikanta Gope -
What does "into corresponding field" addition used for?
What does "into corresponding field" addition used for?. I have seen them in open sql statements. Please explain?
before knowing this you have to know how u write select in ABAP....
think you have a str./internal table itab with this strucutre:
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
posnr like vbap-posnr,
netwrt like vbap-netwrt,
end of itab.
u have to follow the same order in the select statement...
select vbeln posnr netwrt
from vbap
into table itab
where......
Think that u had some concern and coudnt write a select in same order then u write it like this...
Performance wise its very bad...so ppl generally try to eliminate it..
select netwrt posnr vbeln
from vbap
into corresponding field of table itab
where......
Award points if helpful -
"inner join" PLUS "into corresponding fields" in "for all entries" ???
SAP provides the following example:
DATA: BEGIN OF wa,
struc1 TYPE scarr,
struc2 TYPE spfli,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY table_line.
SELECT *
FROM scarr
INNER JOIN spfli ON scarr~carrid = spfli~carrid
INTO TABLE itab.
LOOP AT itab INTO wa.
WRITE: / wa-struc1-carrid,
wa-struc1-carrname,
wa-struc2-connid.
ENDLOOP.
What should the syntax be if:
1) struc1 is your own type with just a few selected fields from scarr;
2) struc2 is your own type with just a few selected fields from spfli
3) you only want these fields in your SELECT (instead of the SELECT *).
Please provide answer only if you know your code works.
Thanks.
djhYes, aRs - thanks.
Someone in the shop here had an example that I coded from, and it's like yours:
REPORT ZFOO.
TABLES:
/sapapo/trprod,
/sapapo/matkey.
TYPES:
BEGIN OF tx_trprod_new,
MATID TYPE /SAPAPO/MATID,
matnr TYPE /sapapo/matnr,
END OF tx_trprod_new.
DATA:
it_trprod_new TYPE STANDARD TABLE OF tx_trprod_new,
v_num TYPE i.
SELECT /sapapo/trprod~matid
/sapapo/matkey~matnr
FROM /sapapo/trprod
JOIN /sapapo/matkey ON /sapapo/trprod~matid = /sapapo/matkey~matid
INTO
TABLE it_trprod_new
WHERE /sapapo/trprod~matid LIKE 'H%'. -
SELECT .... INTO CORRESPONDING - Internal table
How do everyone,
I have the following work areas and internal table defintion:
TYPES: BEGIN OF equi_rec,
equnr, " Registration
herst, " Make
typbz, " Model
zzdept, " Department
zzoperator, " Operator
zzregdate, " Registration Date
END OF equi_rec.
DATA: equi_wa TYPE equi_rec,
equi_tab TYPE TABLE OF equi_rec.
In the code:
SELECT *
INTO CORRESPONDING FIELDS OF TABLE equi_tab
FROM
equi.
The ABAP is falling over at runtime. I have since found out that if
I comment out the ZZREGDATE in the EQUI_REC above, the program works.
The ZZREGDATE is defined as a date in the dicionary.
Can anyone tell me why the program is falling over when I am trying to
move the date field??
Any help much apprectaied.
Thanks in advance
AndyHi,
Here is the answer ..
TYPES: BEGIN OF equi_rec,
equnr, " Registration
herst, " Make
typbz, " Model
zzdept, " Department
zzoperator, " Operator
zzregdate, " Registration Date
END OF equi_rec.
If you declare like above, then all the fields will have Charecter type and length is 1, so the EQUNR, HERST and all other fields is charecter type then it is storing the first charecter in this Internal table, but the ZZREGDATE is the date field and it will not store the first charecter from the date field, because if you use the MOVE-CORRESPONDING then you need to write the same type, so that it is giving the dump ..
after writing the TYPE for ZZREGDATE then the program will run properly, but all the fields will store only the first charecter from the table values,
you need to give the correct TYPE to all the fields from the data dictionary inorder to store the total value
Reward points for all the helpful answers
Regards
Sudheer -
In the select statement, how can I specify fields of an internal table which I want to be filled from a database table? Is it possible to define in INTO clause that I want db_field1 to be copied into itab_field3?
... INTO (f1, ..., fn)
Places the result set in the target area (f1, ..., fn). The fields of the result set are transported to the target fields fi from left to right. INTO (f1, ..., fn) is allowed only if a list with n elements is also specified in the SELECT clause.
If the result of a selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted.
Example
Output a list of all airlines (with short description and name):
TABLES SCARR.
DATA: CARRID LIKE SCARR-CARRID,
CARRNAME LIKE SCARR-CARRNAME,
SELECT CARRID CARRNAME
INTO (CARRID, CARRNAME)
FROM SCARR.
WRITE: / CARRID, CARRNAME.
ENDSELECT
If u have defined an internal tabel and in select query u r retrieving a few fields then use INTO CORRESPONDING FIELDS OF..
DATA: Begin of tab occurs 0,
matnr like mara-matnr,
maktl like mara maktl,
end of tab.
select matnr from
mara <b>into corresponding fields of table tab</b>
where matnr IN s_matnr.
Try this one.
Message was edited by: Judith Jessie Selvi -
Mapping corresponding field in the internal table
Hi guys I need help with putting XML value into the appropriate fields in the internal table struc. I attempted to use if else condition to map the element name (cname)over to the fields but those internal table within an internal table post an issue of when to append and so on ... I am using FM SMUM_XML_PARSE and the output in to this table type smum_xmltb (containing all the XML Element and Values) I want to map it to its corresponding field in the internal table (defined below)
Pls pardon this newbie here as this is very new to me. Hope to hear fr u all soon and points will be given! ")
XML->>
<?xml version="1.0" encoding="iso-8859-1"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<BOOKLIST>
<DATE>2006-09-25</DATE>
<TIME>16:27:20</TIME>
<BOOK_RECORD>
<BOOK_NUM>0012345678</BOOK_NUM>
<SHORT_DESC>OMS BOOK</SHORT_DESC>
<BOOK_GROUP>
<BOOK_CATEGORY>
<CATEGORY_ID>03</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 3</CATEGORY_DESC>
</BOOK_CATEGORY>
<BOOK_CATEGORY>
<CATEGORY_ID>02</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 2</CATEGORY_DESC>
</BOOK_CATEGORY>
</BOOK_GROUP>
</BOOK_RECORD>
<BOOK_RECORD>
<BOOK_NUM>0012345679</BOOK_NUM>
<SHORT_DESC>SAP BOOK</SHORT_DESC>
<BOOK_GROUP>
<BOOK_CATEGORY>
<CATEGORY_ID>01</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 1</CATEGORY_DESC>
</BOOK_CATEGORY>
<BOOK_CATEGORY>
<CATEGORY_ID>09</CATEGORY_ID>
<CATEGORY_DESC>BOOK group 9</CATEGORY_DESC>
</BOOK_CATEGORY>
</BOOK_GROUP>
</BOOK_RECORD>
</BOOKLIST>
</asx:values>
</asx:abap>
INTERNAL TABLE ->>
TYPES: BEGIN OF ADD_CATEGORY,
CATEGORY_ID(10),
CATEGORY_DESC(40),
END OF ADD_CATEGORY,
ADD_T_CATEGORY TYPE ADD_CATEGORY OCCURS 0.
TYPES: BEGIN OF ADD_BOOK_GRP,
BOOK_CATEGORY TYPE ADD_T_CATEGORY,
END OF ADD_BOOK_GRP,
ADD_T_BOOK_GRP TYPE ADD_BOOK_GRP OCCURS 0.
TYPES: BEGIN OF ADD_BOOK,
BOOK_NUM(10) TYPE C,
SHORT_DESC(40) TYPE C,
BOOK_GROUP TYPE ADD_T_BOOK_GRP,
END OF ADD_BOOK,
ADD_T_BOOK TYPE ADD_BOOK OCCURS 0.
TYPES: BEGIN OF TYPE_DATA,
DATE TYPE SY-DATUM,
TIME TYPE SY-TIMLO,
BOOK_RECORD TYPE ADD_T_BOOK,
END OF TYPE_DATA.
DATA: I_DATA TYPE TYPE_DATA OCCURS 0 WITH HEADER LINE.hi,
here is the code sample using ixml library .
just create a report program and copy paste the following code.
REPORT y_test_xml.
DATA: l_ixml TYPE REF TO if_ixml,
l_ixml_sf TYPE REF TO if_ixml_stream_factory,
l_istream TYPE REF TO if_ixml_istream,
l_ostream TYPE REF TO if_ixml_ostream,
l_booklist TYPE REF TO if_ixml_element,
l_document TYPE REF TO if_ixml_document,
l_parser TYPE REF TO if_ixml_parser,
l_root_element TYPE REF TO if_ixml_element,
l_book_record TYPE REF TO if_ixml_element,
l_date TYPE REF TO if_ixml_element ,
l_time TYPE REF TO if_ixml_element ,
l_book_group TYPE REF TO if_ixml_element,
l_book_cat TYPE REF TO if_ixml_element ,
others TYPE REF TO if_ixml_element ,
link TYPE REF TO if_ixml_element ,
description TYPE REF TO if_ixml_element ,
xml TYPE xstring ,
size TYPE i ,
l_xml TYPE REF TO cl_xml_document .
DATA: xml_out TYPE string ,
temp_string TYPE string .
TYPES: BEGIN OF add_category,
category_id(10),
category_desc(40),
END OF add_category,
add_t_category TYPE add_category OCCURS 0 .
TYPES: BEGIN OF add_book_grp,
book_category TYPE add_t_category,
END OF add_book_grp,
add_t_book_grp TYPE add_book_grp OCCURS 0.
TYPES: BEGIN OF add_book,
book_num(10) TYPE c,
short_desc(40) TYPE c,
book_group TYPE add_t_book_grp,
END OF add_book,
add_t_book TYPE add_book OCCURS 0.
TYPES: BEGIN OF type_data,
date TYPE sy-datum,
time TYPE sy-uzeit,
book_record TYPE add_t_book,
END OF type_data.
DATA: i_data TYPE type_data OCCURS 0 WITH HEADER LINE.
DATA: itab LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: cat_wa TYPE add_category ,
bk_gp_wa TYPE add_book_grp ,
bk_rec_wa TYPE add_book ,
bk_wa LIKE LINE OF i_data .
DATA: cat_tab TYPE STANDARD TABLE OF add_category ,
bk_gp_tab TYPE STANDARD TABLE OF add_book_grp ,
bk_rec_tab TYPE STANDARD TABLE OF add_book .
MOVE: '03' TO cat_wa-category_id ,
' BK GP 3' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
MOVE: '02' TO cat_wa-category_id ,
' BK GP 2' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
bk_gp_wa-book_category = cat_tab.
APPEND bk_gp_wa TO bk_gp_tab .
MOVE: '0012345678' TO bk_rec_wa-book_num ,
'OMS book' TO bk_rec_wa-short_desc .
bk_rec_wa-book_group = bk_gp_tab .
APPEND bk_rec_wa TO bk_rec_tab .
CLEAR:bk_gp_tab, cat_tab .
REFRESH :bk_gp_tab, cat_tab .
MOVE: '01' TO cat_wa-category_id ,
' BK GP 1' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
MOVE: '09' TO cat_wa-category_id ,
' BK GP 9' TO cat_wa-category_desc .
APPEND cat_wa TO cat_tab .
bk_gp_wa-book_category = cat_tab.
APPEND bk_gp_wa TO bk_gp_tab .
MOVE: '00123456789' TO bk_rec_wa-book_num ,
'SAP book' TO bk_rec_wa-short_desc .
bk_rec_wa-book_group = bk_gp_tab .
APPEND bk_rec_wa TO bk_rec_tab .
MOVE: sy-datum TO bk_wa-date ,
sy-uzeit TO bk_wa-time .
bk_wa-book_record = bk_rec_tab .
APPEND bk_wa TO i_data .
CLEAR: cat_wa , bk_gp_wa ,bk_rec_wa , bk_wa .
l_ixml = cl_ixml=>create( ).
l_ixml_sf = l_ixml->create_stream_factory( ).
l_document = l_ixml->create_document( ).
l_root_element = l_document->create_element( name = 'asx:abap' ).
l_root_element->set_attribute( name = 'xmlns:asx' value = 'http://www.sap.com/abapxml' ) .
l_root_element->set_attribute( name = 'version' value = '1.0' ).
l_document->append_child( new_child = l_root_element ).
others = l_document->create_simple_element( parent = l_root_element name = 'asx:values' ).
l_booklist = l_document->create_simple_element( parent = others name = 'BOOKLIST' ).
LOOP AT i_data INTO bk_wa .
CLEAR temp_string .
MOVE: bk_wa-date TO temp_string .
l_date = l_document->create_simple_element( parent = l_booklist name = 'DATE' value = temp_string ).
CLEAR temp_string .
MOVE: bk_wa-time TO temp_string .
l_time = l_document->create_simple_element( parent = l_booklist name = 'TIME' value = temp_string ).
LOOP AT bk_wa-book_record INTO bk_rec_wa .
l_book_record = l_document->create_simple_element( parent = l_booklist name = 'BOOK_RECORD' ) .
CLEAR temp_string .
MOVE: bk_rec_wa-book_num TO temp_string .
l_date = l_document->create_simple_element( parent = l_book_record name = 'BOOK_NUM' value = temp_string ).
CLEAR temp_string .
MOVE: bk_rec_wa-short_desc TO temp_string .
l_time = l_document->create_simple_element( parent = l_book_record name = 'SHORT_DESC' value = temp_string ).
l_book_group = l_document->create_simple_element( parent = l_book_record name = 'BOOK_GROUP' ).
LOOP AT bk_rec_wa-book_group INTO bk_gp_wa .
LOOP AT bk_gp_wa-book_category INTO cat_wa .
l_book_cat = l_document->create_simple_element( parent = l_book_group name = 'BOOK_CATEGORY' ).
CLEAR temp_string .
MOVE: cat_wa-category_id TO temp_string .
l_date = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_ID' value = temp_string ).
CLEAR temp_string .
MOVE: cat_wa-category_desc TO temp_string .
l_time = l_document->create_simple_element( parent = l_book_cat name = 'CATEGORY_DESC' value = temp_string ).
ENDLOOP .
ENDLOOP .
ENDLOOP .
ENDLOOP .
l_ostream = l_ixml_sf->create_ostream_xstring( xml ).
l_document->render( ostream = l_ostream ).
CREATE OBJECT l_xml.
CALL METHOD l_xml->parse_xstring
EXPORTING
stream = xml.
l_xml->render_2_string(
EXPORTING
pretty_print = 'X'
IMPORTING
RETCODE = RETCODE
stream = xml_out
size = size
CALL METHOD l_xml->display.
to read the xml data to abap itab you could parse node by node or write a XSLT to map it to your itab or use the following method. (add the following code to the earlier program)
data: result_xml type standard table of smum_xmltb .
data: return type standard table of bapiret2 .
after the statement
l_document->render( ostream = l_ostream ).
add
converting xml to itab
call function 'SMUM_XML_PARSE'
exporting
xml_input = xml
tables
xml_table = result_xml
return = return .
now check the result_xml itab.
rgds
anver -
How to select into a field of my internal table?
Howdy,
I have an internal table:
TYPES: BEGIN OF T_OUTPUT,
EQUIPMENT TYPE EQUI-EQUNR,
DESCRIPTION TYPE EQKT-EQKTX,
EQUIPMENT_CAT TYPE EQUI-EQTYP,
MASTER_WARRANTY TYPE BGMKOBJ-MGANR,
DELIVERY TYPE LIKP-VBELN,
END OF T_OUTPUT.
DATA: ITAB_DETAILS TYPE STANDARD TABLE OF T_OUTPUT WITH HEADER LINE.
Now i'd like to do a slect from LIKP into the field ITAB_DETAILS-delivery, but his code doesn't work?
SELECT VBELN FROM LIKP INTO table ITAB_details-delivery
WHERE VBELN IN S_VBELN
AND VKORG = P_VKORG
AND WERKS = P_WERKS
AND ERDAT IN S_ERDAT
AND LFART IN S_LFART.
Does anyone know what I am doing wrong?
I need to keep the name of the field as 'delivery' and I don't want to change its order in the internal table - Otherwise I'd ahve used the 'MOVE CORRESPONDING' command.
Does anyone have any ideas?
Thanks!STEVE,
Modified Code:
Get value for Delivery
SELECT <b>SINGLE</b> VBELN FROM LIKP
INTO ITAB_details-delivery
WHERE VBELN IN S_VBELN
AND VKORG = P_VKORG
AND WERKS = P_WERKS
AND ERDAT IN S_ERDAT
AND LFART IN S_LFART.
Insert into Internal Table ASSUMING u have values for
other fields in the Work Area.
<b> append ITAB_DELIVERY.</b>
Thanks
Kam -
Report output from memory to internal table (corresponding fields)
How can we pick any standard report output such as
RM07DOCS on to memory and from memory to an internal
table.Here by internal table ,i do not mean of type c
containing complete report but data should go from output to corresponding fields of internal table structure of whom is defined as same of the output.SUBMIT rfbila00 AND RETURN
EXPORTING LIST TO MEMORY
WITH sd_ktopl-low = ' '
WITH sd_bukrs IN s_bukrs
WITH sd_prctr IN s_prctr
WITH bilavers = p_fsv
WITH bilaspra = 'EN'
WITH bilbjahr = p_fyear
WITH b-monate IN s_per
WITH bilvjahr = v_cfyear
WITH v-monate = l_per
WITH bilagvar = P_LAYOUT
WITH bilagrid = 'X'
WITH bilabkon = '2'
WITH bilagkon = '3'
WITH bilasumm = '0'
WITH bilavart = '1'
WITH bilaskal = '3/0'.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_list
EXCEPTIONS
not_found = 1.
REFRESH t_ascii.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_ascii " list converted to ASCII
listobject = t_list
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
u will get the output in t_list...u have to split as per ur requir......
this will help u.....
Reward IF...........
Regards
Anbu -
Hi,
I have to implement the following scenario in SSIS but don't know how to do since I never worked with SSIS before. Please help me.
I have 20 different text files in a single folder and 20 different tables corresponding to each text file in SQL Server 2008 R2 Database. I need to extract the data from each text file and
load the data into corresponding table in Sql Server Database. Please guide me in how many ways I can do this and which is the best way to implement this job. Actually I have to automate this job. Few files are in same format(with same column names
and datatypes) where others are not.
1. Do I need to create 20 different projects ?
or
Can I implement this in only one project by having 20 packages?
or
Can I do this in one project with only one package?
Thanks in advance.As I said I don't know how to use object data type, I just given a shot as below. I know the following code has errors can you please correct it for me.
Public
Sub Main()
' Add your code here
Dim f1
As FileStream
Dim s1
As StreamReader
Dim date1
As
Object
Dim rline
As
String
Dim Filelist(1)
As
String
Dim FileName
As
String
Dim i
As
Integer
i = 1
date1 =
Filelist(0) =
"XYZ"
Filelist(1) =
"123"
For
Each FileName
In Filelist
f1 = File.OpenRead(FileName)
s1 = File.OpenText(FileName)
rline = s1.ReadLine
While
Not rline
Is
Nothing
If Left(rline, 4) =
"DATE"
Then
date1 (i)= Mid(rline, 7, 8)
i = i + 1
Exit
While
End
If
rline = s1.ReadLine
End
While
Next
Dts.Variables(
"date").Value = date1(1)
Dts.Variables(
"date1").Value = date1(2)
Dts.TaskResult = ScriptResults.Success
End
Sub -
How do I insert multiple values into different fields in a stored procedure
I am writing a Stored Procedure where I select data from various queries, insert the results into a variable and then I insert the variables into final target table. This works fine when the queries return only one row. However I have some queries that return multiple rows and I am trying to insert them into different fields in the target table. My query is like
SELECT DESCRIPTION, SUM(AMOUNT)
INTO v_description, v_amount
FROM SOURCE_TABLE
GROUP BY DESCRIPTION;
This returns values like
Value A , 100
Value B, 200
Value C, 300
The Target Table has fields for each of the above types e.g.
VALUE_A, VALUE_B, VALUE_C
I am inserting the data from a query like
INSERT INTO TARGET_TABLE (VALUE_A, VALUE_B, VALUE_C)
VALUES (...)
How do I split out the values returned by the first query to insert into the Insert Statement? Or do I need to split the data in the statement that inserts into the variables?
Thanks
GB"Some of the amounts returned are negative so the MAX in the select statement returns 0 instead of the negative value. If I use MIN instead of MAX it returns the correct negative value. However I might not know when the amount is going to be positive or negative. Do you have any suggestions on how I can resolve this?"
Perhaps something like this could be done in combination with the pivot queries above, although it seems cumbersome.
SQL> with data as (
2 select 0 a, 0 b, 0 c from dual -- So column a has values {0, 1, 4},
3 union select 1 a, 2 b, -3 c from dual -- column b has values {0, 2, 5},
4 union select 4 a, 5 b, -6 c from dual ) -- column c has values {0, -3, -6}.
5 --
6 select ( case when max.a > 0 then max.a else min.a end) abs_max_a
7 , ( case when max.b > 0 then max.b else min.b end) abs_max_b
8 , ( case when max.c > 0 then max.c else min.c end) abs_max_c
9 from ( select ( select max(a) from data ) a
10 , ( select max(b) from data ) b
11 , ( select max(c) from data ) c
12 from dual ) max
13 , ( select ( select min(a) from data ) a
14 , ( select min(b) from data ) b
15 , ( select min(c) from data ) c
16 from dual ) min
17 /
ABS_MAX_A ABS_MAX_B ABS_MAX_C
4 5 -6
SQL> -
Error by inserting data into a field of datatype LONG
Hi,
When inserting data into a field of datatype long in oracle8 database via SQL Plus or SQL worksheet there occurs the following error message: "field in data file exceeds the maximum length".
If I access to the database from a selve written program via odbc there is no problem when inserting the data by the same sql statement.
So what can I do?
Thanks in advance!
JuergenWhat does your SQL statement look like?
Maybe you are looking for
-
I have pdf document which contains special characters in it. The character is rendering correctly in Window nt but in Solarix/Unix it is being rendered as ?. How do I correct the problem on Unix and not create a problem on nt?
-
How can you de-interlace a photo from video in PSE11 it was always possible in all versions until now (tried copying pluggin from PSE 10 but did not work)
-
Running a dos command from a java application
hello, I'm trying to execute a batch file from a java application. I tried with: try Process proc=Runtime.getRuntime().exec("fop -fo "+iXmlFoFile+" - svg "+SvgFileName); }catch (IOException e){System.err.println("Error in conversion of
-
Anyone using GridIron NucleoPro 3 with cs5/cs6 please?
hello, this is probably digging up bones from the past however, are there any users using GridIron NucleoPro 3 with cs5/cs6? just wanting to chitchat about it if possible thanks in advance, j
-
XSTRING to PDF ? AIF.
Hi, I want to show Adobe Interactive Form PDF: REPORT zz_aa_aif. TABLES: lfa1. DATA: wa_lfa1 TYPE lfa1. DATA: fm_name TYPE funcname. DATA: fp_formoutput TYPE fpformoutput, fp_docparams TYPE sfpdocparams. DATA: fp_outputparams TYPE sfpout