Inserting Data to a temporary table
Hi,
This may sound strange, but I see code that inserts data to a temporary table, which sources from the same temporary table. The code looks like this:
-- Some code that initially inserts data to #tmpA
IF(UserId = 0)
BEGIN
INSERT INTO #tmpA
SELECT * from #tmpA
END
I'm just curious on how this code snippets would do. Would this end up to an infinite loop? The whole code runs endlessly, I don't know if it's because of the CURSOR that is being implemented, or is it because of this code snippets which probably inserts data
to #tmpA endlessly?
Hi KEARPEE,
The code is really long, so I just emphasize on the area where I'm concern with.. it's something like that:
-- Some code that declares variables. Some code that initially inserts data to #tmpA
IF(@UserId = 0)
BEGIN
INSERT INTO #tmpA
SELECT * from #tmpA
END
-- Some code that updates the temporary table, and display the result of the temporary table
Similar Messages
-
How to check the data in a temporary table
Hi,
A procedure inserting data into a temporary table , data exists in the table now. so, how to see the data from the temporary table. Is it possible to see from the sqlplus by selecting, right now i'm not getting any data. .thanks Bcj.If you are referring to Global Temporary Tables, then the only way to see the contents of the table are to select from the table while connected to the same session that inserted the data into the GTT.
Please note however that there is not a 1 to 1 correspondence between sessions and users (shcemas). A user may be connected to 1 or more sessions, but it is only the session that inserted the records that will be able to view the records. -
Sql/Plsql code to export data into a temporary table from a text file
Dear all,
I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
i have text file like as below:
order items : books Purchasing
start date:
8-11-09
Notes: Books are selling from aug10 to aug 25
Action performed
Time
Verified By
sold out from shop, sold out date:_________
1.
physics _______ book sold to ravi
2.
social _______ book this is a good book
sold to kiran
aug10th
ronald
3.
maths book to sal
4.
english book__________ this was a newbook
to raj
jak
return to shop, return date:____________
1.
maths book return by:_____________ Verify book
aug11th
john
2.
story book by:_________ checked
aug14th
Now i need to create a temporary table and insert the data into the table from this text file.
Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
Order status Action_Performed Time Verified_By
books Purchasing sold physics _______ book sold to ravi _______ _________
books Purchasing sold social _______ book this is a good book sold to kiran aug10th ronald
books Purchasing sold maths book to sal _____ __________
books Purchasing sold english book__________ this was a newbook to raj __________ jak
books Purchasing return maths book return by:_____________ Verify book aug11th john
books Purchasing return story book by:_________ checked aug14th _________
Thanks in advance.Isn't school work marvelous?
Create an external table.
http://www.morganslibrary.org/reference/externaltab.html
Getting the data into a temporary table may make sense in SQL Server ... but not in Oracle. -
Can we insert data directly in standard table
hi
how can we insert data in standard table directly.
pls reply urgently.Hi sapna yes u can insert data to the SAP tables, as shown below...
use the table mara in the place of m
REPORT ZTEST_INSERT.
TABLES: <m>.
DATA: wa_m TYPE <m>.
wa_m-ernam = 'ZTEST'.
insert into <m> VALUES wa_m.
if sy-subrc = 0.
WRITE / 'Records inserted Successfully'.
ENDIF.
reward if usefull,
Vishnu. R
Edited by: vishnu ramanathan on Sep 18, 2008 2:17 PM -
How to insert data into the mysql table by giving as a text file
Hi,
Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
Thanks:)At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).
-
How to insert data from different internal table into a data base table
hi all,
I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
in short i want to do something like the foll:
INSERT INTO ZMIS_CODES-CODE VALUE '1'.
*INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)REPORT ZINSERT.
tables kna1.
data: itab LIKE KNA1.
data lv_kUNAG LIKE KNA1-KUNNR.
lv_kuNAG = '0000010223'.
ITAB-kuNNR = lv_kuNAG.
ITAB-name1 = 'XYZ'.
INSERT INTO KNA1 VALUES ITAB.
IF SY-SUBRC = 0.
WRITE:/ 'SUCCESS'.
ELSE.
WRITE:/ 'FAILED'.
ENDIF.
Here lv_kunag is ref to kna1 kunnr passed in different name
In internal table .
Try and let me know if this logic dint work. -
How to insert data from file to table??
I need to know that how can i insert data in multiple column through file. I can simply insert data in one column table but couldnt find out the way to put data in all column.
My data store in a file
************************************************text.txt***************
133, shailendra, nagina, 14/H, 45637, 9156729863
**************************************************************my_data(table)**********
trying to insert into below table...
id, name, last_name, add, pin. mob
Let me know if anything else needed..:)Hi Shailendra,
Actually, in SQL Developer, you can open a connection to the target schema, right-click on the Tables node in the navigator tree view, select Import Data, then use the Data Import Wizard. It is extremely flexible. It looks like you have a comma separated variable file, so if you select Format: csv and Import Method: insert it will probably work just fine.
To minimize the chance of errors during import, pick a preview limit value so the wizard can examine the size and data type of all columns in as many data rows as possible, then review the data type/size for each column in the next wizard page and override as necessary. For date columns it is also important to choose the appropriate format mask.
Hope this helps,
Gary
SQL Developer Team -
How to Insert data from notepad to Table
Hi,
I have one table with nodata.i need to insert data into table.but i have records in one notepad.if i enter manually
like using insert statement it will take more time.
Any one know insert data from notepad to table or i need sql script that will use for all the records.Here im using sqldeveloper.Hi dude,
We can use below 2 types.
1) Sql loader
2) utl file
SQL*Loader utility?
One can load data into an Oracle database by using the sqlldr (sqlload on some platforms) utility. Invoke the utility without arguments to get a list of available parameters. Look at the following example:
sqlldr username@server/password control=loader.ctl
sqlldr username/password@server control=loader.ctlThis sample control file (loader.ctl) will load an external data file containing delimited data:
load data
infile 'c:\data\mydata.csv'
into table emp
fields terminated by "," optionally enclosed by '"'
( empno, empname, sal, deptno )
{code}
The mydata.csv file may look like this:
{code}
10001,"Scott Tiger", 1000, 40
10002,"Frank Naude", 500, 20
{code}
Optionally, you can work with tabulation delimited files by using one of the following syntaxes:
{code}
fields terminated by "\t"
fields terminated by X'09'
{code}
Additionally, if your file was in Unicode, you could make the following addition.
{code}
load data
CHARACTERSET UTF16
infile 'c:\data\mydata.csv'
into table emp
fields terminated by "," optionally enclosed by '"'
( empno, empname, sal, deptno )Another Sample control file with in-line data formatted as fix length records. The trick is to specify "*" as the name of the data file, and use BEGINDATA to start the data section in the control file:
load data
infile *
replace
into table departments
( dept position (02:05) char(4),
deptname position (08:27) char(20)
begindata
COSC COMPUTER SCIENCE
ENGL ENGLISH LITERATURE
MATH MATHEMATICS
POLY POLITICAL SCIENCEPlease refer the below link.. it will useful for you.
http://psoug.org/reference/sqlloader.html
http://docs.oracle.com/cd/B10500_01/server.920/a96652/ch05.htm
Regards,
N.Senthil. -
Insert data into msql thru table trigger
Hi,
I installed dg4msql 11.2 and I would like to insert some data into our msql thru one of our Oracle table after insert table,
I used the syntax below
insert into test@dg4msql ("PN") values (:new.PN)
but the below error problem if I insert data into my Oracle table,
ORA-02054: transaction 4.17.15898 in-doubt
ORA-028500, connect from ORACLE to a non-Oracle system returned this message
[Oracle][ODBC SQL Server Driver][SQL Server] Invalid object name "RECOVER.HS_TRANSACTION_LOG
Do I have to create the HS_TRANSACTION_LOG table in my msql server to resolve this problem?
Thanks
VincentVincent,
If the gateway insert is being done as part of a trigger then it will almost certainly be part of a distributed transaction so yes, you will have to create the transaction log table and the recovery user in the SQL*Server database.
As well as the gateway documentation have a look at this note in My Oracle Support -
Note.227011.1 How to Setup DG4MSQL to Use Distributed Transactions (Doc ID 227011.1)
Regards,
Mike -
How to load duplicate data to a temporary table in ssis
i have duplicate data in my table.i want to load unique records in one destination .and i want to load duplicate data in a temporary table in another destination. .how can we impliment package for this
Hi V60,
To achieve your goal, you can use the following two approaches:
Use Script Component to redirect the duplicate rows.
Use Fuzzy Grouping Transformation which performs data cleaning tasks by identifying rows of data that are likely to be duplicates and selecting a canonical row of data to use in standardizing the data. Then, use a Conditional Split Transform to redirect
the unique rows and the duplicate rows to different destinations.
For the step-by-step guidance about the above two methods, walk through the following blogs:
http://microsoft-ssis.blogspot.in/2011/12/redirect-duplicate-rows.html
http://hussain-msbi.blogspot.in/2013/02/redirect-duplicate-rows-using-ssis-step.html
Regards,
Mike Yin
TechNet Community Support -
DB Adapters inserting data into 2 diff tables of same database giving issue
Hello,
I am using Oracle soa suite 11g BPEL.
I need to insert data in 4 different tables of same Oracle database with the requirement of rollback all data if error occurs anywhere.
I have configured the DB adapater as XA enabled on console .
In code:-
I am using 2 DBAdapters to insert data one by one in 2 diff tables of same DB (using INSERT ONLY operations). Before each invoke activity i am using a transformation activity to prepare the input variable of the DBAdapter.
When i run this code i get below error:-
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception. insert failed. Descriptor name: [DBINS_DIANA.XxontPoiHdrsIface]. Caused by java.sql.BatchUpdateException: ORA-02049: timeout: distributed transaction waiting for lock . ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
If i use a wait activity between the 2 invokes i get the data inserted fine , but that means the transactions between inserts would be committed which i want to be rollback fully in case of any errors.
Can anyone have a clue what is wrong here?
Thanks
ShivaniHi Anagha,
Have a look at these links:
/people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30
http://help.sap.com/saphelp_nw04/helpdata/en/b0/676b3c255b1475e10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/2b/d5653fd1d3b81ae10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/95/bb623c6369f454e10000000a114084/frameset.htm
Regards,
Chandra -
Drop, create and insert data into few intermediate tables
Hi All,
I need to schedule a process to drop, create and insert data into few intermediate tables on a weekly basis. Here is what i need to do in the stored procedure, which can be scheduled weekly.
DROP TABLE TABLE_NAME1;
DROP TABLE TABLE_NAME2;
DROP TABLE TABLE_NAME3;
CREATE TABLE TABLE_NAME1
CREATE TABLE TABLE_NAME2
CREATE TABLE TABLE_NAME3
INSERT INTO TABLE_NAME1 SELECT ....;
INSERT INTO TABLE_NAME2 SELECT ....;
INSERT INTO TABLE_NAME3 SELECT ....;
Any suggestions, examples or code on how to accomplish this task would be very helpful. Any question pls let me know.
Thanks in advance.I am using the intermediate tables in an extract process. The idea was that the table would be created prior to calling the extract procedure and once the data written to the intermediate table had been processed the table would be dropped. This would be repeated each time the extract process is run. From a DBA's point or view, would it be better to just leave the table on the database and truncate it after each run or is removing it entirely best?
-
Sql/Plsql code to store data into a temporary table from a text file
Dear all,
I need to create a temporary table getting data from a text file. I am very new to data loading could you please help me how to read the text file in to a temporary table.
i have text file like as below:
order* items : books Purchasing
start date:
8-11-09
Notes: Books are selling from aug10 to aug 25
Action performed*
Time*
Verified By*
sold* out from shop, sold out date:_________
+1.+
physics _______ book sold to ravi
+2.+
social _______ book this is a good book
sold to kiran
aug10th
ronald
+3.+
maths book to sal
+4.+
english book__________ this was a newbook
to raj
jak
return* to shop, return date:____________
+1.+
maths book return by:_____________ Verify book
aug11th
john
+2.+
story book by:_________ checked
aug14th
Now i need to create a temporary table with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
Now i need to create a temporary table named as books_order with 5columns(order,Status,Action_Performed,Time,Verified_By) like as below:
Order status Action_Performed Time Verified_By
books Purchasing sold physics _______ book sold to ravi _______ _________
books Purchasing sold social _______ book this is a good book sold to kiran aug10th ronald
books Purchasing sold maths book to sal _____ __________
books Purchasing sold english book__________ this was a newbook to raj __________ jak
books Purchasing return maths book return by:_____________ Verify book aug11th john
books Purchasing return story book by:_________ checked aug14th _________
Thanks in advance.Hi,
Thanks for your suggestions. I Was able to get the data using utl_file.get_line. But i was not able to the data if it is in the below format:
I was able to read the data and storing if it is in the same line.But i dont know how to read below data
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
I was able to extract the data if it is in below format using utl_file.get_line
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Any one can explain me how to solve the above criteria.
Below i am explaining the same problem in detail.
I have a text file as below and i have a table having 12 columns. Now i need to insert this text file into the table story_books.
CREATE TABLE story_books
book_id NUMBER,
Category VARCHAR2(100 BYTE),
Book_type VARCHAR2(100 BYTE),
Name VARCHAR2(700 BYTE),
Location VARCHAR2(700 BYTE),
Ownership_code VARCHAR2(700 BYTE),
Author VARCHAR2(700 BYTE),
Less_Sel_fact VARCHAR2(700 BYTE),
Reason VARCHAR2(700 BYTE),
Buying VARCHAR2(700 BYTE),
Suspected Book VARCHAR2(700 BYTE),
Conditions VARCHAR2(700 BYTE)
-------------------------text file---------------
Books Out Table: Books
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Buying (if applicable):
Not Applicable
Suspected Book:
Unknown
Conditions to increace sales:
Advertisement in all areas
i was able to read the data and storing if it is in the same line.But i dont know how to read below data
Book. Type Name Location Ownership Code
Story SL hyd SS-HYD
In this data i have to search for 'Book. type' and then i need to save the word 'Story' to the column 'Book_type'
Then i need to search for 'Name' and i need to save 'SL' into the column into 'Name'
Then i need to search for 'Location' and i need to save 'hyd' into the column into 'Location'
I was able to extract the data if it is in below format using utl_file.get_line
Known Author: Unknown
Less Selling Factors: Thunderstorms
Reason: Unknown
Any one can explain me how to solve the above criteria.
Thanks in advance. -
Auditing data from global temporary table
Hi I have a process that uses a global temporary table.
What it does it serve a consolidation point to merge a lot of data.
Some the former designer decides to use a global temporary table and the row will be gone once it got commit.
However, the data is corrupted occasionally. And ideally we would like to fix the upstream source data but this is too complicated and not feasible.
So we decide to audit the data going into the global temporary table. We want to generate a report on the corrupted data.
However, whenever I commit, the data is gone from the global temporary table and we do not want to set it to commit preserve rows for the global temporary table
Even with autonomous transaction this is not working out as once it commits the data is gone.
Any idea how this can be done. Here are the prototype that I build to demo this:
drop table gt_tst1;
--this is the table its data needs to get audit
create global temporary table gt_tst1(id number); --on commit preserve rows;
drop table not_gt_tst1;
--this table is used for storign the corrupt data and generate report
create table not_gt_tst1 as select * from gt_tst1;
CREATE OR REPLACE PROCEDURE tst_gt_tst1 IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
--if there is a way to do the insert and select once. but it seems it is not working for global temporay table unless change it to on commit preserve rows
INSERT
when m2 = 0 THEN
INTO not_gt_tst1(id)values(object_id)
when m3 = 0 THEN
INTO gt_tst1(id) values (object_id)
select object_id,mod(object_id,2) m2, mod(object_id,3) m3 from dba_objects where rownum < 101;
COMMIT;
END tst_gt_tst1;
select sysdate from dual;
truncate table gt_tst1;
truncate table not_gt_tst1;
select * from gt_tst1;
select * from not_gt_tst1;
execute tst_gt_tst1;
select * from gt_tst1; -- data gone
select * from not_gt_tst1;
--commit
select sysdate from dual;
spool offThe data is poor and the code is poor and the dev and QA env is also poor..
And the business asks us to fix the data..However..we do not have an environment close enough to test it out before it got put into production that is the bottom line.
Heres the dev and QA env cannot be trust to the extent that I can sign off and say it will give the same behavior as the production env
So we would like to minimize the risk as there are other process uses these table and we are not sure if changing this would lead to UN-expected behavior.
We cannot tell some other process rely on the fact that these table got empty out after commit.
Edited by: vxwo0owxv on Jan 23, 2012 12:18 PM
Edited by: vxwo0owxv on Jan 23, 2012 12:20 PM -
Can I get Date also from temporary table?
--(1) get table ONLY
create global temporary table cat1
as select * from category;
--(2) get table and data
create table cat2 as select * from category;
nullUse Index
Maybe you are looking for
-
URGENT: system error - Maual restart possible
Hi Experts, I'm facing a problem in Xi prodoction. Both inbound and outbound are throwing system error - Maual restart possible. The user is restarting manually in order to post the invoice. Basically this is retail project, from POS s/w to Xi to SAP
-
Solaris 10 installation in Vitual PC 2007
Anyone have success? I got to install but, it does this on boot: Warning: Time of Day clock error: reason [Stalled]. -- Stopped tracking Time of Day clock. Then seems to hang while using 50% CPU. Machine is HP m7580n, AMD X2 4600, 1 Gig memory alloca
-
Version Management for BAPI Object
Hi all, could someone tell me how to see version changes for BAPI Object type. Something like version comparison in Version Management. Regards, Joseph Message was edited by: Joseph Reddy Yeruva
-
Getting "Publishing Error" trying to update website, please help.
New to this and love iWeb so far. Successfully loaded www.cruisingblueheavens once or twice or several times but today getting this error message: "Can't create the file "mwmac.png." The disk may be damaged or full, or you may not have sufficient acc
-
Can't print jpg files sent in emails - they're autosaved as HP MediaSmart photos
when someone sends me a .jpg file in an email, it comes thru as HP MediaSmart photo, and the only options are for "play". "rotate", edit or trash. There are no options for printing or saving. And you can't right click. So I can't accept any .jpg file