Geeks Talk

Prepare for your Next Interview




vertical printing

This is a discussion on vertical printing within the SQL forums, part of the Databases category; select substr('geek interview',rownum,1) from user_objects where rownum can u explain the word by word meaning. substr('geek interview',rownum,1)----here rownum value is?-------------------- trim(geek interview )...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-06-2008
Banned
 
Join Date: Feb 2008
Location: bangalore
Posts: 32
Thanks: 9
Thanked 2 Times in 2 Posts
jayanth511 is on a distinguished road
vertical printing

select substr('geek interview',rownum,1) from user_objects where rownum<=length(trim('geek interview));




can u explain the word by word meaning.




substr('geek interview',rownum,1)----here rownum value is?--------------------


trim(geek interview )gives-----------?


total query gives what
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-06-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: vertical printing

Dear Jayanth,

Trim removes trailing and leading blank spaces.
legth return the length of a string.
substr(src,p,l) :- Retruns a portion of src starting at position p and l caharacters long.
I already given explanation to rownum and rowid for your last posting.

All these are simple functions for which you can find explanation in any text book or reference material.

If you find it difficult to understand entire query at a time split it into small queries, execute each query seperately as follows and see the result.


select trim('geek interview') from dual;
select length(trim('geek interview')) from daul;
select substr('geek interview',2,1) from dual;

Then it will become easy for you to understand the output of following query.

select substr('geek interview',rownum,1) from user_objects where rownum<=length(trim('geek interview'));

Execute the above queries and find the output yourself .

Regards
Krishna
Reply With Quote
  #3 (permalink)  
Old 03-06-2008
Banned
 
Join Date: Feb 2008
Location: bangalore
Posts: 32
Thanks: 9
Thanked 2 Times in 2 Posts
jayanth511 is on a distinguished road
Re: vertical printing

substr('geek interview',rownum,1) what itgives.


ex.
substr('jayanth',3,4);her 2nd parametr is 3.
gives' yant' right.

but in substr('geek interview',rownum,1) 2nd parametr rownum value is


dont mine i did not understand the concept of rowid, row num .can u give detail exmple for that
Reply With Quote
  #4 (permalink)  
Old 03-06-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: vertical printing

Dear Jayanth,

For each row returned by a query, the ROWNUM returns a number indicating the order in which Oracle selects the row from a table . The first row selected has a ROWNUM of 1, the second has 2, and so on.


For example let us suppose there are fourteen records in EMP table and you want to display first ten records from the table then you may use the following command.

Select * from emp where rownum <=10;

In this query
select substr('geek interview',rownum,1) from user_objects where rownum<=length(trim('geek interview));

Length(trim('geek interview')) returns value 14.

So it becomes becomes
select substr('geek interview',rownum,1) from user_objects where rownum<= 14;

The above query returns 14 rows.

For the first row rownum is 1
Substr('geek interview', 1, 1) retruns G.
For the second row rownum is 2
Substr('geek interview', 2, 1) retruns E and So on.

I hope now it is clear to you.

Regards
Krishna
Reply With Quote
The Following User Says Thank You to krishnaindia2007 For This Useful Post:
  #5 (permalink)  
Old 03-06-2008
Banned
 
Join Date: Feb 2008
Location: bangalore
Posts: 32
Thanks: 9
Thanked 2 Times in 2 Posts
jayanth511 is on a distinguished road
Re: vertical printing

thanks a lot

but user_objects means in that query
Reply With Quote
  #6 (permalink)  
Old 03-06-2008
Banned
 
Join Date: Feb 2008
Location: bangalore
Posts: 32
Thanks: 9
Thanked 2 Times in 2 Posts
jayanth511 is on a distinguished road
Re: vertical printing

Trim removes trailing and leading blank spaces.what it means
Length(trim('geek interview')) gives ---------------
length('geek interview') gives what
Reply With Quote
  #7 (permalink)  
Old 03-07-2008
Expert Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 447
Thanks: 20
Thanked 54 Times in 54 Posts
susarlasireesha is on a distinguished road
Re: vertical printing

Quote:
Originally Posted by jayanth511 View Post
thanks a lot

but user_objects means in that query
USER_OBJECTS describes all objects owned by the current user
objects are tables,views,tiggers,packages,sequences,procedures,functions
Reply With Quote
The Following User Says Thank You to susarlasireesha For This Useful Post:
  #8 (permalink)  
Old 03-07-2008
Expert Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 447
Thanks: 20
Thanked 54 Times in 54 Posts
susarlasireesha is on a distinguished road
Re: vertical printing

Quote:
Originally Posted by jayanth511 View Post
Trim removes trailing and leading blank spaces.what it means
Length(trim('geek interview')) gives ---------------
length('geek interview') gives what
the trim function removes all specified characters either from the beginning or the ending of a string

from this example u can find the difference of Length(trim('geek interview'))

select Length(trim('geek interview')) from dual returns 14

select length('geek interview') from dual; returns 14

but if i give space in beginning of geek interview then

select Length(trim(' geek interview')) from dual returns 14

but select Length(' geek interview') from dual return 15
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Print management system that gives you control over all of your printing resources, p JobHelper Geeks Lounge 0 01-03-2008 11:50 AM
How can we use thermal printer for bar code printing Geek_Guest Oracle 1 07-17-2007 08:30 AM


All times are GMT -4. The time now is 09:29 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved