Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    205

    Unanswered: CAST and RTRIM in SP

    Hi,

    I tried the following :

    select rtrim(cast('abcd' as char(8))) from dual --> returns "abcd"

    But if I try the same in my Oracle Stored procedure, this is not working. Here is my procedure :

    create or replace procedure ....
    ....
    var char(10);

    var := rtrim(cast('abcd' as char(8))); // Here it throws error.

    Why is this not working ?
    Please advise. Also is there any alternative available for this in procedure level.

    Thanks,
    Sam

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Use this code:
    Code:
    CREATE OR REPLACE PROCEDURE myproc
    IS
      var CHAR(10);
    BEGIN
      SELECT RTRIM(cast('abcd' AS CHAR(8))) INTO var FROM dual;
      dbms_output.put_line(var);
    END;
    /

  3. #3
    Join Date
    Mar 2004
    Posts
    205
    Thanks for your prompt reply.

    Even I tried this previously, I get the same following error :

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    5/35 PLS-00103: Encountered the symbol "(" when expecting one of the
    following:
    ) varying large
    The symbol ")" was substituted for "(" to continue.

    5/39 PLS-00103: Encountered the symbol ")" when expecting one of the
    following:
    . ( , * % & - + / at mod rem <an identifier>
    <a double-quoted delimited-identifier> <an exponent (**)> as
    from into || bulk
    The symbol "(" was substituted for ")" to continue.

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Procedure I wrote works properly on Oracle 9.0.1.3.0.
    It won't compile on Oracle 8.1.7. (same errors you had).

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    And the manual says that the CAST function is ANSI-standard function (from SQL/92 forward) that is newly supported in Oracle9i.
    Which version do you use?

Posting Permissions

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