Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: A few simple Oracle questions

Re: A few simple Oracle questions

From: <mpir_at_compuserve.com>
Date: 1998/04/03
Message-ID: <6g3hsj$ki0$1@nnrp1.dejanews.com>#1/1

In article <352345a9.1426163_at_192.168.0.1>,   rwillems_at_xs4all.nl wrote:
>
> On Wed, 01 Apr 1998 22:22:38 -0800, "Mark W. Eaton" <eaton_at_best.com>
> wrote:
>
> >Our organization is relatively new to Oracle but fairly seasoned with SQL Server
> >development. We have a few questions we need to understand to make the
> >transition as quickly as possible. Please respond directly via email as I do
> >not read this newsgroup regularly,
> >
> >Sincerely,
> >Mark Eaton
> >eaton_at_best.com
> >
> >-----------------------------------------------------------------------
> >SQL*Plus related
> >--------------------------
> >How do I tell the Server to return only a fixed number of rows in response to a
> >query.
> >In isql (Sybase) I would say
> >set rowcount 10
> >select fld1 from table1 where fld2 > 100
> >This would return the first 10 rows that fulfilled the condition.
> >How do I achieve the same in SQL*Plus. There does not seem any
> >environment variable that I can set.
>
> Try this:
>
> select fld1 from table1 where fld2 > 100 AND ROWNUM < 11;
>
> SQL Reference:
>
> ROWNUM
>
> For each row returned by a query, the ROWNUM pseudocolumn returns a
> number indicating the order in which Oracle7 selects the row from a
> table or set of joined rows. The first row selected has a ROWNUM of 1,
> the second has 2, and so on.
>
> You can use ROWNUM to limit the number of rows returned by a query, as
> in this example:
>
> SELECT *
> FROM emp
> WHERE ROWNUM < 10
>
> >------------------------------------------------------------------------
> >OCI related
> >-----------------
> >OCIStmntExecute( ) returns the status of executing a SQL command.
> >Is there a call to find the number of result rows before doing a fetch ?
> >( equivalent to a Sybase DBCOUNT () ) which would facilitate doing a
> >single memory allocation for storing the results
> >------------------------------------------------------------------------
> >Oracle Database Server - Datatypes related
> >--------------------------------------------------------------
> >User defined types in Oracle refer to composite fields.
> >In Sybase they are more like typedefs in C/C++
> >e.g I would define a user defined type ut_zip as char(6)
> >This way whenever I had addresses the zip field would be of type ut_zip.
> >This facilitated a single point of change to the zip fields and also
> >maintenance / searching the database for zip fields.
> >How can I achieve the same in Oracle ?
> >------------------------------------------------------------------------
>
> -----
> Real programmers don't comment their code.
> It was hard to write, it should be hard to understand.
> -----
> Richard Willemsen
> http://www.xs4all.nl/~rwillems/
>

For DBCOUNT() try 'Select Count(*) from table where qualified;'

As for the field typedefs, it is possible under Oracle 8. Not as clean as C, but doable.

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Fri Apr 03 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US