Running .sql file or insert statements
I have a large .sql file compiled from SQL developer from a SQL Server database. Whatever I do, I cannot get the rows to be permanently committed to the oracle db. I tried copying the text directly from the file and running it as a script on the Oracle server which seemed to work but the rows did not actually commit, they weren't available in the program and when I restarted the SQL Developer program they disappeared.
I also tried using SQL Plus and received the same results. I even tried copying just a single insert statement in with no success.
A second problem I have is when copying the entire file over, somewhere around line 500 it starts asking for substation variables, which I have no idea what they are or why it's asking for them.
Thanks for any help :)
Daft question, but have you got "commit" in your script?
Also, you'll need to "set define off" at the beginning of your script - & is the default prompt for SQLPLUS to ask for a variable, so if you're trying to insert "You & Me", it'll prompt you for a value for Me, unless you've got set define off.
Similar Messages
-
How to run SQL files from Java?
Hi,
Can someone point me towards a link on how to run sql files in Java? Thanks.
P.S...if I've been completely blind please go easy on me!Sorry forgot the formating code thingy
public static boolean executeScript(File script, Connection conn){
boolean success = true;
success = script.exists();
if(success){
DEBUG.print("ES::READING SCRIPT:" + script.getAbsolutePath());
StringBuffer buffer = new StringBuffer();
success=readScript(script,buffer);
if(success){
try{
String creationScript = buffer.toString();
Statement st = conn.createStatement();
int start = 0;
int end = 0;
while (end != -1 && start < creationScript.length()) {
end = creationScript.indexOf("GO", start);
if (end != -1) {
DEBUG.print(creationScript.substring(start, end));
st.executeUpdate(creationScript.substring(start, end));
start = end + 2; //2 is the length of "GO"
st.close();
}catch(Exception e){
success=false;
DEBUG.printStackTrace(e);
}else{
DEBUG.print("ES::SCRIPT FILE DOES NOT EXISTS");
success=false;
return success;
public static boolean readScript(File script, StringBuffer buffer){
boolean success = true;
DEBUG.print("RS:: reading file :" + script.getAbsolutePath());
try{
InputStreamReader isr = new InputStreamReader(new FileInputStream(script),"UTF16");
int ch;
while ( (ch = isr.read()) > -1) {
buffer.append( (char) ch);
if (isr != null)
isr.close();
}catch(Exception e){
success=false;
DEBUG.printStackTrace(e);
return success;
} -
How to run .sql file in tsql or powershell
Hi All,
HOw to run .sql file inside the TSQL or powershell using with IF else condition. This below query works fine but when i executing through the SQL Agent it's geeting an error.Please could help how to run through the SQL agent already using execution type
in agent as 'Operating system(CmdExec)'
Declare @computerName varchar(100), @InstanceName varchar(50)
SET @ComputerName = REPLACE(CAST(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS varchar),'\','$')
SET @InstanceName = REPLACE(CAST(SERVERPROPERTY('instancename') AS varchar),'\','$')
IF (@InstanceName = 'SQL2008R2')
Begin
:r C:\BackupFolder\Test1.sql
:r C:\BackupFolder\Test2.sql
End
IF (@InstanceName = 'SQLINS2')
BEGIN
:r C:\BackupFolder\Test3.sql
END
IF (@InstanceName = 'SQL2012')
BEGIN
:r C:\BackupFolder\Test4.sql
END
Thansk in Advance
A-ZSQLIn T-SQL, you can try using sqlcmd to invoke sql file
if @@SERVERNAME='abcd'
begin
Master..xp_cmdshell 'sqlcmd -S <ServerName> -i BackupDetails.sql -E'
end
OR
PowerShell
Load the snapins
Add-PSSnapin SqlServerCmdletSnapin100
Add-PSSnapin SqlServerProviderSnapin100
Function Get-SqlInstances {
Param($ServerName = '.')
$localInstances = @()
[array]$captions = gwmi win32_service -computerName $ServerName | ?{$_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe"} | %{$_.Caption}
foreach ($caption in $captions) {
if ($caption -like "MSSQLSERVER") {
$localInstances += $ServerName
} else {
$temp = $caption | %{$_.split(" ")[-1]} | %{$_.trimStart("(")} | %{$_.trimEnd(")")}
$localInstances += "$ServerName\$temp"
$localInstances
$instance=Get-SqlInstances -ServerName HQDBSP17
foreach($i in $instance)
if($i -like 'CRM2011')
write-host 'CRM Database'
invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
if( $i -like 'SQL2012')
write-host 'SQL 2012 instance'
invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
--Prashanth -
Is it possible to run .sql files in oracle
Hi
I have a .sql file which contains the scripts of the tables .Is it possible for me to run the .sql file in oracle or will i have to run the scripts of each tables separately becoz there is about 240 table scripts in that single .sql file. In mysql by giving " \.filename.sql " the whole scripts in the .sql file will get executed .Is there any thing like this in oracle9i.Also i want to know how to make a dump file in oracle and to run that?
Thanking you in advanceHi
I did the way u said the whole script file is running but the execution of the script is not happening. The below is a part of script but the table creation is not happening at the end of each table script
5946 drop table lms_class_permission;
5947 CREATE TABLE lms_class_permission (
5948 pk_permission_id NUMBER(11) NOT NULL ,
5949 fk_class_Id NUMBER(11) default NULL,
5950 fkSysGroupId NUMBER(11) default NULL,
5951 perm NUMBER(11) default '0',
5952 CONSTRAINT pk_permission_id_lms_class PRIMARY KEY (pk_permission_id),
5953 CONSTRAINT uk_lms_class_permission UNIQUE (fk_class_Id,fkSysGroupId),
5954 CONSTRAINT fk_lms_Class_Permission_1 FOREIGN KEY (fk_class_Id) REFERENCES lms_class (pk_class
5955 CONSTRAINT fk_lms_Class_Permission_2 FOREIGN KEY (fkSysGroupId) REFERENCES t_system_groups (g
5956 );
5957 create index fk_class_Id_lms_class_perm on lms_class_permission (fk_class_Id);
5958 create index fkSysGroupId on lms_class_permission (fkSysGroupId);
5959 CREATE SEQUENCE lms_class_permission_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NO
5960 CREATE OR REPLACE TRIGGER TR_lms_class_permission_BI
5961 BEFORE INSERT
5962 ON lms_class_permission
5963 REFERENCING NEW AS NEW OLD AS OLD
5964 FOR EACH ROW
5965 BEGIN
5966 SELECT lms_class_permission_SEQ.NEXTVAL INTO :NEW.pk_permission_id FROM dual;
5967 END ;
5968 drop table lms_contact_us ;
5969 CREATE TABLE lms_contact_us (
5970 pkautoid NUMBER(10) not null ,
5971 user_name VARCHAR2(255) default '0',
5972 email VARCHAR2(255) default '0',
5973 subject VARCHAR2(1000),
5974 message VARCHAR2(1000),
5975 loginId VARCHAR2(255) default NULL,
5976 status NUMBER(11) default NULL,
5977 classId NUMBER(11) default NULL,
5978 CONSTRAINT pkautoid_lms_contact_us PRIMARY KEY (pkautoid)
5979 );
5980 CREATE SEQUENCE lms_contact_us_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NOCYCLE NO
5981 CREATE OR REPLACE TRIGGER TR_lms_contact_us_BI
5982 BEFORE INSERT
5983 ON lms_contact_us
5984 REFERENCING NEW AS NEW OLD AS OLD
5985 FOR EACH ROW
5986 BEGIN
5987 SELECT lms_contact_us_SEQ.NEXTVAL INTO :NEW.pkautoid FROM dual;
5988 END ;
5989 drop table borland_feedback ;
5990 CREATE TABLE borland_feedback (
5991 pkautoid NUMBER(10) not null ,
5992 FeedTitle VARCHAR2(1000),
5993 FeedBody VARCHAR2(1000),
5994 EnteredBy NUMBER(11) default '0',
5995 FeedStatus NUMBER(11) default '0',
5996 FeedEnteredDate TIMESTAMP,
5997 CONSTRAINT pkautoid_borland_feedback PRIMARY KEY (pkautoid)
5998 );
5999 CREATE SEQUENCE borland_feedback_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NOCYCLE
6000 CREATE OR REPLACE TRIGGER TR_borland_feedback_BI
6001 BEFORE INSERT
6002 ON borland_feedback
6003 REFERENCING NEW AS NEW OLD AS OLD
6004 FOR EACH ROW
6005 BEGIN
6006 SELECT borland_feedback_SEQ.NEXTVAL INTO :NEW.pkautoid FROM dual;
6007 END ;
Thanking you advance
dinny -
Running SQL files in PL/SQL Cartdrige - OAS407
Hai!
I am unable to run the SQL file via a PL/SQL cartridge(without
creating the Stored procedure). I am able to run the SQL file
which is given in the sample&demos through the 'admin' listener
(port 8889). When i doing it through some other listener i am
getting error saying that URL not found.
I think I have configured the virtual path correctly for my
application and Cartridge.
Is there any thing else I am missing?
Thank you
Phanesh
nullI am working on this too. I am sure that the problem is the
procedures for the HTM are not install correctly. I read one
part of the documentation, it said that you have to log in as
SYS and grant some procedure to USER, but I forgot. If you
found it, PLEASE let me know. Thanks.
Phanesh (guest) wrote:
: Hai!
: I am unable to run the SQL file via a PL/SQL cartridge(without
: creating the Stored procedure). I am able to run the SQL file
: which is given in the sample&demos through the 'admin' listener
: (port 8889). When i doing it through some other listener i am
: getting error saying that URL not found.
: I think I have configured the virtual path correctly for my
: application and Cartridge.
: Is there any thing else I am missing?
: Thank you
: Phanesh
null -
Hi,
I have following files
1. SQL file which is created from shell script with same functionality.
2. SQL file which is a Procedure.
Both these SQLs are running successfully on Windows server. Will these SQLs run on UNIX server also?
Do I have to make any change in code so that they will run in UNIX?
Please let me know.
Thanks in advance.
AdityaTroll35 wrote:
Hello,
The SQL language is exactly the same between UNIX and windows. You only have to check none of your SQL files are refering to OS filenames with path included, because of course, OS path will not be the same between Unix and windows.
You might want to check character encoding and newlines before trying to run the script on a unix-box (especially in production... :-) )
If you can open and read the contents of the file, with say vi or less, you ought to be fine.
Brgds
Johan -
I have a Windows XP system and I'm running Sql Developer version 1.0.0.15.
I open a sql file in Oracle Developer and choose Run SQLFile.sql from the Run menu and it gives and error that it can't be started because it isn't a runnable target. However, if I just copy out the text and paste it into a worksheet it runs fine.
Why can't you run SQL when it is opened from a file?You need to associate it with a connection.
There is drop down list of connections at the top right of each sql window. Pick a connection from there and the run action should be enabled. -
Running .sql file from JDev9i???
In JDev 3.2.3 I could just right click on the sql file and invoke SQL*Plus. This does not appear in JDev9i. Could someone please lend some aid?
I think it is simply that the path to your
SQL*Plus is not set (or is incorrect).
Try menu Tools | Preferences
Click on the SQL*Plus element on Left
Enter the path to your SQL*Plus executable
$(OracleHome)\bin\SQLPLUSW.EXE)
and then it should work.
-John
null -
Getting error while running .sql file
Hi,
I export a schema "schema1" with name export1.sql i am trying to run this .sql at
schema2 i am getting an error ' input is too long () 2499 charecters"
even if put set buffersize 100000 and set define off i am getting same error file won't run.Any helpMake the lines shorter?
How are you producing the export1.sql script? -
Run sql statement from batch file
How can we execute SQL Statement using Batch file???
I did a test.
create batch file test.bat
sqlplus "username@db /pass" @\script.sql
script.sql file has following statement
select sysdate from dual;
exit
it is working but I want to call sql statement in the same batch file instead of calling .sql script file. how can I do that any idea..This is very easy in unix shell scripting, but AFAIK, not available with Windows. It's a function of how the shell/command processor handles input redirection.
-
How to Run a .sql file from simple java class
How to execute a .sql file consisting of Complex Queries,procedures through simple java class.
The queries may have different delimiters,queries independant of each other.
I am able to do with Specific De-limiter.But I need in such a way that there should not be any
Constraints. Since My .sql may Contain different De-limiters.
If any one can Suggest Some Solution.
It will be Great Help.
regards
AnilCheck out ibatis script runner, it' a third party library but quite handy for running sql files...
m -
Malformed INSERT statement - Sample Hyperion Planning with ODI
Hello,
I've tried to execute the sample Hyperion Planning pack with ODI, but it was found the following error below, I am beginner and I don't have faintest idea what it is.
My source is a CSV file and my target is Hyperion Planning.
7000 : null : java.sql.SQLException: Malformed INSERT statement.
java.sql.SQLException: Malformed INSERT statement.
at com.sunopsis.jdbc.driver.file.bb.a(bb.java)
at com.sunopsis.jdbc.driver.file.bb.a(bb.java)
at com.sunopsis.jdbc.driver.file.w.a(w.java)
at com.sunopsis.jdbc.driver.file.w.<init>(w.java)
at com.sunopsis.jdbc.driver.file.u.prepareStatement(u.java)
at com.sunopsis.sql.SnpsQuery.a(SnpsQuery.java)
at com.sunopsis.sql.SnpsQuery.a(SnpsQuery.java)
at com.sunopsis.sql.SnpsQuery.updateExecStatement(SnpsQuery.java)
at com.sunopsis.sql.SnpsQuery.executeQuery(SnpsQuery.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrdersScriptingOder(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
at com.sunopsis.dwg.cmd.e.i(e.java)
at com.sunopsis.dwg.cmd.g.y(g.java)
at com.sunopsis.dwg.cmd.e.run(e.java)
at java.lang.Thread.run(Unknown Source)Hello Mateus,
My source is CSV file and my target is Hyperion Planning.
I defined only one RKM for Hyperion Planning. There is a IKM SQL to Hyperion Planning. There are two technologies defined: one for Generic File and another to Hyperion Planning. These steps are defined on the sample manual of ODI - Hyperion Planning.
I created the interface without any warning or errors. But when I tried execute this rule, I have the following error return on the Operator module:
7000 : null : java.sql.SQLException: Malformed INSERT statement.
java.sql.SQLException: Malformed INSERT statement.
at com.sunopsis.jdbc.driver.file.bb.a(bb.java)
at com.sunopsis.jdbc.driver.file.bb.a(bb.java)
at com.sunopsis.jdbc.driver.file.w.a(w.java)
at com.sunopsis.jdbc.driver.file.w.<init>(w.java)
at com.sunopsis.jdbc.driver.file.u.prepareStatement(u.java)
at com.sunopsis.sql.SnpsQuery.a(SnpsQuery.java)
at com.sunopsis.sql.SnpsQuery.a(SnpsQuery.java)
at com.sunopsis.sql.SnpsQuery.updateExecStatement(SnpsQuery.java)
at com.sunopsis.sql.SnpsQuery.executeQuery(SnpsQuery.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execCollOrdersScriptingOder(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java)
at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
at com.sunopsis.dwg.cmd.e.i(e.java)
at com.sunopsis.dwg.cmd.g.y(g.java)
at com.sunopsis.dwg.cmd.e.run(e.java)
at java.lang.Thread.run(Unknown Source)
Thanks a lot for your help and attention,
Wallace Galvao -
How to export MySql queryBrowser to oracle's .sql file
Hi folks:
I was trying to export result set from MySql query browser to Oracle. I could able to do
File->Export Result Set-> Excel format...
What I am trying to get is .sql file so that I can run it as a script in my oracle db. Is there any way we can get .sql file with inserts and delimeters ....?
Did you guys get my question.?
Please throw some light on this....
Could be very appreciable ....
Thanks
Sudhir NaiduAs already pointed out the implementation is bad.
You should have:
USERS ( ID )
GROUPS ( ID )
USER_GROUPS( USER_ID,GROUP_ID )The reason for not using the CSV list is that not only is it hard to write efficient SQL against denormalised structures, but it is very difficult to constrain your data properly.
But anyhow, Oracle 10g has a MEMBER OF function. Too bad you're on 9i. You say "new task", is the platform still up for decision?
You could normalise on the fly like this
e.g.
SELECT t.GROUP_ID
,EXTRACTVALUE (csv_to_tab.COLUMN_VALUE, 'user')
user_id
FROM t_user t
,TABLE (XMLSEQUENCE (EXTRACT (XMLTYPE
( '<set><user>'|| REPLACE
(t.users,',','</user><user>' )
|| '</user></set>'), '/set/*'))) csv_to_tab -
How to execute a script(.sql) file from a PL\SQL procedure
I would like to know how to execute a .sql file from a stored procedure and the result of it should update a table. My .sql file contains select statements.
Hi!
just go through the following piece of code -
SQL> ed
Wrote file afiedt.buf
1 declare
2 str varchar2(200);
3 begin
4 str := '@C:\RND\Oracle\Misc\b.sql';
5 execute immediate(str);
6* end;
SQL> /
declare
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 5ORA-00900: invalid SQL statement
Cause: The statement is not recognized as a valid SQL statement. This error can occur if the Procedural Option is not installed and a SQL statement is issued that requires this option (for example, a CREATE PROCEDURE statement). You can determine if the Procedural Option is installed by starting SQL*Plus. If the PL/SQL banner is not displayed, then the option is not installed.
Action: Correct the syntax or install the Procedural Option.
Regards.
Satyaki De. -
Need command to run sql script from sql prompt
Hi,
I am beginner in sql i need a command to run sql file from sql prompt.In notepad i have write 10 to 15 tables creation and saved as .sql i want to run this file from sql promp pls some one help.I am very great full to all users in this forum.You can also use the 'start' command.
You may also want to look in the SQLPlus User Guide and Reference (for your release) at the set command for commands to set the number of lines per page, turn headings on or off, and so on:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/toc.htm
HTH -- Mark D Powell --
Maybe you are looking for
-
How do I find out if a ringtone is stored in the cloud? I had to restore my iPhone and the ringtone did not restore. For some reason, the file is not on my computer (in a format I can find anyway). My phone is fine now and I would like to simply f
-
Aperture 2.0 Previews not working in iPhoto 08
I am using Aperture 2.0 and iPhoto 08 with all the most recent updates available. I have iPhoto 08 setup to show previews of my Aperture projects. I did this by telling iPhoto not to organize my photos and leave them in the current location. The prev
-
Can't find older mail from archived install
I recently upgraded the OS on my iBook G4 to Tiger - and performed an archived install just to be safe. After installation was successful, most of my preferences transferred with the upgrade seamlessly (Calendar, Address Book items, bookmarks etc.) B
-
From the oracle documentation, http://docs.oracle.com/cd/E11882_01/server.112/e10701/original_export.htm#BABJHCDH it says that sequence numbers that have been allocated are available for use in the current database. I have a table Test which has a co
-
Is it mandatory to install patch 124861-15 for Applications R12
Hi, In pre-requisites it is says to install 124861-15 patch for Solaris R12.1.1 By the way we are upgrading from 11.5.10.2 to R12.1.3 with 11gR2 But for some reason out OS admin is not ablt to install. And he reckons that if we have sun studio 12, it