Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Simple SQL statement not working for me please help!

  • 27-11-2008 05:20PM
    #1
    Registered Users, Registered Users 2 Posts: 569 ✭✭✭


    Hi,

    So I prob have a silly mistake here but i'm just learning at the mo.
    I want this to print out in Oracle SQL*Plus and its not working

    set serveroutput on
    DECLARE
    VARIABLE basic_percent NUMBER
    VARIABLE pf_percent NUMBER
    today DATE:=SYSDATE;
    tomorrow today%TYPE;
    begin
    :basic_percent:=45;
    :pf_percent:=12;
    tomorrow:=today +1;
    dbms_output.put_line('hello');
    dbms_output.put_line('Today is :' || today);
    dbms_output.put_line('Tomorrow is :' || tomorrow);
    END;
    /
    PRINT basic_percent
    PRINT pf_percent

    These are the errors
    SP2-0552: Bind variable "PF_PERCENT" not declared.
    SQL> PRINT
    SP2-0568: No bind variables declared.

    I've tried messing around with it a bit but I don't know where to declare these variables!

    Its probably very easy but i just can't get my head around it.

    Thanks alot!


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 5,822 ✭✭✭jd


    Bubba wrote: »
    Hi,

    So I prob have a silly mistake here but i'm just learning at the mo.
    I want this to print out in Oracle SQL*Plus and its not working

    set serveroutput on
    DECLARE
    VARIABLE basic_percent NUMBER
    VARIABLE pf_percent NUMBER

    Semicolons?
    Is there a "variable" keyword?

    DECLARE
    basic_percent NUMBER;
    pf_percent NUMBER;


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭Bubba


    jd wrote: »
    Semicolons?
    Is there a "variable" keyword?

    DECLARE
    basic_percent NUMBER;
    pf_percent NUMBER;

    Yeah i still get the same error with or without the semi colons!

    Really annoying me here!


  • Registered Users, Registered Users 2, Paid Member Posts: 5,822 ✭✭✭jd


    Bubba wrote: »
    Yeah i still get the same error with or without the semi colons!

    Really annoying me here!


    Sorry should have looked - are you trying to run pl/sql from sqlplus !?


  • Registered Users, Registered Users 2 Posts: 569 ✭✭✭Bubba


    jd wrote: »
    Sorry should have looked - you are trying to run pl/sql from sqlplus !

    Its ok I got it :).

    If i put in the variables before the declare it works then!

    Thanks for your help.


  • Registered Users, Registered Users 2 Posts: 525 ✭✭✭mwrf


    [PHP]
    declare
    basic_percent NUMBER;
    pf_percent NUMBER;
    today DATE:=SYSDATE;
    tomorrow today%TYPE;
    begin
    basic_percent:=45;
    pf_percent:=12;
    tomorrow:=today +1;
    dbms_output.put_line('hello');
    dbms_output.put_line('Today is :' || today);
    dbms_output.put_line('Tomorrow is :' || tomorrow);
    END;[/PHP]


  • Advertisement
Advertisement