Re: Need some guidance

From: Kenneth Ho <kenho_at_hk.super.net>
Date: Tue, 23 Aug 1994 11:13:10 GMT
Message-ID: <kenho.22.2E59D9C6_at_hk.super.net>


In article <33atfl$ng5_at_sbctri.sbc.com> Brenda Thompson <bthompson_at_sbctri.sbc.com> writes:
>Path: hk.super.net!news.ust.hk!hpg30a.csc.cuhk.hk!news.hk.net!howland.reston.ans.net!wupost!trinews.sbc.com!mac-bthompson.tri.sbc.com!bthompson
>From: Brenda Thompson <bthompson_at_sbctri.sbc.com>
>Newsgroups: comp.databases.oracle
>Subject: Need some guidance
>Date: 22 Aug 1994 19:15:01 GMT
>Organization: Technology Resources, Inc.
>Lines: 23
>Distribution: world
>Message-ID: <33atfl$ng5_at_sbctri.sbc.com>
>NNTP-Posting-Host: mac-bthompson.sbc.com
>X-UserAgent: Version 1.1.3
>X-XXMessage-ID: <AA7E65841B01163E_at_mac-bthompson.tri.sbc.com>
>X-XXDate: Mon, 22 Aug 94 20:24:04 GMT

>I'm new at working with Oracle, and need some advice.
 

>I need to get fields out of my database, perform some comparisions,
>re-set the values if they meet certain conditions, then print the fields.
 

>When I use the BEGIN-END, nothing happens - I get no results:
>BEGIN
>SELECT x, y, z FROM table WHERE x = j;
>IF y = 5 THEN
> y := 15;
>ELSEIF y = 6 THEN
> y := 16;
>ELSE y := 20;
>ENDIF;
>END;
Assume you are using PL/SQL, your code should look something like this:

DECLARE

   v_x  table.x%type;
   v_y  table.y%type;
   v_z  table.z%type;

BEGIN
  SELECT x, y, z INTO v_x, v_y, v_z WHERE x = j;   IF v_y = 5 THEN...
END;
>If I take off the BEGIN-END, I get the results of the SELECT FROM WHERE
>statement only. The IF statements are not recognized.
 

>What am I doing wrong? Thanks.
 

>Brenda T.
>bthompson_at_sbctri.sbc.com

Hope this help.

Kenneth Ho
Programmer
Hospitality Data Resources Ltd., H.K. Received on Tue Aug 23 1994 - 13:13:10 CEST

Original text of this message