Results 1 to 4 of 4

Thread: err in PL/SQL

  1. #1
    Join Date
    Mar 2004
    Posts
    50

    Arrow Unanswered: err in PL/SQL

    Hi
    I am running following piece of code in PL/SQL and getting an error.
    I am using oracle 8.1.7



    BEGIN
    dbms_output.put_line ( PK_EXCHANGE_RATE.FN_CURR_CONV((SELECT SUM(NET_EARNING_ASSET)
    FROM INVESTMENT_DETAIL_HISTORY@ATLAS.TCSGE IDH
    WHERE IH.INVESTMENT_ID =
    100 AND
    TO_CHAR(IDH.DATE_UPLOADED,
    'mmyyyy') = 100));
    END;

    Thanks
    Ishan

  2. #2
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: err in PL/SQL

    Originally posted by ishanbansal
    Hi
    I am running following piece of code in PL/SQL and getting an error.
    I am using oracle 8.1.7



    BEGIN
    dbms_output.put_line ( PK_EXCHANGE_RATE.FN_CURR_CONV((SELECT SUM(NET_EARNING_ASSET)
    FROM INVESTMENT_DETAIL_HISTORY@ATLAS.TCSGE IDH
    WHERE IH.INVESTMENT_ID =
    100 AND
    TO_CHAR(IDH.DATE_UPLOADED,
    'mmyyyy') = 100));
    END;

    Thanks
    Ishan
    What kind of error you got?

  3. #3
    Join Date
    Mar 2004
    Posts
    50
    This is the error that came .


    dbms_output.put_line ( PK_EXCHANGE_RATE.FN_CURR_CONV((SELECT SUM(NET_EARNING_ASSET)
    *
    ERROR at line 2:
    ORA-06550: line 2, column 55:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + mod not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string>

  4. #4
    Join Date
    Jan 2004
    Posts
    492
    You can't do that. If you are going to do a select, it either must be a cursor, or you must select into a variable.

    You need to declare a variable to hold the sum, and then dbms_output.put_line the sum.

    Ex:
    Code:
    DECLARE
    FN_SUM NUMBER;
    
    BEGIN
    SELECT SUM(NET_EARNING_ASSET)
    INTO FN_SUM
    FROM INVESTMENT_DETAIL_HISTORY@ATLAS.TCSGE IDH
    WHERE IH.INVESTMENT_ID =
    100 AND
    TO_CHAR(IDH.DATE_UPLOADED,
    'mmyyyy') = 100));
    DBMS_OUTPUT.PUT_LINE(FN_SUM);
    
    END;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •