Blank line in string value in insert statement causing problems
I am generating an sql statement (insert) from an xml document using xsl transformation that is later run in an sqlplus session. The issue I am coming across is that one of the tags contains free-form text that can be any number of lines. Most strings are not causing a problem, but when there is a blank line in the string (two or more endline characters together) sqlplus seems to think this signifies the end of a statement. Here is an example that I hope will clarify what is being created.
INSERT INTO MYTABLE VALUES('THIS WORKS', 0, NULL, ...);
INSERT INTO MYTABLE VALUES('THIS
ALSO
WORKS', 0, NULL, ...);
INSERT INTO MYTABLE VALUES('THIS
DOES NOT
WORK', 0, NULL, ...);
Anyone seen this problem before or have a quick fix? All I can come up with is to pre-process the xml document (which, by the way, I have no control over the format as it comes from a client) to compress vertical whitespace. (This seems like overkill to me). Any suggestions would be appreciated.
Thanks,
Daniel
I don't know if this will work for u.
If ur string has more than one end of lines and u don't need them, u can replace them by a single space using
replace(string,chr(13)||chr(10),' ').
If this does not solve ur problem then probably ur srting has a special charachter. To remove it
take the ascii value of the special character and then see what is the corresponding chr value and then use replace function in ur insert statement where u find this special character.
I too face same kind of problem and this worked for me.
Similar Messages
-
How to retrieve value from insert statement
hi,
how can i get a certain value from insert statement and store it in a variable.
suppose i am inserting emp_no , emp_name , emp_salary to employee table
and i want to store the emp_name in a variable for other processing,
how can i accomplish this ? i'm guessing that i have to use trigger,
but dont know the procedure .
any help will be greatly appreciated
thanksinsert into <table> valiues (....) returning <expression> into <variable>
You could and should have found this using the SQL Language reference manual
or
http://www.morganslibrary.org/reference/insert.html
Sybrand Bakker
Senior Oracle DBA -
How to assign value from insert statement to variable from a trigger
Hi,
I got this really annoying problem and I don't know if I am doing it correctly.
I have a BEFORE INSERT trigger on a table. When someone executes an insert statement I want to grab the value of a column from that statement and assign it to a variable and then do stuff with it. I'm stuck on the assignment.. look below..
CREATE OR REPLACE TRIGGER CARS.geotest2_trigger
BEFORE INSERT ON CARS.GEO_TEST2
FOR EACH ROW
DECLARE
v_chainkey nchar(32);
v_chainkey2 nchar(32);
not_exists EXCEPTION;
BEGIN
:NEW.CHAINKEY := v_chainkey;
SELECT GEO_TEST.CHAINKEY INTO v_chainkey2 FROM GEO_TEST WHERE GEO_TEST.CHAINKEY = v_chainkey;
IF v_chainkey2 = '' or v_chainkey2 is null THEN
RAISE not_exists;
ELSE
INSERT INTO GEO_TEST2 VALUES(:NEW.CHAINKEY, :NEW.BLA, :NEW.FOO);
END IF;
EXCEPTION
WHEN not_exists THEN
RAISE_APPLICATION_ERROR(-20010, 'Chainkey does not exist in parent table GEO_TEST');
END;
I keep getting this error
Error: ORA-04098: trigger 'CARS.GEOTEST2_TRIGGER' is invalid and failed re-validation
SQLState: 42000
ErrorCode: 4098It isn't assigning because v_chainkey is not at the left hand side of the assignment statement.
test@ORA10G>
test@ORA10G>
test@ORA10G> declare
2 x number := 5;
3 y number;
4 begin
5 x := y; -- does not assign anything to y; assigns NULL to x,
6 -- because y is NULL at this point
7 -- so, essentially the value 5 of x is *LOST* now
8 dbms_output.put_line('x = '||x);
9 end;
10 /
x =
PL/SQL procedure successfully completed.
test@ORA10G>
test@ORA10G>
test@ORA10G>In any case, here's what you are probably looking for:
test@ORA10G>
test@ORA10G> --
test@ORA10G> drop table geo_test;
drop table geo_test
ERROR at line 1:
ORA-00942: table or view does not exist
test@ORA10G> drop table geo_test2;
drop table geo_test2
ERROR at line 1:
ORA-00942: table or view does not exist
test@ORA10G>
test@ORA10G> create table geo_test (chainkey nchar(32));
Table created.
test@ORA10G> insert into geo_test (chainkey) values ('a');
1 row created.
test@ORA10G> insert into geo_test (chainkey) values ('');
1 row created.
test@ORA10G>
test@ORA10G> create table geo_test2 (chainkey nchar(32), bla number(1), foo number(1));
Table created.
test@ORA10G>
test@ORA10G>
test@ORA10G> CREATE OR REPLACE TRIGGER geotest2_trigger
2 BEFORE INSERT ON GEO_TEST2
3 FOR EACH ROW
4 DECLARE
5 v_chainkey2 nchar(32);
6 not_exists EXCEPTION;
7 BEGIN
8 SELECT GEO_TEST.CHAINKEY INTO v_chainkey2 FROM GEO_TEST WHERE nvl(GEO_TEST.CHAINKEY,'~') = nvl(:new.chainkey,'~');
9 IF v_chainkey2 is null THEN
10 RAISE not_exists;
11 END IF;
12 EXCEPTION
13 WHEN not_exists THEN
14 RAISE_APPLICATION_ERROR(-20010, 'Chainkey does not exist in parent table GEO_TEST');
15 END;
16 /
Trigger created.
test@ORA10G>
test@ORA10G> --
test@ORA10G> insert into geo_test2 (chainkey,bla,foo) values ('b',1,1);
insert into geo_test2 (chainkey,bla,foo) values ('b',1,1)
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "TEST.GEOTEST2_TRIGGER", line 5
ORA-04088: error during execution of trigger 'TEST.GEOTEST2_TRIGGER'
test@ORA10G>
test@ORA10G> --
test@ORA10G> insert into geo_test2 (chainkey,bla,foo) values (null,1,1);
insert into geo_test2 (chainkey,bla,foo) values (null,1,1)
ERROR at line 1:
ORA-20010: Chainkey does not exist in parent table GEO_TEST
ORA-06512: at "TEST.GEOTEST2_TRIGGER", line 11
ORA-04088: error during execution of trigger 'TEST.GEOTEST2_TRIGGER'
test@ORA10G>
test@ORA10G> --
test@ORA10G> insert into geo_test2 (chainkey,bla,foo) values ('a',1,1);
1 row created.
test@ORA10G>
test@ORA10G>
test@ORA10G>pratz
I think the sole purpose of that "not_exists" exception is this -
If you try to insert a NULL value for GEO_TEST2.CHAINKEY, then this trigger will throw an error even if at least one NULL value exists in GEO_TEST.CHAINKEY column.
Not sure if that's something that you wanted.
Message was edited by:
pratz -
Feature Request - show substitution string values in session state display
Hi!
I would like to request that in addition to page and application items and session state values that the value of substitution string values be shown. Another option would be to have a separate link (like session) to display them. This would allow developers to see all of the available substitution values and how they change across pages, etc.
Thanks!
Dave VenusDave - What are some examples of values that you are not seeing in the session state report that would be useful?
Scott -
Nds Insert statement little problem
DB version XE 10g
Hello
I have little problem with my insert statement.
In my code, are many examples, but plz focus on V2 and V3 part.
As you can see V2 and V3 are not working
I get following errors
V2
Error report:
ORA-00984: column not allowed here
ORA-06512: AT line 28
00984. 00000 - "column not allowed here"
V3
Error report:
ORA-00917: missing comma
ORA-06512: AT line 33
00917. 00000 - "missing comma"
I really have no idea, why i'm getting these errors...
DROP TABLE FILMYARNOLD;
CREATE TABLE FILMYARNOLD
FIL_ID VARCHAR2 (329),
FIL_NAME VARCHAR2 (592),
FIL_YEAR VARCHAR2 (294),
FIL_ACTOR VARCHAR2 (392),
FIL_TEXTT VARCHAR2 (2596)
SET SERVEROUTPUT ON
DECLARE
TYPE FIL_TABLE IS TABLE OF VARCHAR2 (256);
vfilmiczki FIL_TABLE := fil_table();
statement VARCHAR2 (2048);
BEGIN
vfilmiczki.EXTEND;
vfilmiczki(1) := '77804';
vfilmiczki.EXTEND;
vfilmiczki(2) := 'Predator';
vfilmiczki.EXTEND;
vfilmiczki(3) := '1984';
vfilmiczki.EXTEND;
vfilmiczki(4) := 'Arnold';
vfilmiczki.EXTEND;
vfilmiczki(5) := 'get to the choppa';
/*statement := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT) VALUES ( ';
statement := statement|| '''chlip'',''lol'',''lol'',''chlip''';--
statement := statement||',''hmm'')';*/
-------V1------------working-----------------
--statement := 'INSERT INTO FILMYARNOLD (FIL_ID) VALUES ( ';
--statement := statement||vfilmiczki(1)||' )';
--EXECUTE IMMEDIATE statement;
--------V2-------------------- not working -----------------------------------------
--statement := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME) VALUES ( ';
--statement := statement||vfilmiczki(1)||','||vfilmiczki(2)||' )';
--EXECUTE IMMEDIATE statement;
----V3------------ not working ------------
statement := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT) VALUES ( ';
statement := statement||vfilmiczki(1)||','||vfilmiczki(2)||','||vfilmiczki(3)||','||vfilmiczki(4)||','||vfilmiczki(5)||' )';
EXECUTE IMMEDIATE statement;
/* statement := 'INSERT INTO FILMYARNOLD VALUES (:jeden, :dwa, :trzy, :cztery, :piec)';
EXECUTE IMMEDIATE statement
USING vfilmiczki(1)
, vfilmiczki(2)
, vfilmiczki(3)
, vfilmiczki(4)
, vfilmiczki(5); */
statement := 'INSERT INTO FILMYARNOLD VALUES ('; --(:jeden, :dwa, :trzy, :cztery, :piec)';
FOR i IN 1..vfilmiczki.COUNT
LOOP
IF i = vfilmiczki.LAST THEN
statement := statement||vfilmiczki(i)||' )';
ELSE
statement := statement||vfilmiczki(i)||', ';
END IF;
--DBMS_OUTPUT.PUT_LINE (vfilmiczki(i));
END LOOP;
EXECUTE IMMEDIATE statement;
--INSERT INTO FILMYARNOLD
--VALUES (vfilmiczki(vfilmiczki.FIRST),vfilmiczki(2),vfilmiczki(3),
--vfilmiczki(4), vfilmiczki(5));
--DBMS_OUTPUT.PUT_LINE ('*****************');
--DBMS_OUTPUT.PUT_LINE (vfilmiczki((vfilmiczki.LAST)));
END;
/Im waiting for your replys
greetingsHi,
change V2 to:
STATEMENT := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME) VALUES ( ';
STATEMENT := STATEMENT||VFILMICZKI(1)||','''||VFILMICZKI(2)||''' )';
EXECUTE IMMEDIATE statement;and V3 to:
----V3------------ not working ------------
STATEMENT := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT) VALUES ( ';
STATEMENT := STATEMENT||VFILMICZKI(1)||','''||VFILMICZKI(2)||''','||VFILMICZKI(3)
||','''||VFILMICZKI(4)||''','''||VFILMICZKI(5)||''' )';
EXECUTE IMMEDIATE statement;EXECUTE IMMEDIATE statement;One general remark: INSERT can be used directly in PL/SQL, you don't need to bother with dynamic SQL,
and the direct SQL will be probably more efficient than dynamic SQL.
Try this:
SET SERVEROUTPUT ON
DECLARE
TYPE FIL_TABLE IS TABLE OF VARCHAR2 (256);
vfilmiczki FIL_TABLE := fil_table();
statement VARCHAR2 (2048);
BEGIN
vfilmiczki.EXTEND;
vfilmiczki(1) := '77804';
vfilmiczki.EXTEND;
vfilmiczki(2) := 'Predator';
vfilmiczki.EXTEND;
vfilmiczki(3) := '1984';
vfilmiczki.EXTEND;
vfilmiczki(4) := 'Arnold';
vfilmiczki.EXTEND;
vfilmiczki(5) := 'get to the choppa';
-------V1------------working-----------------
INSERT INTO FILMYARNOLD (FIL_ID) VALUES ( VFILMICZKI(1) );
--------V2-------------------- not working -----------------------------------------
INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME) VALUES ( VFILMICZKI(1),VFILMICZKI(2));
----V3------------ not working ------------
INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT)
VALUES ( VFILMICZKI(1), VFILMICZKI(2), VFILMICZKI(3), VFILMICZKI(4), VFILMICZKI(5));
END;
/ -
How to set a dropdown to the blank line value
Hi all,
maybe a very easy question.
How can I set a dropdownbyindex value to the blank line?
If I use e.g.
wdContext.currentActionsElement().setDescription(null);
it adds another blank line among the values and if I try with:
wdContext.nodeActions().setLeadSelection(0);
it doesn't work.
Any suggestion?
Thanks in advance.
AngelowdContext.nodeActions().setLeadSelection(IWDNode.NO_SELECTION);
Check that node selection is not mandatory (i.e. selection cardinality is 0..1, not 1..1).
If this does not help set initializeLeadSelection to false for this node.
VS -
Where is the syntax error in my Insert statement?
It says that there is a syntax error in my insert statement, pointing to the .ExecuteNonQuery() at the end:
'Defining the activity ID from the datatable
Dim ActivityID As Integer = DataTableActivities.Rows(0).Item(0)
'Defining the calories from the datatable
Dim calories As Decimal = (DataTableActivities.Rows(0).Item(3)) * (DurationNum.Value / 60)
'Insert statement to add new training events
Dim SqlQueryActivityInsert As String = "INSERT INTO tblTraining (RunnerID, ActivityID, Full_Name, Time, Calories_Burnt, Date) VALUES (@RunnerID, @ActivityID, @Full_Name, @Time, @Calories, @Date)"
Dim SqlCommandActivity As New OleDbCommand
With SqlCommandActivity
.CommandText = SqlQueryActivityInsert
.Parameters.AddWithValue("@RunnerID", LoginForm.UserIDlbl.Text)
.Parameters.AddWithValue("@ActivityID", ActivityID)
.Parameters.AddWithValue("@Full_Name", LoginForm.Full_Namelbl.Text)
.Parameters.AddWithValue("@Time", DurationNum.Value)
.Parameters.AddWithValue("@Calories", calories)
.Parameters.AddWithValue("@Date", WeekPicker.Value)
.Connection = conn
.ExecuteNonQuery()Viorel is right. The 'Date' field is probably throwing it off. Date is a reserved word.
https://www.drupal.org/node/141051
Putting square brackets [] around the field name should get it working for you.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
How do you force source formatting to leave blank lines in CS6?
I inherited some code with paragraph breaks between some lines so that there's a blank line between two lines of code. When I Apply Source Formatting, the original blank lines remains, but when I insert a blank line & then Apply Source Formatting, the blank lines I inserted disappear.
I showed the hidden characters and found that on the lines that remain blank, there are 4 spaces & a paragraph marker. When insert the same thing, source formatting still removes my blank lines, but keeps the ones that someone else inserted (while not using DW) by adding 4 spaces & a paragraph marker.
Is this behavior due to opening a file that was created outside of DW? Is there anyway to get source formatting to leave my inserted blank lines alone?
Thanks!That worked: I want to be able to preserve blank lines when I apply source formatting, not get rid of them. I copied the lines that didn't disappear & they were also preserved wherever I copied them in my doc.
It would be nice to know what that hidden character is that prevents the blank line from being removed, but I guess I can't tell with DW. -
How do I remove a blank line in the tool bars area?
I have a blank line between a couple of the lines in the toolbar area(Between the back/forward/home/reload line and the Googlebar Lite line. How can I remove this extra blank line/space?
This issue can be caused by an extension or plugin that isn't working properly.
See:
* [[Troubleshooting extensions and themes]]
* [[Troubleshooting plugins]] -
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:
bchurnIt 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');
>> -
I have been looking at my code for hours now and cant figure out what is wrong. The error has kept popping up even when i thought i had fixed everything. maybe a second set of eyes could help me out here. If you could help me out it would be much appreciated.
USE [ConorsSetKits]
GO
CREATE TABLE Customers (
CustomerID Int NOT NULL IDENTITY(1000,1),
LastName NChar(30) NOT NULL,
FirstName NChar(30) NOT NULL,
Address NChar(50) NOT NULL,
City NChar(30) NOT NULL,
State NChar(2) NOT NULL,
Zip Numeric(5) NOT NULL,
Email NVarChar(50) NOT NULL,
DateOfBirth Numeric (4) NOT NULL,
CONSTRAINT CustomersPK PRIMARY KEY(CustomerID),
CONSTRAINT ValidZip
CHECK ( [Zip] LIKE '[0-9][0-9][0-9][0-9][0-9]' ),
CONSTRAINT ValidState
CHECK( LEN([State]) = 2),
CONSTRAINT DateOfBirth
CHECK ([DateOfBirth] BETWEEN '1920-01-01' AND getdate() - 5844));
CREATE TABLE Sets (
SetID Int NOT NULL IDENTITY(1000,1) Primary Key,
SetName NChar(20) NOT NULL,
SetType NChar (20) NOT NULL,
Price Numeric (20) NOT NULL,
Quantity Numeric (50) NOT NULL,
CONSTRAINT SetTypeCheck
CHECK (SetType IN ('Planes','Tanks','Robots','Cars','Helicopters','Boats','Trains','Motorcycles','Jets')),
CONSTRAINT ValidQuantity
CHECK (Quantity >= 0)
CREATE TABLE Orders (
OrderID Int NOT NULL IDENTITY(1000,1),
CustomerID Int NOT NULL,
OrderDate Date NOT NULL,
CONSTRAINT CAIntPK PRIMARY KEY(OrderID, CustomerID),
SET IDENTITY_INSERT dbo.CUSTOMER OFF
SET IDENTITY_INSERT dbo.Sets OFF
SET IDENTITY_INSERT dbo.Orders OFF
SET IDENTITY_INSERT dbo.CUSTOMER ON
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1000, 'Janes', 'Jeffrey', '123 W. Elm St', 'Renton', 'WA', '98055',
'[email protected]',1985);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1001, 'Smith', 'David', '813 Tumbleweed Lane', 'Loveland', 'CO', '81201',
'[email protected]',1992);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1015, 'Twilight', 'Tiffany', '88 1st Avenue', 'Langley', 'WA', '98260',
'[email protected]',1972);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1033, 'Smathers', 'Fred', '10899 88th Ave', 'Bainbridge Island', 'WA', '98110',
'[email protected]',1980);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1034, 'Frederickson', 'Mary Beth', '25 South Lafayette', 'Denver', 'CO', '80201',
'[email protected]',1970);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1036, 'Warning', 'Selma', '205 Burnaby', 'Vancouver', 'BC', '80201',
'[email protected]',1981);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1037, 'Wu', 'Susan', '105 Locust Ave', 'Atlanta', 'GA', '30322',
'404', '653-3465', '[email protected]',1971);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1040, 'Gray', 'Donald','55 Bodega Ave', 'Bodega Bay', 'CA', '94923',
'[email protected]',1985);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1041, 'Johnson', 'Lynda', '117 C Street', 'Washington', 'DC', '20003',
'[email protected]',1969);
INSERT INTO Customers
(CustomerID, LastName, FirstName, Address, City, State, Zip,
Email, DateOfBirth)
VALUES (
1051, 'Wilkens', 'Chris', '87 Highland Drive', 'Olympia', 'WA', '98508',
'[email protected]',1994);
SET IDENTITY_INSERT dbo.CUSTOMER OFF
SET IDENTITY_INSERT dbo.Sets ON
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1000, 'MysterySet1','Planes',$29.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1001, 'MysterySet2','Planes',$19.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1002, 'MysterySet4','Tanks',$39.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1003, 'MysterySet3','Robots',$19.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1004, 'MysterySet5','Cars',$29.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1005, 'MysterySet6','Boats',$29.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1006, 'MysterySet7','Trains',$39.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1007, 'MysterySet8','Motorcycles',$9.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1008, 'MysterySet9','Helicopters',$29.99,10);
INSERT INTO Sets
(SetID, SetName, SetType, Price, Quanity)
VALUES (
1009, 'MysterySet10','Jets',$29.99,10);
SET IDENTITY_INSERT dbo.Sets OFF
SET IDENTITY_INSERT dbo.Orders ON
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1000, '2012-12-12');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1000, '2013-12-30');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1005, '2013-08-30');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1004, '2013-12-30');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1004, '2013-08-31');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1004, '2014-03-25');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1002, '2012-11-14');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1001, '2012-11-14');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1001, '2013-01-05');
INSERT INTO Orders
(OrderID, OrderDate)
VALUES
(1006, '2012-06-22');
SET IDENTITY_INSERT dbo.Orders OFFPrice Numeric (20) NOT NULL,
I do not think you understand this datatype? Go look at the values you are attempting to insert into this column. For example, "$29.99". After the insert, what value is actually stored in that column?
DateOfBirth Numeric (4) NOT NULL,
No. Just No. Either change the column name to faithfully represent what values you intend to store (and apply the appropriate constraints) or change the datatype and the values that you intend to store to match the column name. And the constraint
that you do have:
CONSTRAINT DateOfBirth
CHECK ([DateOfBirth] BETWEEN '1920-01-01' AND getdate() - 5844));
is both logically suspect and syntactically wrong. First, the upper boundary will be computed as 1999-04-29 15:50:21.670. But, of course, your column is a whole number of no more than 4 digits. The same issue applies to your lower boundary.
A simple select statement will show you those errors
select cast('1920-01-01' as numeric(4)), getdate() - 5844, cast(getdate() - 5844 as numeric(4));
An insert statement fails with the same error. Because, of course, your boundary values must actually be converted to numeric(4) in order to compare them against the value contained in the column. Generally, you can convert from
string to numeric - IF the content of the string actually contains a value that is numeric and can be converted into the specific type needed. Not so in this case. Is this 16 year period (5844 days) significant for some reason? You should
document it here in your DDL with a comment, because it is unlikely to be documented (and kept current) anywhere else.
And lastly, your script has:
SET IDENTITY_INSERT dbo.CUSTOMER OFF
That is not the name of your table, and therefore that statement also fails. The table name you used is plural. -
Blank lines inserted at the end of the flat file generated
Hi,
my scenario is idoc to flat file. for each item node in the idoc, one flat file has to be generated. i have used FCC with variable substitution method.
structure is something like this
<TOItem>
<field1>
<field2>
</TOItem>
<FieldNode>
< Filename>
the filename value is used to generate the file name in variable substitution. this field should not appear in the output file. so we have used
Filenode.fieldFixedLengths = 0 and FileNode.fixedLengthTooShortHandling=Cut
with this 2 blank lines are being inserted in the output file.
these lines should not appear in the output file. can anyone guide me how to achive.
Best Regards
DeepikaDo not add this as a separate node. Keep it inside the field strucuture at the end and mentione the length of the field 0. Your problem will be solved.
VJ -
Inserting Blank Line after subtotal in ALV
Hi,
I am using REUSE_ALV_GRID_DISPLAY for my report output and I am displaying the following fields :
Company Code Comp Name Bank Name Amount Data
I am sorting my output based on the company code and displaying the subtotal for each company code.
My requirement is that I need to insert a Blank line after every subtotaled value in the report output. like after the subtotaled value of company code say XXX a blank line should be inserted and then I should start displaying data for company code YYY.
Please let me know if this is possible and if yes how to do that.
In case I am not clear with my question please let me know.
Regards,
Lalit KabraHi,
Following is my code ::
wa_sort-fieldname = 'BUKRS'.
wa_sort-tabname = 'WT_OUTPUT'.
wa_sort-spos = '1'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
wa_sort-fieldname = 'WRBTR'.
wa_sort-tabname = 'WT_OUTPUT'.
wa_sort-spos = '4'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
I have put the wa_sort-Group = 'UL' but could not get the desired results.
What my need is that say for one company code there are five line items, and I need to sort the output by company code then after displaying the 5 line items, I need to display the subtotal of amount for that company code , then a blank line and then the data for the next company code should start.
Please suggest how this can be achieved.
regards,
Lalit -
Insert a blank line between records
Hi,
I am creating a sqlplus report and want to insert a blank line or some seperator to seperate the records between the start and end points of the loop to make it more readable.
ex : The output currently look like this.
ColumnA ColumnB
1 2
2 3
3 1
4 5
5 6
6 4I want the output to look like this
ColumnA ColumnB
1 2
2 3
3 1
4 5
5 6
6 4Thanks for the help in advance!Hi,
You probably work with this table every day, and you probably struggled with this particular query for a while before posting a question, so you're very familiar with the table, the data, and the application.
Perhaps no one else in the world is in that position. Don't assume we know what your data is, or where it came from.
Are you getting the data from a query like this?
SELECT columna
, columnb
FROM table_x
START WITH columna IN (1, 4)
CONNECT BY NOCYCLE columna = PRIOR (columnb)
;If so, that's the kind of thing you should say clearly in your first message, rather than hint at in your third.
As Ow said, you should manufacture a column for use in the BREAK command, and use COLUMN ... NOPRINT if you don't want to see it in the results?
The question here is, what is an appropriate column? CONNECT_BY_ROOT seems to work perfectly for your example
BREAK ON my_break_column SKIP 1
COLUMN my_break_column NOPRINT
SELECT columna
, columnb
, CONNECT_BY_ROOT columna AS my_break_column
FROM table_x
START WITH columna IN (1, 4)
CONNECT BY NOCYCLE columna = PRIOR (columnb)
;The rest of this message is an merely a tangent. I find it interesting, but feel free to skip it.
You might think CONNECT_BY_ISCYCLE was an obvious choice for a BREAK oclumn: you want to skip a line after every output row where CONNECT_BY_ISCYCLE = 1.
Unfortunately, BREAK always works when a column value changes. That is, you can't tell it "Please skip one line after rows where columnz = 1"; all you can say is "Please skip a row before rows where columnz is different than it was on the previous row". (At least that's what I think: I would love it if someone proved me wrong!)
So we have to manufacture some column that keeps its value for an entire loop. The SUM of CONNECT_BY_ISCYCLE (in DESCending order, as returned by the CONNECT BY query) would work. Analytic ORDER BY clauses seem to destroy the order imposed by CONNECT BY, so you'd have to do the CONNECT BY in a sub-query, capture the ROWNUM to preserve the order, and use the analytic SUM function in the main query:
WITH oq AS
SELECT columna
, columnb
, ROWNUM AS r_num
, CONNECT_BY_ISCYCLE AS cycle_val
FROM table_x
START WITH columna IN (1, 4)
CONNECT BY NOCYCLE columna = PRIOR (columnb)
SELECT columna
, columnb
, root
, SUM (cycle_val) OVER (ORDER BY ROWNUM DESC)
-- AS my_break_column
FROM oq
ORDER BY r_num
;The only reason for actually doing this is to learn about CONNECT BY queries. CONNECT_BY_ROOT, as shown above, works much better for your requirements. -
Insert a blank line at the start of a text file
I'd like to insert a blank line at the start of a text file.
I presume SED would be the best to use? Any help on code would be greatly appreciated?Hi David,
That is a little more difficult in sed and awk than it seems like it should be. I'll assume that you know how to handle the redirection and I'll just post the actual sed and awk commands. If you're comfortable with multiline statements in sed it could be done with the following:
sed '1s/./\
Programmatically more complicated but easier to type would be:
sed '1{x;p;g;}'
I think that it's conceptually simpler in awk using the BEGIN address like so:
awk 'BEGIN{ print }//'
You'll probably get other responses using other tools. I'm certainly curious to see what develops.
Gary
~~~~
"And I don't like doing silly things (except on purpose)."
-- Larry Wall in <[email protected]>
Maybe you are looking for
-
What is the best way to host an interactive PDF in a website?
I am making an interactive fashion magazine with DPS and I need it to be put into a website, but haven't found a simple solution yet. I am not very well versed with HTML, so something without too much of that would be good. What type of website would
-
How to combine this query so that i can display the ouput together
I have no idea how to combine this query together.Someone please help.I want the ouput to display oni 1 result combining all together. select facility, route, operation, script_id from F_ROUTEOPER where facility = 'A01' and operation in ('6910','7976
-
Hi, I have entered the values of CVD and Customs duty during Customs MIRO as 100 USD for each line item and saved. When i do MIGO,asked for commercial Invoice number,entered and saved. When i see the FI documents,the each line item value varies from
-
Expert mode query in View objects and appended where clause
My company is Oracle Member Partner and we are developing enterprise web applications using Oracle database and BC4J. I have the following problem... When I enable EXPERT MODE option in View Object I have trouble appending to query statement in my cl
-
Sidebar isn't full length of page
Hi, I have a site that has a right sidebar that is not showing the background color down the same length as the left side of the page. Both the left and right backgrounds should be the same color so I don't think I need to do the trick listed in htt