Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    51

    Unanswered: execute immediate

    create or replace procedure a as
    str1 varchar2(500);
    val number(10);
    begin
    str1:='select num into val from trial where condition=<>' ;
    execute immediate str1 ;
    end;

    This program has errors.
    I am trying to get the value of num into val. I want to use execute immediate due to other programming reasons. I want to use the value of val for other calculations.
    How can i do this.
    sampath gowri

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >How can I do this?
    By constructing valid SQL statements!
    >select num into val from trial where condition=<>
    The line above is NOT valid SQL.
    here is a free clue.
    1) Build the SQL for EXECUTE IMMEDIATE as a single VARCHAR2 variable
    2) prior to invoking the ECECUTE IMMEDIATE output the variable with DBMS_OUTPUT so you can see what is being passed to SQL parser.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    this..
    str1:='select num into val from trial where condition=<>' ;
    execute immediate str1 ;

    should be:
    str1:='select num from trial where condition=<>' ;
    execute immediate str1 into val;

Posting Permissions

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