Re: What is wrong with the following PL/SQL Block?
From: Rauf Sarwar <rs_arwar_at_hotmail.com>
Date: 28 Jul 2002 15:01:47 -0700
Message-ID: <92eeeff0.0207281401.163407bb_at_posting.google.com>
...
Date: 28 Jul 2002 15:01:47 -0700
Message-ID: <92eeeff0.0207281401.163407bb_at_posting.google.com>
"Andrew Wong" <andrew_at_i-cable.com> wrote in message news:<ahv77r$jbp1_at_rain.i-cable.com>...
> What is wrong with the following PL/SQL Block?
>
>
> DECLARE
> a NUMBER;
> b VARCHAR2(30) DEFAULT 'My String';
> BEGIN
> a:=10;
> a:=SYSDATE+a;
> b:=b+' is not null';
> ...
> DBMS_OUTPUT.PUT_LINE(b);
> ...
> END;
- a is NUMBER and you cannot assign SYSDATE (DATE) to it
- "+" is a math operator in PLSQL. To concatenate a string, use double pipes ||
Here is how you can write your block
DECLARE
a NUMBER;
b VARCHAR2(30) DEFAULT 'My String';
c DATE;
BEGIN
a := 10;
c := SYSDATE + a;
b := b || ' is not null';
...
DBMS_OUTPUT.PUT_LINE(b);
...
END;
HTH
//Rauf Sarwar
Received on Mon Jul 29 2002 - 00:01:47 CEST
