显示标签为“record”的博文。显示所有博文
显示标签为“record”的博文。显示所有博文

2012年3月26日星期一

Flat File Source with Ragged Right Problems

For some reason, when I try to use the Flat File Source and set the record type to Ragged Right it does not seem to recognize 'short' records. It seems to be confused by the CRLF set delimiters and not recognize these in 'some' records. The input does not seem consistent. What am I missing?

SSIS parses column by column, not rows then columns. There are a fair number of posts on this. Basically the work around today is to bring in each row as a single string column, then parse it into indiviudal columns in the package.

Example here: http://agilebi.com/cs/blogs/jwelch/archive/2007/05/08/handling-flat-files-with-varying-numbers-of-columns.aspx

Flat File source to Oracle OLE DB Target (ETL)

What could be simpler: map a flat file record structure, extract the data, and populate essentially the same flat file record struc in an Oracle table. Let the fun begin.

Specifically: the flat file record struc is fixed length 196 bytes. A particular field consists of 4 bytes of Integer data; IS deals very nicely with the definition, does not appear to be any issue with that. The issue is trying to get the 4 bytes of integer to map and load into the Oracle table. The data type in the flat file def is DT_UI4. The data type in the Oracle target is DT_NUMERIC. One would think that perhaps a simple transform and Viola?! I've defined the transform but does not seem to matter - whatever I try yeilds the same results.

I 've tried many different src/trg data type defs., but all yeild the same results.

Execution Results from debug:

Everything validates and then...

[kcd [8671]] Error: Data conversion failed. The data conversion for column "load_time_min" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".

[kcd [8671]] Error: The "output column "load_time_min" (11050)" failed because error code 0xC0209084 occurred, and the error row disposition on "output column "load_time_min" (11050)" specifies failure on error. An error occurred on the specified object of the specified component.

Any ideas appreciated!

Thanks.

What precision and scale are you specifying for the DT_Numeric? Since the Integer column is defined as an unsigned integer, you need to allow enough room in the numeric to support it. Or you could use a derived column transform to explicity cast the integer to the numeric, if you know there will not be an overflow.

(DT_NUMERIC, 10, 0) [Your_Column]

2012年3月21日星期三

Flag Random Record

I am using this select statement to radomly display a record

SelectCommand="SELECT TOP 1 * FROM [TBL_Example] ORDER BY NEWID()

I need to, however, flag this record, to determine if it has already been previously randomly selected, and won't take part in future random selections.

I will need to add a where clause to the above, but what I am unsure of is what I should do for the insert statement. I guess I could figure this out on my own as well if I could determine a means to prgramatically store my PK from the above record in session.

Any ideas?I probably need a statement like this in my code behind:

Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
SqlDataSource1.UpdateParameters("Flag").DefaultValue = "True"
End Sub

and then I probably need some insert parameters, here is what I am working with right now with my sqldatasource

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT TOP 1 * FROM [CIT_ContactInfo] ORDER BY NEWID()"
updatecommand="update [CIT_ContactInfo] set [Flag] = @.Flag where [UserName] = @.UserName">
<UpdateParameters>
<asp:Parameter Name="Flag" Type="boolean" />
</UpdateParameters>
</asp:SqlDataSource
Does any of this look remotely correct?

Flag a record

Given the following record set, how can I "Flag" the first payment record
(Typecode = 'P') so that it has satisfied the "Fire_Fee_Recvd"
In other words when a payment comes in, the billed fire fee amount is to be
applied first (first in,first out) and when subsequent payments come in, I d
o
not want to subtract the amount of the fire fee from the premium recvd
Policy BilledPrem BilledFireFee Pymt Typecode (PremRecvd)
(FFRecvd)
bp 001 2292 22.05 B
0 22.05
bp 001 500 P
477.95 22.05
bp 001 367.77 P
345.72 22.05
The last row needs to read Prem Recvd = 367.77 and FFRecvd = 0
My current logic is
PremRecvd = Pymt - FFRecvd
How can I flag that first pymt record as True for satisfying the fire fee so
that the next record will not subtract if from the pymt?
Thanks!Hi Patrice,
You table is little bit confusing for me ..if you want to flag a field (with
true or false)
you can try like this
-- create a new column 'flag filed'
-- write a trigger with your business requied logic[trigger can be insert or
update based on ur requirement] and to display true or false in newly
inserted Flag column based on the logic .
I dont know how far it is true ..iam also curious to know abt this.
hope this will help you
Kumar
So that ,it will check automatically when you insert or update new columns
"Patrice" wrote:

> Given the following record set, how can I "Flag" the first payment record
> (Typecode = 'P') so that it has satisfied the "Fire_Fee_Recvd"
> In other words when a payment comes in, the billed fire fee amount is to b
e
> applied first (first in,first out) and when subsequent payments come in, I
do
> not want to subtract the amount of the fire fee from the premium recvd
> Policy BilledPrem BilledFireFee Pymt Typecode (PremRecvd)
> (FFRecvd)
> bp 001 2292 22.05 B
> 0 22.05
> bp 001 500 P
> 477.95 22.05
> bp 001 367.77 P
> 345.72 22.05
> The last row needs to read Prem Recvd = 367.77 and FFRecvd = 0
> My current logic is
> PremRecvd = Pymt - FFRecvd
> How can I flag that first pymt record as True for satisfying the fire fee
so
> that the next record will not subtract if from the pymt?
>
> Thanks!

2012年3月9日星期五

Fix legacy data - Missing primary key + duplication record + large table

We have a large table which is very old and not much ppl take care about, recently there is a performance problem from the report need to query to this table. Eventally we find that this table have primary key missing and there is duplicate data which make "alter table add primary key" don't work

Besides the data size of this table require unacceptable time to execute something like "insert into new_table_with_pk from select distinct * from old table"

Do you have any recommendation of fixing this? As the application run on oracle , sybase and sql server, is that cross database approace will work?How big is ur table?.have u tried to create non clustered index on the field(s) of the tables which ur report using in filter condition.U have to do this modification when ur database have less load.|||How big is ur table?.have u tried to create non clustered index on the field(s) of the tables which ur report using in filter condition.U have to do this modification when ur database have less load.

It is about 2 millions rows. We haven't create non clustered index as we like to remove duplication and create primary key. So you mean first create index then do [insert into new_table from select distinct * from old_table]?|||first of all 2m records is not that big.distinct keyword is the killer here,it will affect the perfomance of ur query
Some options are,

change ur database option to 'true' for 'select into/bulkcopy' before u doing select * into.

exec sp_dboption 'urdatabase','select into/bulkcopy',true

this will improve the perfomance of the query 'select into' .

u should try checksum function in sql to remove duplicate.
before that add new column in exist table with identity,primary key

alter table urtable add [id] int identity(1,1)
CONSTRAINT id_pk PRIMARY KEY

-- select checksumvalues
eg:count duplicate in city,state,zip,contract in authors table.And delete duplicates

use pubs
go
delete authors from (
select max(au_id) as au_id,checksumvalue from
(
select au_id,au_lname,checksum(city,state,zip,contract) as checksumvalue from authors
) as t group by checksumvalue
having count(*)>1
) as t1 where authors.au_id=t1.au_id and authors.au_lname=t1.au_lname
--Note u should compare atleast one column from duplicate columns in where --clause(because checksum functiont is not 100% acuurate) as u can see , I --used 'au_lname' field in the above query

Same way u should compare with ur new [id] column which u created.



finally u have to build index on that table for better perfomance.

come back to me,if have doubts on how to remove duplicates using checksum function. try to put tables DDL also.


NB: dont forgot change back database option to,

exec sp_dboption 'urdatabase','select into/bulkcopy',false

after finish this job.

2012年2月26日星期日

First Occurence of the record

Can any one let me know as how can I query the first occurence of a record. I need to select all distinct Order Types from a table. If there is more than one record with the same Order Type, then I need to get the first record.
It would be a great help to me.
Thanks,
JohnHow do you determine which one is the first record ?|||I mean any randon first record. I used min (rowid) but it did not work.

Please help me out.

John|||Did you try to use Top 1 * with Order By RowID (a primary key)|||john, what's the primary key of this table?

2012年2月24日星期五

First & last record retrieve

Is there a simple SQL statement to get the
last and first record of a table under
Access and SQL Server ?
Thanks,
Pierre.Tables have no concept of "first" and "last". You need to create a column by which you can order the data. Then you can do something like:

SELECT * FROM t WHERE col IN (SELECT MIN(col) FROM t
UNION SELECT MAX(col) FROM t);

2012年2月19日星期日

firehose

Good day to all

How could I dis-able the read-only in a table when it generate an error message "Firehose mode"?, when I delete a record or a group of records?. What is that mean?

Thank you for any help

Madix

Hi Madix,

Could you let me know the exact error message you're getting, which product/language/API you are using and what you do that causes the error please.

Thanks,

Chris

|||Hi,
guess your problem is related to:
http://support.microsoft.com/kb/286199/en-us
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q237398&
HTH, Jens Suessmeyer.

firehose

Good day to all

How could I dis-able the read-only in a table when it generate an error message "Firehose mode"?, when I delete a record or a group of records?. What is that mean?

Thank you for any help

Madix

Hi Madix,

Could you let me know the exact error message you're getting, which product/language/API you are using and what you do that causes the error please.

Thanks,

Chris

|||Hi,
guess your problem is related to:
http://support.microsoft.com/kb/286199/en-us
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q237398&
HTH, Jens Suessmeyer.