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 difficult request

Re: A difficult request

From: Ryan <rgaffuri_at_cox.net>
Date: Fri, 17 May 2002 01:33:18 GMT
Message-ID: <y5ZE8.3459$tg.209243@news2.east.cox.net>


yes you can do this, but you need PL/SQL

Create a view and use rownum as one of your columns(you will have to rename it). This will be your counter.

Then right a script. Does not have to be saved in the database. You can use host variables, etc... to make it more user friendly. dont have a sqlplus book in front of me and cant remember my scripting.

declare

v_counter NUMBER := 1;
host_variable

cursor... and record... cant remember you may have to decalre a record type.

begin
loop
select column
from table
where rownum(your counter) = v_counter
v_counter := v_counter + 1
dbms_output... your info
use a host variable to ask the user if they want to go again

exit when host_variable = 'z' or whatever you want to exit

Its something like that. This is fairly common in other languages. Im pretty sure you can do this if you think about it. Id have to put some thought in it.

it would be really easy in a form. you put your v_counter into a global. then use a button so they can reset it.

sorry for the pseudocode... maybe someone else can clean it up.

"Joe Bayer" <u705413818_at_spawnkill.ip-mobilphone.net> wrote in message news:l.1021582008.1213226318@[64.94.198.252]...
> My boss asks me to let user select from a table for only one row each
> time, which is very difficult to achieve
>
> for example
>
> SQL> select * from test;
>
> SCHEMA_NAME SCHEMA_VALUE
> -------------------- --------------------
> A a
> B b
> C c
> D d
> E e
> F f
>
> 6 rows selected.
>
> Each time, we just want user to see one row,
> so I created a view
>
> 1 CREATE OR REPLACE VIEW test_view AS
> 3 SELECT *
> 4 FROM test
> 5* WHERE rownum < 2
> SQL> /
>
> View created.
>
> but I can only select the first row of the table
>
> 1 select * from test_view
> 2* where schema_name='A'
> SQL> /
>
> SCHEMA_NAME SCHEMA_VALUE
> -------------------- --------------------
> A a
>
> 1 select * from test_view
> 2* where schema_name='B'
> SQL> /
>
> no rows selected
>
> can somebody help?
>
> thanks
>
>
>
>
>
>
>
> --
> Sent by joebayerii from hotmail subpart from com
> This is a spam protected message. Please answer with reference header.
> Posted via http://www.usenet-replayer.com/cgi/content/new
Received on Thu May 16 2002 - 20:33:18 CDT

Original text of this message

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