Saturday, December 31, 2005

How to SELECT specific ROWS from a TABLE

Thats a tricky thing to do.At first do select with an extra row as rownum.And do another select based on this select using where to specify specific rows.I think an example can elaborate this.

table A:
----------
name roll_no
----- -------
hasim 02MCA07
mamnoon 03MCA45
matin 02MCA50
anwar 02MCA09
gafur 03MCA56

SELECT name FROM (SELECT name,ROWNUM n FROM A) WHERE n BETWEEN 2 AND 4
This query will fetch:

mamnoon
matin
anwar

Labels:

Monday, December 12, 2005

How to Unix:To Send An Attachment From Unix

I posted once how to send mail from unix.Anyway that can not be called a post as it merely described things.It was just an information.Today i felt a need to send an attachment.But its not as easy as sending mail as text only.
Becuase if we try to send a small midi or wav file by doing a simple mailx like follow,it may not work.
$ mailx -s "Warning!! May not reach as it is!!" rakib004@yahoo.com < BritneySpears.mid

Because while delivery from one mail agent to other,they will strip off or add bytes as per their standards.SO how to do this then?

For that u need to encode before sending.And then send it.
$ uuencode BritneySpears.mid codedBritneySpears.mid| mailx -s "ATTACHMENT" rakib004@yahoo.com
And if you want to tell him wats the attachment is in text,then:
$ (cat MailBody.txt; uuencode BritneySpears.mid codedBritneySpears.mid)| mailx -s "ATTACHMENT_WITH_BODY" rakib004@yahoo.com

What uuencode do:
(From Unix MAN Page)
uuencode takes the named source file (default standard input) and
produces an encoded version on the standard output. The encoding uses
only printing ASCII characters, includes the original mode of the
input file, and preserves the value of the remotedest argument which
is the intended name for the file when it is restored later on the
remote system.

FROM ORAFAQ:
(Good Script )

http://www.orafaq.com/scripts/unix/sendmail.txt
http://www.orafaq.com/scripts/unix/mailx.txt
LINK TO MY OTHER POST:
http://mahasim.blogspot.com/2005/05/how-to-send-mail-from-unix.html

Sometimes your mail may not be able to decode the file sent to you using uuencode and mailx.

In that case you may follow the following command:-
$ sendmail m.a.hasim@gmail.com<> `cat hasim.txt`
> `uuencode hasim.txt hasim.txt`
> END

Labels:

Thursday, December 01, 2005

SQL LOADER --Commonly Asked Questions And Answers

I use the Oracle`s SQLLDR utility usually.I faced many problems.I solved them finding solution from my teammates and other

places.I also feel many points to be noted down.So all the question here are on SQLLDR.Hope this post length will increase

further later.


Q1> Can we upload data to some remote machine db?
Ans. Yes.U just need to supply the appropriate dblink.
like as
c:\>sqlldr /@dblink control= data=

Q2>So wats the difference between sqlldr and ftp as both can load files to some remote machine?
Ans.Its an absurd question.Bcz ftp just upload a file.But sql loader inserts it into table not upload the file.and sql loader

can do much which we will discuss later on.

Q3>can u give a simple format for sqlloader control file?
Ans. Control file is the heart of the whole loading process.

example1.

Load data -- command
infile * -- to which table
replace -- replace the prev records
fields TERMINATED BY '|' -- Fields in the input file are separated by pipe
OPTIONALLY ENCLOSED BY '"'
-- if fields are optionally enclosed by double quote
TRAILING NULLCOLS --use this if u expect any column to be null
(
column_name_where_1st_data_2b_loaded,
column_name_where_2nd_data_2b_loaded, --here all are the actual column names in the target table.
column_name_where_3rd_data_2b_loaded,
column_name_where_4th_data_2b_loaded
)

Q4> What trainling nullcols do actually?Ans. It justs load a NULL if any data is missing.

Q5>How much faster is ftp than sqlloader?

Labels: