Trigger or sql statments to trim spaces??
Dears,
I am receiving some data in some kind of stagging tables with some columns having extra spaces ... so is it faster and / or better to create a trigger on those tables to trim those spaces before insert or shall i trim when retrieving data from those tables?? note that this data will not be retrieved more than two times as its part of migration process.
Thanks in advance,
Swaid McKey
How did you perform the import? imp <username>/<password>@<ORACLE_SID> fromuser=<srcusername> touser=<destusername> file=<dumpfilename> tables='<tablename>' log=<logfilename> BUFFER=2048000 RECORDLENGTH=64000
Where did the source dump file come from? if i got u right from informix dynamic server (src) to oracle 9i (intermediate) then to oracle 9i (stagging)
How did you "processing and moving data to final destination"? with pl/sql procedures selecting from stagging inserting into dist with updates in the middle.
How did you "updating the the table by trimming the> column"? update emp
set name=rtrim(name);
How many tables are we talking about? 13 table
How many columns need to be trimmed? 1 to 2 columns per table
How many rows are there? as i said before 11million
How did you take these timings?using shell script, i record the time before & after.
How did you write hte migration?cursor --> open --> loop --> fetch --> inserts --> updates --> end loop
Why are you going via a dump file to do the migration?because of the agreement with the other party
Why are you using staging tables? Are you performing other transforms on the staging tables?i only query from them but i do transform the data before inserting in the destination
Where are the spaces? leading or trailing? or both?trailing
what are the data types?VARCHAR2 (20)
Are there object types involved?no
Do the target tables already have triggers on them for other reasons?no
Similar Messages
-
How to access currently executing SQL statment?
Hello -
I have a C language external procedure that is called from an INSERT / UPDATE / DELETE trigger.
Is there a way (using OCI, or elsewhere) to get a string containing the SQL statment that fired the trigger?
Thanks a bunch for your help!
-jshttp://databasejournal.com/features/oracle/article.php/3373701
The second page has more details (there is also a part II to this article if you are interested). -
Forms 10gR2 does not trim spaces
Hi,
we are planning to migrate to 10g from 6i. as far as i know forms always trims trailing spaces. so when we are inserting space to a table it inserts null.
but at 10gR2 it does not trims spaces and inserts non-null value.
Am i missing something or is it really changed?
Regards. Engin.I had fogotten about that bug. But it still exists, even in Forms 6i, patch 17 (6.0.8.26.0)
I ran this test:
Declare
v1 varchar2(4);
v2 varchar2(4);
v3 varchar2(4);
Begin
v1 := ' '; -- one space
select nvl(v1,'X'), v1 into v2, v3 from dual;
message
('V2=' || v2 || ', Length(V2) = ' || nvl(Length(v2),0) );
message
('V3=' || v3 || ', Length(V3) = ' || nvl(Length(v3),0) );
End;And I get the following messages:
V2=X, Length(V2) = 1
V3=, Length(V3) = 0Run under SQL Plus, changing Message to DBMS_Output.Put_Line:
V2= , Length(V2) = 1
V3= , Length(V3) = 1I get the correct result, the same as SQL Plus, in Forms 10.1.2.0.2. -
this SQL statment work in oracle database :
SELECT TO_DATE('20080627','YYYYMMDD') - TO_DATE('20080526','YYYYMMDD') FROM dual
But didn'twork on Timesten Database and this error is appear
2789: An interval data type must be specified for a datetime arithmetic result
The command failed.SELECT extract (day from TO_DATE('20080627','YYYYMMDD') - TO_DATE('20080626','YYYYMMDD')) FROM dual;
See
http://download.oracle.com/otn_hosted_doc/timesten/703/TimesTenDocumentation/wwhelp/wwhimpl/js/html/wwhelp.htm?&accessible=true
for details. -
Problem with DBMS_OUTPUT and SQL statment with a function
I am using SQL Developer version 3.0.04 and I have a function that has a dbms_output statment in it. I am running the following SQL to select the output of that statment.
select A.A_FUCTION('TEST') from dual;
The output works fine but the dbms_output line does not show in the dbms_output window. I turned on the output window etc. and i can get the select to print out the output if i wrap it in a declare begin end wrapper... and then change the query to insert the return value into variable.
just wondering if there is way to get the dbms_output to flush out with just an SQL statment instead of in a begin end wrapper etc.just wondering if there is way to get the dbms_output to flush out with just an SQL statment instead of in a begin end wrapper etc.works fine in sql*plus, so I guess it must be a preference or sth. in sql*developer:
SQL> set serverout on
SQL> create or replace function f1 (r int)
2 return int
3 as
4 begin
5 dbms_output.put_line ('Hello World ' || r);
6 return r;
7 end f1;
8 /
Function created.
SQL>
SQL> select f1 (rownum) f1 from dual connect by level <= 3
2 /
F1
1
2
3
3 rows selected.
Hello World 1
Hello World 2
Hello World 3
SQL> -
Create Fiat File Using Trigger in SQL Server
Dear All,
How to Create a Flat File using Trigger in SQL Server?Take a look at osql/sqlcmd, bcp, COM calls, xp_cmdshell, etc. Here are a few links with code examples:
https://www.simple-talk.com/sql/t-sql-programming/reading-and-writing-files-in-sql-server-using-t-sql/
http://www.nigelrivett.net/SQLTsql/WriteTextFile.html
http://stackoverflow.com/questions/8132663/creating-a-text-file-on-local-machine-using-sql-server-2008
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to find top 10 SQL statments which are consuming more cpu time.
hi all,
Is there any command or script to monitor the top 10 sql statments which are consuming more cpu time.
I know by using AWR REPORT we can find it, i want the command or script to find the top cpu utilization sql statments.
Regards
Subhash.Subhash,
A quick and dirty Google search could have get you started with the following:
Thread: how to get top CPU consuming sql oracle 10g
Re: how to get top CPU consuming sql oracle 10g
Oracle SQL top sessions
http://www.dba-oracle.com/oracle10g_tuning/t_sql_top_sessions.htm
"How to Find top 10 expensive sql's", version 9.2.0
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:73325450402303
HTH,
Thierry -
How to create conditional update trigger in sql server
How to create conditional update trigger in sql server
You cant create a conditional update trigger. Once you create an update trigger it will get called for every update action. However you could write logic inside it to make it do your activity based on your condition using IF condition statement
Say for example if you've table with 6 columns and you want some logic to be implemented on update trigger only if col3 and col5 are participating in update operation you can write trigger like this
CREATE TRIGGER Trg_TableName_Upd
ON TableName
FOR UPDATE
AS
BEGIN
IF UPDATE(Col3) OR UPDATE (Col5)
BEGIN
....your actual logic here
END
END
UPDATE() function will check if column was involved in update operation and returns a boolean result
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to trim spaces from string in BMM layer?
Hi friends,
I need to trim spaces from the string. can you please give me syntax with example.
ThanksHi
I have tried the below option , but it did not work . PS_D_PERSON
PERSON_ID is char type in the data base oracle , and it is defined as varchar on the physical layer .
So the table is loaded with space , i am not able to remove the space using trim both
Thanks
Sridhar.N -
Newbee Question to SQL Statment ..
Hello,
what does the statment PRODWH refer to in the statment below ....?
what s the function of {?PRODWH: F_INVOICES.PROD_ID}. Is it an Input Parameter for the user ?
ist the statment "external Join" replaceble trough Right/left Join ..?
SQL Statment-------------------
PRODWH
SELECT
"D_PROD_DESC"."PRODUCT_DESC_SHORT",
"D_PROD"."SKU", "D_PRODUCT"."BU_DEPARTMENT",
"D_PROD"."PROD_ID"
FROM
"D_PROD_DESC" "D_PROD_DESC" INNER JOIN
"D_PROD" "D_PROD" ON
"D_PROD_DESC"."PROD_ID"="D_PROD"."PROD_ID"
EXTERNAL JOIN D_PROD.BU_DEPARTMENT={?PRODWH: Command.BU_DEPARTMENT} AND
D_PROD.PROD_ID={?PRODWH: F_INVOICES.PROD_ID} AND
D_PROD.SKU={?PRODWH: D_OLD_CUST.BU_SKU}
-----END----------------The Database is Oracle but the SQL statment is generated by Crystal Reports XI
-
hiya
i need help about SQL statment i want get all employee Data if i know the emp_no get specify recored if emp_no = null get all Data
select * from employe where emp_no=123 if emp_no=null get all records
thxHi,
Welcome to the forum!
Ttushar's solution is what you requested.
If empno can not be NULL, then you can also modify it like this:
SELECT *
FROM employee
WHERE emp_no = NVL (:v_emp_no, emp_no); -
Hello All,
I need to trim space from beginning and end of a string.
For example -
astring = ' hello123 '.
I need to get astring as 'hello123'.
Thanks in advance.
VirenHi Viren,
You can code like this
WRITE ASTRING TO ASTRING NO-GAP.
Hope this will help.
Regards,
Ferry Lianto -
Embeded SQL Statment VS Store procedure
On J2ee tecknology, what is the better method of usind data services.
raping all sql statment in the store procedure or embeded all sql statment in EJB.
thanks
nullHi,
This issue looks similar to the the issue described in:
Re: Exception in reader for ODP.NET 11.1.0.6.2 same work fine in older version
Note that Bug 9792727 was filed to track the issue described in the above link.
Regards,
-Naveen -
Hi all,
I have a table which contain project details those are the coulmns:
Project_number (PK)
Submit Date
Project_title
Project_milestones
I want to retrieve how many number of project in each mounth per year
Output Example:
Date Number of projects
FEB 2008 *6*
March 2008 *5*
FEB 2009 *4*
March 2009 *7*
And so on, I tryed to write an sql statment to retrieve the desired results but I couldn't.
If any one has any idea in retrieving such result please assist me how to write this sql statment.Hi,
If submit_date is a DATE, then TRUNC (submit_date, 'MM') is the beginning of the month that countains it.
So you can say:
SELECT TRUNC (submit_date, 'MM') AS month
, COUNT (*) AS cnt
FROM project_table
GROUP BY TRUNC (submit_date, 'MM');Of course, you can add TO_CHAR to the first line to format the date however you like. -
Tip in create trigger thru SQL Developer 1.5
I try to create trigger in SQL Developer, which simply delete all the related rows in other tables, the trigger is as below:
create or replace trigger delregion
after delete on regions
for each row
begin
delete from countries where region_id=:old.region_id;
end delregion;
when I test it and it throws the following error:
delete from hr.regions where region_id = 4;
ORA-04098: trigger 'HR.DELREGION' is invalid and failed re-validation.......
However, I try exactly the same trigger in the SQLPLUS command console, it works just fine.
Finally, I found out I should click the "Run Script" button instead of the "Execute Statement" button..... :-)
Edited by: user7253132 on Oct 26, 2009 3:47 PM
Edited by: user7253132 on Oct 26, 2009 3:49 PMSo it's working now? Then mark the question as answered...
K.
Maybe you are looking for
-
Hi there, I'm using Siena on a couple of machines: a desktop PC with Win8.1 and an 8" tablet running Win8.1. On the tablet but not on the desktop, I receive the above error whenever I try to add an image, audio or video visual and then Add Media to
-
My index page and services page specifically for the English version of my website looks broken and I can't figure out why. I created this using Adobe Muse. I'm not the best in navigating the back-end/coding part of the website but I'm afraid it may
-
Hi. Im new to Flash and im looking for a place i can learn to make a short cartoon with a step by step tutorial. It doesnt matter what the story is, it could be about a snail and his friend or something. Im not yet comfortable doing cartoons on flash
-
Modifying Existing Web Gallery
How to I add or delete images from a web gallery which I have already published using the web module?
-
part1 CREATE OR REPLACE TYPE ALL_DEV.OBJECT_ROW_TYPE AS OBJECT ( CNT NUMBER CREATE OR REPLACE TYPE ALL_DEV.REF_TYPE AS TABLE OF object_row_type CREATE OR REPLACE FUNCTION ALL_DEV.ref_return RETURN ref_type AS v_tab ref_type := ref_type(); BEGIN FOR c