DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: execute immediate

  1. #1
    Join Date
    Nov 2000
    Location
    Birmingham, UK
    Posts
    360

    execute immediate

    I'm having problems running execute immediate from a procedure. Basically I'm trying to create a database link from information stored in a table (list_of_tables) - using 9.2.0.5

    Code:
    select * into v_lod from list_of_databases where lod_sid = p_dbsid;
    
    execute immediate 'create database link '||v_lod.lod_sid||'.world connect to '||v_lod.lod_username||
     ' identified by '||v_lod.lod_password||' using '||chr(39)||v_lod.lod_prmy_tns||chr(39)||';';
    The error I'm getting is
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "DBACHECK.FRAZE_TEST", line 35
    ORA-06512: at line 1

    Any help appreciated

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166

    Re: execute immediate

    Code:
    select * into v_lod from list_of_databases where lod_sid = p_dbsid;
    
    execute immediate 'create database link ' || v_lod.lod_sid      ||
                      '.world connect to '    || v_lod.lod_username ||
                      ' identified by '       || v_lod.lod_password ||
                      ' using '''             || v_lod.lod_prmy_tns ||
                      ''';';
    Does this work? You need to use 2 ' when you want to embed them.

  3. #3
    Join Date
    Nov 2000
    Location
    Birmingham, UK
    Posts
    360
    Getting the same error unfortunately - I was using chr(39) which is the same as '''

  4. #4
    Join Date
    Jan 2004
    Posts
    162
    Lose the first semi-colon.

  5. #5
    Join Date
    Nov 2000
    Location
    Birmingham, UK
    Posts
    360
    Excellent - all works now - Cheers for that

Posting Permissions

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


Click Here to Expand Forum to Full Width