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: PL/SQL Problem

Re: PL/SQL Problem

From: GDN <gert.deneve_at_advalvas.be>
Date: 10 May 1999 19:41:31 GMT
Message-ID: <01be9b1c$543fa7c0$8311eec3@default>


2. Use the function rtrim/ltrim

3. You don't need to write an exceptions-clause

    It's included in the loopo construction.     when you don't find any records, the loop will not be exectued.

4. Try this

	cursos MyCursor Is
		select sum(something) Mysum  --> You give your sum(...) an alias
		   from Mytable
		   group by MyField;

	For MyRec in MyCursos
	Loop
		dbms_output.put_line(MyRec.Mysum )
	End Loop;

Gert

Sydney <sydney_at_i-france.com> wrote in article <7h74u8$rka$1_at_wanadoo.fr>...
> Hi
>
> I'm a french student, i must create some PL/SQL procedure and function.
I'm
> using SQL Server 8.0 on a UNIX system (HP-UNIX).
>
> 1) I must declare a type before using it as a return variable of a
function.
> Due to the fact this is a function i can't use the declare key word.
> Here is my PL/SQL code
> declare type tcmd is record
> ( tnumtable numtable%TYPE,
> tnumserv numserv%TYPE,
> tnomserv nomserv%TYPE,
> tdatecom DATE,
> tmontant montant%TYPE);
> create or replace function (pnumcom numcom%TYPE) return tcmd as
> rcmd tcmd
> begin
> ...
> end;
> There is an error(Don't like create) . Is there a solution?
>
> 2) Here is a simpla PL/SQL sample.
> create or replace procedure
> l_name char(20);
> begin
> l_name := &name;
> dbms_output.put_line(l_name || ' is a good PL/SQL programmer :)');
> end;
>
> If you enter for example 'my dog', it will write
> my dog(14 blanks) ' is a good PL/SQL programmer ;)
> How to remove the 14 blanks and have this
> my dog is a good PL/SQL programmer :)
>
> 3)Cursor question
>
> create or replace procedure aff_tableservie (pnumserv
serveur.numserv%TYPE,
> pdate DATE) as
> cursor c1 is select numtable from affecte where numserv = pnumserv and
> datejour = pdate;
> begin
> for rec in c1 loop
> dbms_output.put_line('Le serveur ' || pnumserv || 'a servi la table '
||
> rec.numtable || 'le ' ||
> to_char(rec.datejour,'DD/MM/YYYY');
> end loop;
> end;
>
> Is the "for in c1 loop" read all data in the cursor?
> If there is no data in the cursor, where do i put the exception in order
to
> display a message.
>
> 4) Another cursor question
>
> Here is a cursor
> cursor c2 is select sum(montant) from commande where
> to_char(datecom,'MM')=pmois group by to_char(datecom,'DD');
>
> To read the entire cursor
> for rec in c2 loop
> end loop;
> How to access to the sum(montant)?
> Which one is correct(hope there is one ;))
> rec.montant or rec.sum(montant)
>
> Thanks a lot.
> Sydney
>
>
>
>
Received on Mon May 10 1999 - 14:41:31 CDT

Original text of this message

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