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

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL Problem

PL/SQL Problem

From: Sydney <sydney_at_i-france.com>
Date: Mon, 10 May 1999 18:47:10 +0200
Message-ID: <7h74uf$rka$2@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 - 11:47:10 CDT

Original text of this message

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