Conversion Oracle data into query
Hi everyone,
I've 1000 records in my table. Now i want to create the same table in another database. If i have script to create and insert all values, i can very easily execute it.
How to generate script for the Oracle table which contains 1000 records?
-haifriends
My Sample Table is
Master_CallType
~~~~~~~~~~~~
CallID CallType
~~~~ ~~~~~~
CT001 Monitor Problem
CT002 Network Problem
CT003 Keyboard Problem
I've a table like this. Create and insert query in used to create table and insert value. Now i've 1000 records in my table. I want to move this value to another database. I want it in script form to create table (with all constrainsts ) and insert value.
Similar Messages
-
Oracle date parameter query not working?
http://stackoverflow.com/questions/14539489/oracle-date-parameter-query-not-working
Trying to run the below query, but always fails even though the parameter values matches. I'm thinking there is a precision issue for :xRowVersion_prev parameter. I want too keep as much precision as possible.
Delete
from CONCURRENCYTESTITEMS
where ITEMID = :xItemId
and ROWVERSION = :xRowVersion_prev
The Oracle Rowversion is a TimestampLTZ and so is the oracle parameter type.
The same code & query works in Sql Server, but not Oracle.
Public Function CreateConnection() As IDbConnection
Dim sl As New SettingsLoader
Dim cs As String = sl.ObtainConnectionString
Dim cn As OracleConnection = New OracleConnection(cs)
cn.Open()
Return cn
End Function
Public Function CreateCommand(connection As IDbConnection) As IDbCommand
Dim cmd As OracleCommand = DirectCast(connection.CreateCommand, OracleCommand)
cmd.BindByName = True
Return cmd
End Function
<TestMethod()>
<TestCategory("Oracle")> _
Public Sub Test_POC_Delete()
Dim connection As IDbConnection = CreateConnection()
Dim rowver As DateTime = DateTime.Now
Dim id As Decimal
Using cmd As IDbCommand = CreateCommand(connection)
cmd.CommandText = "insert into CONCURRENCYTESTITEMS values(SEQ_CONCURRENCYTESTITEMS.nextval,'bla bla bla',:xRowVersion) returning ITEMID into :myOutputParameter"
Dim p As OracleParameter = New OracleParameter
p.Direction = ParameterDirection.ReturnValue
p.DbType = DbType.Decimal
p.ParameterName = "myOutputParameter"
cmd.Parameters.Add(p)
Dim v As OracleParameter = New OracleParameter
v.Direction = ParameterDirection.Input
v.OracleDbType = OracleDbType.TimeStampLTZ
v.ParameterName = "xRowVersion"
v.Value = rowver
cmd.Parameters.Add(v)
cmd.ExecuteNonQuery()
id = CType(p.Value, Decimal)
End Using
Using cmd As IDbCommand = m_DBTypesFactory.CreateCommand(connection)
cmd.CommandText = " Delete from CONCURRENCYTESTITEMS where ITEMID = :xItemId and ROWVERSION = :xRowVersion_prev"
Dim p As OracleParameter = New OracleParameter
p.Direction = ParameterDirection.Input
p.DbType = DbType.Decimal
p.ParameterName = "xItemId"
p.Value = id
cmd.Parameters.Add(p)
Dim v As OracleParameter = New OracleParameter
v.Direction = ParameterDirection.Input
v.OracleDbType = OracleDbType.TimeStampLTZ
v.ParameterName = "xRowVersion_prev"
v.Value = rowver
v.Precision = 6 '????
cmd.Parameters.Add(v)
Dim cnt As Integer = cmd.ExecuteNonQuery()
If cnt = 0 Then Assert.Fail() 'should delete
End Using
connection.Close()
End Sub
Schema:
-- ****** Object: Table SYSTEM.CONCURRENCYTESTITEMS Script Date: 1/26/2013 11:56:50 AM ******
CREATE TABLE "CONCURRENCYTESTITEMS" (
"ITEMID" NUMBER(19,0) NOT NULL,
"NOTES" NCHAR(200) NOT NULL,
"ROWVERSION" TIMESTAMP(6) WITH LOCAL TIME ZONE NOT NULL)
STORAGE (
NEXT 1048576 )
Sequence:
-- ****** Object: Sequence SYSTEM.SEQ_CONCURRENCYTESTITEMS Script Date: 1/26/2013 12:12:48 PM ******
CREATE SEQUENCE "SEQ_CONCURRENCYTESTITEMS"
START WITH 1
CACHE 20
MAXVALUE 9999999999999999999999999999still not comming...
i have one table each entry is having only one fromdata and one todate only
i am running below in sql it is showing two rows. ok.
select t1.U_frmdate,t1.U_todate ,ISNULL(t2.firstName,'')+ ',' +ISNULL(t2.middleName ,'')+','+ISNULL(t2.lastName,'') AS NAME, T2.empID AS EMPID, T2.U_emp AS Empticket,t2.U_PFAcc,t0.U_pf
from [@PR_PRCSAL1] t0 inner join [@PR_OPRCSAL] t1
on t0.DocEntry = t1.DocEntry
inner join ohem t2
on t2.empID = t0.U_empid where t0.U_empid between '830' and '850' and t1.U_frmdate ='20160801' and t1.u_todate='20160830'
in commond promt
select t1.U_frmdate,t1.U_todate ,ISNULL(t2.firstName,'')+ ',' +ISNULL(t2.middleName ,'')+','+ISNULL(t2.lastName,'') AS NAME, T2.empID AS EMPID, T2.U_emp AS Empticket,t2.U_PFAcc,t0.U_pf
from [@PR_PRCSAL1] t0 inner join [@PR_OPRCSAL] t1
on t0.DocEntry = t1.DocEntry
inner join ohem t2
on t2.empID = t0.U_empid where t0.U_empid between {?FromEmid} and {?ToEmid} and t1.U_frmdate ={?FDate} and t1.u_todate={?TDate}
still not showing any results.. -
How to load oracle data into SQL SERVER 2000?
how to load oracle data into SQL SERVER 2000.
IS THERE ANY UTILITY AVAILABLE?Not a concern for an Oracle forum.
Als no need for SHOUTING.
Conventional solutions are
- dump the data to a csv file and load it in Mickeysoft SQL server
- use Oracle Heterogeneous services
- use Mickeysoft DTS
Whatever you prefer.
Sybrand Bakker
Senior Oracle DBA -
Unable to replicate oracle data into timesten
I have created CACHE GROUP COMPANY_MASTER
Cache group :-
Cache Group TSLALGO.COMPANY_MASTER_TT:
Cache Group Type: Read Only
Autorefresh: Yes
Autorefresh Mode: Incremental
Autorefresh State: On
Autorefresh Interval: 1 Minute
Autorefresh Status: ok
Aging: No aging defined
Root Table: TSLALGO.COMPANY_MASTER
Table Type: Read Only
But whenever I start timesten server the following lock seen in ttxactadmin <dsn_name>
Program File Name: timestenorad
30443 0x7fab902c02f0 7.22 Active Database 0x01312d0001312d00 IX 0
Table 1733200 S 4221354128 TSLALGO.COMPANY_MASTER
Row BMUFVUAAAAaAAAAFBy S 4221354128 SYS.TABLES
Row BMUFVUAAACkAAAALAF Sn 4221354128 SYS.CACHE_GROUP
Due to the following lock oracle data is not replicated in timesten.
When we check sqlcmdid it shows following output
Query Optimizer Plan:
Query Text: CALL ttCacheLockCacheGp(4, '10752336#10751968#10751104#10749360#', 'S', '1111')
STEP: 1
LEVEL: 1
OPERATION: Procedure Call
TABLENAME:
TABLEOWNERNAME:
INDEXNAME:
INDEXEDPRED:
NONINDEXEDPRED:
Please suggest why timesten take lock on following table.966234 wrote:
Unable to download Oracle Data Integrator with version 11.1.1.6.Hope this could be resolved ASAP.What is the file you are trying to download? Is it for Windows or Linux or All Platforms?
Thanks,
Hussein -
Hi,
I am new to this forum so pls. pardon me if I am not familier with the rules. I need to know how to integrate DB Adapter data into BPEL rules engine. Actually, based on a status column value in Oracle table this rules engine would guide it to a human task. I need help to do this.
Thx,Hi
I am exactly working on the same scenario as below and wanted to use the Oracle Apps Adapter
1. Import the CSV files using File Adapter.
2. Move the CSV data into Oracle Staging Table using Databse Adapter.
3. Validate the Record by PL/SQL Package that i publish as WebService.
4. Move the Validated Record to Oracle Base table using Apps Adapter.
I created a package for validating the data and call the Oracle Seeded APIs and registered the same as a concurrent program. Now when i am trying to find the same concurrent program through apps adapter I couldn't find.
Am I missing something? Or do I have only one option to call the Concurrent Program through DB Adapter?
Can any one help me out please -
How to extract Oracle data into Excel file?
For a small automation project I have to extract data from a table/
tables and append it to the existing excel file and feed that excel
file to a command that will load data into some other environment. I
am totally new to this. So to get started I wanted to know,
1) How to extract data from sample table Foo which has columns A,B,C
and append these values as new columns to an existing excel say
fooresults.csv ?
2) Can I achieve this in pl/sql script or do I need to write unix or
perl script or some other programing language, please advise?The "extract data from a table" part is easy, you could do that with VB/ADO, or .NET/ODP.NET. It's then a matter of taking that data and appending it to a spreadsheet that might be the hard part, and how you'd do that exactly is really more of a Microsoft question than an Oracle one.
If you want to be able to do this from the database itself and your database is on Windows, you could use either [.NET Stored Procedures|http://www.oracle.com/technology/tech/dotnet/ode/index.html] if you can manipulate the spreadsheet in .net code, or you could also use Oracle's [COM Automation Feature|http://www.oracle.com/technology/tech/windows/com_auto/index.html] if you're handy with the COM object model for Excel.
How you'd do that exactly via either .net or com or vb is the crux of the problem and is something you'd need to know before it turns into an Oracle question, but if you already know how to do that and now just need to figure out a way to do that from Oracle, either of the above might help.
Hope it helps,
Greg -
Outbound oracle data into xml file
Hi Odie,
Your previous inputs for xml inbound was working fine, in the similar way now I need outbound the oracle apps data into .xml file format. For that I've written one sample script like this. I thought of making use of the utl_file option in Oracle apps.
declare
l_log_handle UTL_FILE.FILE_TYPE;
l_log_name varchar2(50);
l_path_2 varchar2(40);
l_global_file varchar2(50);
l_time number:=1;
cursor cur1 is
select xmltype(cursor(select * from fnd_menus where rownum <101)) a from dual;
--select menu_id from fnd_menus where rownum<100;
begin
BEGIN
SELECT DECODE (INSTR (VALUE, ','),
0, VALUE,
SUBSTR (VALUE, 1, (INSTR (VALUE, ',', 1)) - 1)
INTO l_path_2
FROM v$parameter
WHERE NAME = 'utl_file_dir';
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error while getting Unix Path ' || SQLERRM);
END;
l_log_name := 'XGBIZ_'||TO_CHAR (SYSDATE, 'YYMMDD')||l_time;
l_log_name := CONCAT(l_log_name,'.xml');
l_global_file := l_log_name;
l_log_handle := UTL_FILE.FOPEN(l_path_2,l_log_name,'W');
for cur2 in cur1 loop
UTL_FILE.PUT_LINE(l_log_handle, cur2);
end loop;
utl_file.fclose_all;
EXCEPTION
WHEN UTL_FILE.INVALID_OPERATION THEN
dbms_output.put_line('Invalid Operation For '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_PATH THEN
dbms_output.put_line('Invalid Path For '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_MODE THEN
dbms_output.put_line('Invalid Mode For '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
dbms_output.put_line('Invalid File Handle '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.WRITE_ERROR THEN
dbms_output.put_line('Invalid Write Error '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.READ_ERROR THEN
dbms_output.put_line('Invalid Read Error '|| l_global_file);
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INTERNAL_ERROR THEN
dbms_output.put_line('Internal Error');
UTL_FILE.FCLOSE_ALL;
WHEN OTHERS THEN
dbms_output.put_line('Other Error '||'SQL CODE: '||SQLCODE||' Messg: '||SQLERRM);
UTL_FILE.FCLOSE_ALL;
end;
when running this script I am getting error
ERROR at line 30:
ORA-06550: line 30, column 2:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 30, column 2:
PL/SQL: Statement ignored
if in the cursor declaration happen to use 'select menu_id from fnd_menus ' a plain record then it is successfully creating.
If tried again revert to actual select statement ' select xmltype(cursor(select * from fnd_menus where rownum <101)) a from dual'
then its erring out as above said.
Please give me your valuable inputs in this regard.
Thanks & Regards
NagendraHi,
There are multiple ways to generate XML documents from relational data.
Here are some :
-- SQL/XML functions : XMLElement, XMLAgg, XMLAttributes etc.
-- DBMS_XMLGEN package
select dbms_xmlgen.getXML('SELECT * FROM scott.emp')
from dual;-- XMLType constructor over a REF CURSOR (the one you chose)
select xmlserialize(document
xmltype(
cursor(
select *
from scott.emp
as clob
from dual;-- From a DBUriType
select xmlserialize(document
dburitype('/SCOTT/EMP').getXML()
as clob
from dual;-- From XQuery using ora:view function
select xmlserialize(document
xmlquery('<ROWSET>{ora:view("SCOTT","EMP")}</ROWSET>' returning content)
as clob indent size = 1
from dual;If a column is NULL in the result set, those methods (except XMLElement) won't create the corresponding element.
There's an option available for the XQuery method, but only in version 11.2.
So if you want to output empty elements, you'll have to use DBMS_XMLGEN with setNullHandling method :
DECLARE
ctx DBMS_XMLGEN.ctxHandle;
v_out CLOB;
rc SYS_REFCURSOR;
BEGIN
OPEN rc FOR
SELECT *
FROM scott.emp
ctx := DBMS_XMLGEN.newContext(rc);
DBMS_XMLGEN.setNullHandling(ctx, DBMS_XMLGEN.EMPTY_TAG);
v_out := DBMS_XMLGEN.getXML(ctx);
DBMS_XMLGEN.closeContext(ctx);
CLOSE rc;
DBMS_XSLPROCESSOR.clob2file(v_out, 'TEST_DIR', 'test_out.xml');
END;
I thought of making use of the utl_file option in Oracle apps.You could, but you might find DBMS_XSLPROCESSOR.clob2file procedure more convenient for that (see above).
All you have to do is serializing the XML in a CLOB variable, and call the procedure.
WHERE NAME = 'utl_file_dir';The "utl_file_dir" init. parameter is deprecated since 10g, use directory objects instead. -
Need to archive Oracle data into MS Access database
Gurus,
I've been tasked with archiving several large tables (10 million records) into an MS Access database. I'm looking through MS Access help guide which states that I can use the ODBC driver to create table, column definitions, and import data.
Does anyone have any good resources on creating an ODBC driver for MS Access. Also, any reference material would be greatly appreciated.
Thanks
Scottsreese wrote:
Gurus,
I've been tasked with archiving several large tables (10 million records) into an MS Access database. On the face of it, that is an astoundingly bad idea. Using the worst database product (I can't even really refer to it as an RDBMS) on the planet to archive data that is already in the best RDBMS on the planet?
What does the person who came up with this idea expect to achieve?
I'm looking through MS Access help guide which states that I can use the ODBC driver to create table, column definitions, and import data. ODBC drivers don't create anything. They provide a common link between ODBC enabled apps and the native db interface.
>
Does anyone have any good resources on creating an ODBC driver for MS Access. You don't create the driver. It is provided by either MS or Oracle (they both have them). You just configure a connection definition (aka "Data Source Name" or DSN) that utilizes it.
Also, any reference material would be greatly appreciated.
Thanks
Scott -
Conversion of Date into Number of Days
Hai All,
Can anyone pls tell how to convert the Date format into Number of days.
For example I have 2 dates, 25.03.2009 and 25.02.2009.
I have to take the difference of these two dates, means its 30 days.
Later I have to move this 30 days to a variable and display.
Can anyone help me.Try these FMs.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = p_sdate
i_datum_von = p_edate
IMPORTING
e_tage = l_differ
EXCEPTIONS
days_method_not_defined = 1
others = 2.
WRITE:/ l_differ.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from = p_sdate
i_date_to = p_edate
I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = EDAYS
E_MONTHS = EMONTHS
E_YEARS = EYEARS.
WRITE:/ No of Days ', EDAYS.
Regards,
Joan -
How to conver the oracle data into xml files
Hi All,
I have a table for ex emp, now i want to generate every row into an xml file. could anyone pls help...
ex:- emp table
eno ename sal
1 bond 3000
2 kiran 2000
3 jai 1000
4 henry 500
o/p :- i have to get a column in 4 different files for this 4 rows.
1.xml file should contain data <ID>1</ID><eNAME>bond</eNAME><sal>3000</sal>
2.xml file should contain data <ID>2</ID><eNAME>kiran</eNAME><sal>2000</sal>
3.xml file should contain data <ID>3</ID><eNAME>jai</eNAME><sal>1000</sal>
4.xml file should contain data <ID>1</ID><eNAME>bond</eNAME><sal>500</sal>
regards,
Badri.You can do it like this :
begin
for r in (
select empno
, xmlserialize(content xmlforest(empno as "ID", ename, sal)) as xmlcontent
from scott.emp
loop
dbms_xslprocessor.clob2file(r.xmlcontent, 'TEST_DIR', to_char(r.empno) || '.xml');
end loop;
end; -
Hi All,
I am using Oracle SQL Developer Data modeler tool. Find it a very good tool for database designing and its free. Here I can connect to Oracle database and get complete ER diagram, but I didn't see any place through which I can Reverse Engineer changes made to ER Diagram back to Schema.
Do anybody have any idea about this.
Thanks,
Danish. Find it a very good tool for database designing and its free.Actually it's not free. The "free" version was an Early Adopter release and not intended for commercial use. The first production release is a very-far-from-free USD 3000 per seat. Worth it? Dunno, I haven't installed the production release yet.
The EA2 version of the tool does support forward engineering but it doesn't generate diffs between the existing schema and the new one, like Designer could.
Cheers, APC
blog: http://radiofreetooting.blogspot.com -
How to convert Oracle Data into Java Date
Hi there,
in JDev 3.2 oracle.jbo.domain.Date was derived from oracle.sql.DATE, which has a timestampValue() method to get a java.sql.Timestamp.
In Jdev 9.0.3 Date is not!! derived from oracle.sql.DATE, so my previous implementation fails.
So, How can I get a java.util.Date from oracle.jbo.Date?
( I think this is a bug !?)Hi Dietmar,
this is documented in the help; see Reference - Business Components Oracle Domains; then choose 'Date'
using the dateValue() method on the oracle.jdo.domain.Date gives you a java.sql.Date which is a (subclass of) java.util.Date.
Cheers, Hans -
Insert Today's Date into query
I created a query and want it to filter based on todays date. How do I automatically add todays date to the query so the user does not need to type it in?
Yes you are right. You will need to use WHERE convert(varchar, T0.refdate, 103) = convert(varchar, getdate(), 103)
This is because the getdate() is actually a datetime field and returns current date and current time so in the previous statement you are asking for journal fields where the posting date = todays date AND the exact time that the query is run which is never going to be true.
If you just use getdate()-1 you will also get yesterdays' journals posted after this time yesterday. -
What's the best way to export UTF8 data into Excel?
Hi,
Database charterer set is UTF8
PARAMETER VALUE
1 NLS_NCHAR_CHARACTERSET UTF8
2 NLS_CHARACTERSET UTF8
My requirement is that I want to export oracle data into excel file by using UTL_FILE oracle supplied package.
But while writing data into excel files it’s looses in UTF8 encoding and writes some garbage data into file.
I am very much sure that while retrieving the data form database it is perfectly encoded with UTF8, but after data is written to the file it eats the UTF encoding resulting into some garbage data.
e.g.
I am retrieving this filed from database which is UTF8 encoded in DB “Langäcker 55” but when it is written into excel it becomes “Langäcker 55”.
Is Oracle UTL_FILE eating the UTF8 encoding while writing into file? if yes, is there utility which can help me to remain the UTF8 encoding as it is while writing in to excel file? Is there anythingi can do in Oracle to get this done?
Thanks in advance.
Thanks,
SantoshUntil now I have not found anyone who could write real Excel files (MS binary format) in PL/SQL. So I assume that you write your data in strings separated by a character like ; or |, aka CSV.
Try to open your file with 'wb' (write binary) instead of 'w' and then use
-- write data
utl_file.put_raw(v_file,utl_raw.cast_to_raw(<your data>));
--write remaining data
utl_file.fflush(v_file);
--close the file
utl_file.fclose(v_file);Regards
Marcus -
Query Data from other Oracle Database into current
Hi all,
I have to query data from another oracle database into the current oracle database. Because the customer has standard edition, I cannot use a pipe. I tried "SELECT column_name FROM external_oracle_db.schema.table WHERE column_name = 'column_value';" Unfortunately this does not work.
Does anyone have a suggestion?
Thanks
HansHave you tried with Database links?
SELECT column_name FROM schema.table@external_oracle_db WHERE column_name = 'column_value';
Satish
Maybe you are looking for
-
BEx Cell Report - Performance Issue
All, We have a BEx Report in which I have used cell formulas extensively. My BW ver 3.0B and parch 31. From last f32 weeks this report is working only for maximum of 9 materials. Tthe report output comes very fast. The momemnt I give 10th material or
-
Not able to open pdf and adobe reader on windows xp sp3.
Hello, I am not able to open pdf and adobe reader on my windows xp sp3 computer. I have reinstalled adobe reader 11.0.3 twice, but, no luck. I would appreciate if you could help me in resolving this issue. Thanks in advance. Regards, Venkata
-
Hello, Is it possible to set a default value at Terms of Payment when I create a new customer? (XD01) Thanks in advance, Ricard.
-
How do I keep Finder Tabs open after a restart?
After opening several Tabs in Finder, I find they have closed after I´ve shut down & then (Later), restart my Mac Mini. The Safari tabs stay open. Cant find anything in `Finder Preferences´ or in `System Preferences´. Anyone know???
-
How do I save audio adjustments I make to my project?
I have just opened up a video project I created last week, to find it has not saved the audio adjustments that I made to it (background noise reduction etc.) Could anyone advise me how I save these adjustments?