Sql insert statement will fail if the data value has empty line

Hi,
I notice if the insert statement in my .sql file contains data that has new line (enter key), the insert will fail.
For example:
insert into mytable (message)
values ('this is the first line
this is the second line that will cause insert statement to fail
so as this third line');
commit;
How to overcome this?
Please advise.
Thank you.
Message was edited by:
bchurn
Message was edited by:
bchurn

It did not return me any error. What is the error you are receiving ??
SQL> create table mytable (message varchar2(500));
Table created.
SQL> insert into mytable (message)
  2  values ('this is the first line
  3  this is the second line that will cause insert statement to fail
  4  so as this third line');
1 row created.
SQL> @c:\test.txt
1 row created.contents of c:\test.txt
<<
insert into mytable (message)
values ('this is the first line
this is the second line that will cause insert statement to fail
so as this third line');
>>

Similar Messages

  • Insert Statement Will Not Work if a user has

    I am using a MySQL database to process my Java Server Page form.
    Simply, I always try to see if I can process information, first, via the command line client, then thru JSP.
    At the command line client I type:
    I type insert into tablename (favorite_quote) VALUES
    ('Sleepin' in 'da house!');
    That insert throws an error. SImply said, because of the bunches of single quotes... Is there any advanced statement or insert statement to solve this?
    If I do this:
    INSERT INTO tablename (favorite_quote) VALUES
    ('Java');
    It adds the record perfectly normal...
    I am REALLY new to Java, so any help on this issue would be great!
    BTW: Part of my Java Server Pages has:
    String favorite_quote =request.getParameter("favorite_quote");
    "INSERT INTO tablename (favorite_quote) VALUES " +
    "('"+userid+"')";
    Obviously that works fine unless anybody adds a ' or " isn't or what's, etc.
    I'm loving Java, I just REALLY need some help on solving this issue.
    Thank you so much! Any help would BE **WONDERFUL**!

    String favorite_quote
    te =request.getParameter("favorite_quote");
    PreparedStatement ps =
    = connection.prepareStatement(""INSERT INTO tablename
    (favorite_quote) VALUES (?)");
    ps.setString(1, "Sleepin' in 'da house!");
    ps.execute();oops a small error
    PreparedStatement ps = connection.prepareStatement("INSERT INTO tablename (favorite_quote) VALUES (?)");

  • Generate SQL Insert Statements

    Hello,
    I am testing generating insert statements for which I have a function which will return a sql statement.
    This sql statement when I execute would results as sql insert statements.
    What I am trying to acheive through a procedure is when I execute function, the result I would like to execute automatically and then the second sql I would like to store to a control file or sql file.
    How can I acheive this?
    Any help is very helpful
    Regards
    Edited by: user20090209 on Aug 20, 2009 11:34 AM

    Here is the function to generate sql
    CREATE OR REPLACE function insert_sql(v_table_name varchar2)
    return varchar2 as
    b_found boolean := false;
    v varchar2(32000);
    v1 varchar2(32000);
    v2 varchar2(32000);
    begin
    for s in (
    select *
    from all_tables
    where table_name=upper(v_table_name)
    --and owner=upper(v_owner)
    ) loop
    b_found := true;
    for ss in (
    select *
    from all_tab_columns
    where table_name = s.table_name
    order by column_id
    ) loop
    if ss.data_type='NUMBER' then
    v1:=v1||','||ss.column_name;
    v2:=v2||',''''''||to_char('||ss.column_name||')||''''''';
    end if;
    if ss.data_type in ('VARCHAR2','CHAR') then
    v1:=v1||','||ss.column_name;
    v2:=v2||',''''''||replace(replace('||ss.column_name||','''''''',''''''''''''),''&'','''')||''''''';
    end if;
    if ss.data_type='DATE' then
    v1:=v1||','||ss.column_name;
    v2:=v2||',to_date(''''''||to_char('||ss.column_name||',''dd.mm.yyyy hh:mi:ss'')||'''''',''''dd.mm.yyyy hh:mi:ss'''')';
    end if;
    end loop;
    v:='select ''insert into '||s.table_name||' (';
    v:=v||substr(v1,2,9999)||') '||chr(10)||' values ('||substr(v2,2,9999)||'); '' txt from '||s.table_name;
    end loop;
    if not b_found then
    v:='- Table ' || v_table_name || ' not found';
    else
    v:=v;
    end if;
    return v;
    end;
    /And I am calling like
    CREATE OR REPLACE PROCEDURE test_gen_script_exec IS
    type v_ref_cur is REF CURSOR;
    v_ref_cur_var v_ref_cur;
    v_temp_sql VARCHAR2(4000);
    v_sql varchar2(4000);
    begin
    v_sql := insert_sql('table_name');--change here
    open v_ref_cur_var for v_sql;
    loop
    fetch v_ref_cur_var into v_temp_sql;
    exit when v_ref_cur_var%notfound;
    execute immediate v_temp_sql;
    end loop;
    close v_ref_cur_var;
    end;
    /Edited by: user20090209 on Aug 20, 2009 1:24 PM

  • Insert statement will not work if select statement has less number of colum

    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
    Either only specify explicit column in TEMP to get data,
    or provide value for "extra" column in TEMP

  • SQL Loader and foreign characters in the data file problem

    Hello,
    I have run into an issue which I can't find an answer for. When I run SQL Loader, one of my control files is used to get file content (LOBFILE) and one of the fields in the data file has a path to that file. The control file looks like:
    LOAD DATA
    INFILE 'PLACE_HOLDER.dat'
    INTO TABLE iceberg.rpt_document_core APPEND
    FIELDS TERMINATED BY ','
    doc_core_id "iceberg.seq_rpt_document_core.nextval",
    -- created_date POSITION(1) date "yyyy-mm-dd:hh24:mi:ss",
    created_date date "yyyy-mm-dd:hh24:mi:ss",
    document_size,
    hash,
    body_format,
    is_generic_doc,
    is_legacy_doc,
    external_filename FILLER char(275) ENCLOSED by '"',
    body LOBFILE(external_filename) terminated by EOF
    A sample data file looks like:
    0,2012-10-22:10:09:35,21,BB51344DD2127002118E286A197ECD4A,text,N,N,"E:\tmp\misc_files\index_testers\foreign\شیمیایی.txt"
    0,2012-10-22:10:09:35,17,CF85BE76B1E20704180534E19D363CF8,text,N,N,"E:\tmp\misc_files\index_testers\foreign\ลอบวางระเบิด.txt"
    0,2012-10-22:10:09:35,23552,47DB382558D69F170227AA18179FD0F0,binary,N,N,"E:\tmp\misc_files\index_testers\foreign\leesburgis_á_ñ_é_í_ó_ú_¿_¡_ü_99.doc"
    0,2012-10-22:10:09:35,17,83FCA0377445B60CE422DE8994900A79,binary,N,N,"E:\tmp\misc_files\index_testers\foreign\làm thế nào bạn làm ngày hôm nay"
    The problem is that whan I run this, SQL Loader throws an error that it can't find the file. It appears that it can't interpret the foreign characters in a way that allows it to find that path. I have tried adding a CHARACTERSET (using AL32UTF8 or UTF8) value in the control file but that only has some success with Western languages, not the ones listed above. Also, there is no set of defined languages that could be found in the data file. It essentaially could be any language.
    Does anyone know if there is a way to somehow get SQL Loader to "understand" the file system paths when a folder and/or file name could be in some other langauge?
    Thanks for any thoughts - Peter

    Thanks for the reply Harry. If I try to open the file in various text editors like Wordpad, Notepad, GVIM, andTextpad, they all display the foreign characters differently. Only Notepad comes close to displaying the characters properly. I have a C# app that will read the file and display the contents and it renders it fine. If you look at the directory of files in Windows Explorer, they all are displayed properly. So it seems things like .Net and Windows have some mechanism to understand the characters in order to render them properly. Other applications, again like Wordpad, do not know how to render them properly. It would seem that whatever SQL Loader is using to "read" the data files also is not rendering the characters properly which prevents it from finding the directory path to the file. If I add "CHARACTERSET AL32UTF8" in the control file, all is fine when dealing with Western langauges (ex, German, Spanish) but not for the Eastern languages (ex. Thai, Chinese). So .... telling SQL Loader to use a characterset seems to work, but not in all cases. The AL32UTF8 is the characterset that the Oracle database was created with. I have not had any luck if I try to set the CHARACTERSET to whatever the Thai character set is, for example. There problem there though is that even if that did work, I can't target specific lagauages because the data could come from anywhere. It's like I need some sort of global "super set" characterset to use. It seems like the CHARACTERSET is the right track to follow but I am not sure, and even if it is, is there a way to handle all languages.
    Thanks - Peter

  • The SAP SSO authentication will fail because the current user doesn't...

    Hi Experts!
    I am facing an issue and I have tried to do all the tips on answers of topics under same subject.
    Once I enter on my report and refresh, it prompts me a message that I don't have acess on one or more data providers, asking me if I want to proceed ( ID : WIS_30286) then I click yes and run the refresh and it prompts me another message: The SAP SSP authentication will fail because the current user doesn't have an alias that matches system BIDCLNT100..
    I checked the connection and tested, but the server not answers (SBO0001), on details I see the same message above.
    This on PRD, because on DEV it works fine.
    Thanks in advance!

    Hi,
    for the first part where you don't access I would suggest you do an authorization trace to ensure that the user has all the necessary authorizations.
    and on the second part - yes the user needs to have credentials for the system that you trying to access
    Ingo

  • In what order will select * return the data?

    hi guys,
    1) if we just do a select * from emp, will it return the data in the order of the data blocks in the extents. i.e. return all data blocks from extent 1, then from extent 2 and so forth?
    2) if we do a select * from emp, and say half the data blocks are already in the database buffer cache, how does Oracle know that the data blocks from emp are already in the database buffer cache? Does it keep some lookup table?
    thanks

    OracleGuy777 wrote:
    thanks guys,
    I will mark the question as closed, even though I am still a bit unsure as to why if we just start up a database so that the db cache is empty, and do a select * on a small table that is all on one disk, why the Oracle kernel would from a logical point of view choose different order to return the rows.
    but thanks anywayThe order in which rows are returned is a side effect of the execution plan chosen by the Query Optimizer (which is one reason why the ORDER BY clause exists), in plain relational theory both your underlying table and the results are relations (simply an unordered set of tuples) so consequently the optimizer is free to follow whatever method it likes to return the results. In the case of a Rule Based optimizer then there is simply a set of rules that determine the choice of execution plan, in the case of a cost based optimizer then the optimizer attempts to minimize the time taken to return the resultset by choosing an execution plan based on statistical information and algorithms. The existence of the buffer cache is in fact ignored for most practical purposes and certainly for the purposes you imagined.
    Now if your table is just that, a straight forward heap table with no indexes then you will likely get what you expect, that is rows returned in the order that the blocks in which they are held are located on disk; this isn't insert order necessarily by the way especially if ASSM is involved. This is only however because a full tablescan is the only available option for satisfying the query. Most tables however aren't like that, they have indexes, the query involves joins and filters and so on. Once you start allowing the possibility of other access paths then you allow the possibilty that rows or rather blocks will be visited in a different order to the simplistic one described above.
    Niall Litchfield

  • What will happen to the data block after data offloading?

    HI All,
    Since offloading can filter out the necessary information such as unnecessary columns and rows before they are passed to the database, I want to know what will happen to the data block? Will some new blocks be built at this time,which only contains the useful information?
    Best regards,
    Leon

    Andy Klock wrote:
    The statement seems to imply that Exadata has the ability to strip out columns from a block, but a block is a block is a block. Offloading is remarkable at filtering out data in the storage layer that ultimately is not needed but if you only need one row in a block that has 100 rows in it, you still get the whole block (and all 100 rows) to be processed by Oracle. The columns portion of the statement is when HCC is used for a table allowing only the blocks containing the column data required for the query, and thus if a block has 1000 column values in it, it will pass all 1000 column values to the instance to be processed.These assertions are incorrect.
    Blocks sent to the database grid as a result of a Smart Scan contain only the necessary columns and rows for the db grid to do its processing (after filter restrictions and projection restrictions are applied). These Smart Scan blocks are created at run time by the storage server so they have no bearing on the blocks that reside physically on disk which is why they can not be reused by other queries via the SGA and are read directly into the PGA space.
    Regards,
    Greg Rahn | blog | twitter | linkedin

  • Before I buy, will I see the date on photos in sorter?

    I'm looking for the right App to make movie / video  files from a photoshow.  I'm interested in iMovie but am concerned that I won't see the date stamp on my photo files like in the iPad photo albums.  I find this very annoying in the Photo app.  You can't sort or anything.  Will I see the date stamp of when the photo was taken if I download a photo to my iPad?  So I can sequence my pictures for a video?
    When I say date stamp, I don't mean a the date and time right on the photo.  I just want to know when the photo was taken and be able to sort a group of photos based on date taken.

    Photos are sorted by date and time, but the date and time is not shown in the app.

  • External drive not showing up - which disk initialization method will NOT erase the data on that external hard drive?

    Hi,
    as thousands of other users, my WD Passport drive worked like a charm until yesterday and now it wont show on any computer, but does show in the Disk management and when plugged in , the Disk Management offers two ways of initialization : MBR and GPT
    i dont understand any of that and want to know if any of those two methods will make the disk initialize wITHOUT loosing the data on the drive?
    i looked on so many forums and some people say that it will and others that it will not erase the data. 
    can you please tell me what is correct?? also a suggestion is to add some more wording to that initializaiton dialog box so that we can know what initialization does and doesnt
    thank you so much

    Try connecting it to a different computer to see if you can access the data, under no circumstances should you Initialize the drive as all existing data will be lost.
    If you still can't access your files, then remove the drive from the case and connect it via an extra SATA cable and power connector (you usually need a desktop PC in order to do this if the drive is a 3.5 inch model, a 2.5in drive will fit into a laptop
    if you have a spare slot).
    J W Stuart: http://www.pagestart.com
    Never be afraid to ask. This forum has some of the best people in the world available to help.

  • A string that can be displayed as both ASCII and hex in an indicator will only save the data to a file in ASCII format

    We can see the data in an indicator just fine, but when we try to write that string of hexadecimal data to a file, it will only save the data in ASCII format.  
    This sounds fairly simple, as the indicator can be selected to display the data in several different formats (VI>Properties>Appearance>Display Style: Normal, Backslash...., Hexadecimal).  However, I have been unable, as of yet, to save the data in different formats.
    Solved!
    Go to Solution.

    altenbach wrote:
    ... or you could just read the string:text.text property to get whatever is actually displayed.
    like this...
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    texttextString.PNG ‏6 KB

  • Delta failing on the data request

    Hello All,
    I have the following error on a delta that didn't even make it into BW (failing on the data request) "Syntax error in GP_ERR_RSDRO_UPDATE, row 1.893" - any idea on the problem?
    Thank you and kind regards,
    Keith

    Hi,
    This error seems to be in the Update from ODS, so check once again ur update rules for proper mapping, concentrate on the newly enhanced InfoObject. You are saying that u have added that InfoObject only in the InfoCube, what about the ODS ? from where that IO is getting data ? how u r updating that IO, check that as well.
    try to check if the table corresponding to the ODS (/BIC/A<ODS Object>40 or /BI0/A<ODS Object>40) is active. If not just run the program RSOD_XPRA_BDS_TO_KW to create the table and load it again...
    -Shreya

  • If I update my 4th gen ipod to the iOS 5, will I lose the data on my apps?

    If I update my 4th gen ipod to the iOS 5, will I lose the data on my apps?

    If everthing goes as planned, your app date wil be restored to the iPod. To help guard againste a possible mishap. sync (iTunes also creates a backup) the iPod before the udate and caopy the backup file to a save location in case something happens.  The backup is located here:
    Where iTunes backups are stored on your computer
    The folder where your backup data are stored varies depending on the computer's operating system. Make sure the backup folder is included in your periodic data-backup routine.
    iTunes places the backup files in the following places:
    Mac: ~/Library/Application Support/MobileSync/Backup/
    Windows XP: \Documents and Settings\(username)\Application Data\Apple Computer\MobileSync\Backup\
    Windows Vista and Windows 7: \Users\(username)\AppData\Roaming\Apple Computer\MobileSync\Backup\

  • What will happen to the data I´ve in my Key ring when migrating to iCloud

    What will happen to the data I´ve in my Key ring when migrating to iCloud?
    Any feedback is appreciated
    Uwe

    Hi Winston!
    Thanks for your quick response. I meant keychain items. So I you anserwed my question, perfectly.
    Best
    Uwe

  • "The Data entered is wrong, so it will revert to the previos value" error in Smartview

    A user is receiving the error "the data entered is wrong, so it will revert to the previous value" when working in excel and having a smart-view adhoc open. it doesn't happen all the time (it is not predictable) but it does happen regularly (3-5 times per week). If the user disconnects all connections in smartview or restarts excel, it temporarily fixes the issue.
    I have seen this error references in two other threads, not no answer. Can someone pelase help?

    Hello sher,
    You must be using certain formulas in other sheets which will connect back to your retrieval sheet and get the refreshed data from there.
    Try and use "Paste Values" to the formula columns to which you have once retrieved values from adhoc retrieval sheets. Hopefully this error should not occur then.
    Also check this thread : Excel Error "Data entered is wrong" when using multiple tabs
    Cheers!

Maybe you are looking for

  • Need advice on airport set up (home network)

    hi all, i am just wondering what the best set up would be for my home network, listed below are what i have set up, and what i think could be the best setup i have an office upstairs which contains: -ADSL2 modem -iMac 802.11n -PC wired -printer -750G

  • Trying to use hangouts for sms on verizon droid maxx but "can't compose"

    I'm trying to use hangouts for SMS on my Verizon Droid Maxx but the message "Can't compose. No default SMS app." displays when I try to compose (+") a new message, even though the top of the screen says that "Hangouts is your SMS app".  What do I nee

  • Single quotes around a variable

    Hi, I have values that are being passed into a variable with single quotes around. for eg: 'test'. So the value in variable v_empname will hold the value 'test' But then below sql statement returns null: select empid into v_empid from emp where empna

  • Touchsmart 310-1020 screen flicker

    My computer screen is flickering. I can see whats on it and everything works but it just looks like a strobe light is on my screen. I've tried updating/reinstalling drivers. Also the only option for refresh rate is 60 htz, so I can't change it. Any h

  • Canon MP460 Pixma won't install on MacBook Pro

    I am trying to use the setup CD that came with my canon mp 460 pixma printer (about 6 years old) in my brand new macbook pro....only i insert the CD, it begins to load, starts setup and then HOURS later, it's still on 71%. Goes no farther. I had to f