Execute Immediate and by calling a function

I'm calling a function by using the Execute Immediate, but not sure what the correct syntax for the function's return value after the Execute Immediate runs.

I need the value for further processing in my PL/SQL package.

I tried several methods, but cannot get the right format for this work/compilation.


EExecute Immediate plsql_block back in ShName2;

Have been that plsql_block has the code to:
Declare shname2 varchar2 (4000); Begin shname2: = lurking. ShortNm ('STRUCTURE'); End;
SQL> set serveroutput on
SQL>
SQL> create or replace
  2  function fun
  3     return varchar2
  4  is
  5  begin
  6     return 'hello';
  7  end fun;
  8  /

Function created.

SQL>
SQL>
SQL> declare
  2     var varchar2(100);
  3  begin
  4     execute immediate 'begin :this := fun; end;' using in out var;
  5    dbms_output.put_line(var);
  6  end;
  7  /
hello

PL/SQL procedure successfully completed.

SQL> 

Tags: Database

Similar Questions

  • EXECUTE IMMEDIATE and operator "AND".

    Please what is the problem with this because the error said Invalid operator relationship
    declare
    x varchar2 (20);

    Start
    x: = "Navy";
    address: = "Cairo";
    ID: = 4;

    EXECUTE IMMEDIATE 'update t1 set name =' | x |' where address: = v1 and id: v2 =' help to answer, id;

    end;


    but it works fine without operator AND
    declare
    x varchar2 (20);

    Start
    x: = "Navy";
    address: = "Cairo";
    ID: = 4;

    EXECUTE IMMEDIATE 'update t1 set name =' | x: ' if the address: v1 =' using address;

    end;

    EXECUTE IMMEDIATE 'update t1 set name =' | x |' where address =: id = and v1: v2' using answer, id;

    -There should not be ': =' must be '=' and ': should precede the variable equal not before.

  • EXECUTE IMMEDIATE and NO_DATA_FOUND

    Hi all
    in my proc, I need to create a block for the select statement to continue with the process flow, because when the select returns no value I get the error ORA-01403: no data found.

    BEGIN
    Start
    query_stmt: = ' select CUST_FIRST_NAME in the OEHR_CUSTOMERS where ACCOUNT_MGR_ID =: 1';
    EXECUTE IMMEDIATE query_stmt in l_value using PK;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    audit_exception (SQLCODE, SUBSTR (SQLERRM, 1, 128), SYSTIMESTAMP);
    l_value: = null;
    end;
    query_stmt: = ' delete from OEHR_CUSTOMERS where ACCOUNT_MGR_ID =: 1';
    EXECUTE IMMEDIATE query_stmt using PK;
    query_stmt: = ' delete from OEHR_EMPLOYEES where MANAGER_ID =: 1';
    EXECUTE IMMEDIATE query_stmt using PK;
    query_stmt: = ' delete from OEHR_EMPLOYEES where EMPLOYEE_ID =: 1';
    EXECUTE IMMEDIATE query_stmt using PK;
    EXCEPTION
    WHILE OTHERS THEN
    audit_exception (SQLCODE, SUBSTR (SQLERRM, 1, 128), SYSTIMESTAMP);
    LIFT;


    Is there another solution to continue with the flow of treatment using dynamic SQL and select the statement without the block, because this way, I have to change a lot of code.

    Thank you
    Sergio

    JoL says:
    I used dynamic sql code with bind variable because I red this combination to improve performance (SQL is DB riutilizable) and for reasons of safety (protection against SQL Injection attacks).

    Sergio

    OK, bind variable improve performance and prevent SQL injections, however just refers to the difference between... for example

    immediately execute "delete from table1 where col1 = ' |" col1_value;

    and

    immediately execute "delete from table1 where col1 =: 1' using col1_value;"

    However,.

    When you write a DML directly in PL/SQL statement, then what is a local variable (not inside the SQL tables themselves) e.g. PK in your code is linked automatically as a variable binding by the PL/SQL engine, if of course they are bind variables and do not impinge on the performance. If you run a DML statement directly within PL/SQL like this and then check it running (assuming you've been pretty fast) via Enterprise Manager, you would see one of the places where you specified a local variable: 1: 2, etc.

    ;)

  • EXECUTE IMMEDIATE and multiple SQL

    Hello
    I get a string, say strSQL from an application.
    for example:

    strSQL: = "CREATE UNIQUE INDEX 'WEBDBTARGET'". "" PK_EMPID6"ON"WEBDBTARGET ". "" EMP_R1 "("EMPID")
    PCTFREE, INITRANS 10 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "TARGET_TS_01";

    CREATING INDEX 'WEBDBTARGET '. "' MARK ' ON 'WEBDBTARGET '. "" EMP_R1 "("EMPNAME")
    PCTFREE, INITRANS 10 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE «TARGET_TS_01 "«;»

    I tried to run the strSQL using EXECUTE IMMEDIATE

    get the error
    * "PLS-00103: encountered the symbol"end-of-file"when it is waiting for one of the following values: *"
    *; < an ID > < a between double quote delimited identifiers of > *.
    * The symbol ";" was replaced by "end-of-file" continue. » *

    I understand that the question is after the first SQL.
    How to use EXECUTE IMMEDIATE if the input string contains multiple SQL?
    Help, please.

    TIA,
    Newbie

    user570138 wrote:
    strSQL: = "CREATE UNIQUE INDEX 'WEBDBTARGET'". "" PK_EMPID6"ON"WEBDBTARGET ". "" EMP_R1 "("EMPID")
    PCTFREE, INITRANS 10 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE "TARGET_TS_01";

    CREATING INDEX 'WEBDBTARGET '. "' MARK ' ON 'WEBDBTARGET '. "" EMP_R1 "("EMPNAME")
    PCTFREE, INITRANS 10 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645)
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 DEFAULT USER_TABLES)
    TABLESPACE 'TARGET_TS_01"';'

    You have extra quote (marked in red). But remove won't solve all of your problems. EXECUTE IMMEDIATE executes a SQL statement. You must divide in two strSQL:

    strSQL:=' CREATE UNIQUE INDEX "WEBDBTARGET"."PK_EMPID6" ON "WEBDBTARGET"."EMP_R1" ("EMPID")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TARGET_TS_01"';
    EXECUTE IMMEDIATE strSQL;
    CREATE INDEX "WEBDBTARGET"."SDSDSD" ON "WEBDBTARGET"."EMP_R1" ("EMPNAME")
    PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "TARGET_TS_01"';
    EXECUTE IMMEDIATE strSQL;
    

    SY.
    P.S. in the majority of cases it IT not a good design of database to create objects dynamically.

  • execute immediate delivery when calling a plsql block procedure

    Hi all

    I have the following simple code, my immediate execution does not work (I am pasting the below error as well)

    CREATE OR REPLACE PROCEDURE CALL_RAHUL_PROCEDURES
    AS
    strng varchar2 (1000);

    BEGIN
    I'm in (select proc_name, flag, the rahul_procedures by id order id)
    loop
    If (i.flag = 'Y')
    then
    strng: = 'exec'. i.proc_name |' ("rahul")';
    dbms_output.put_line (strng);
    run immediately strng;
    end if;
    end loop;

    END CALL_RAHUL_PROCEDURES;

    --------------------------------------------------

    Error:

    Connect to the INQDWD database.
    ORA-00900: invalid SQL statement
    ORA-06512: at "ETLADMIN. CALL_RAHUL_PROCEDURES', line 17
    ORA-06512: at line 2
    exec ('rahul') RAHUL_HELLO_WORLD2;
    Process is complete.
    Disconnection from the INQDWD database.

    ----------------------------------------------------
    data in the rahul_procedures table:
    Proc_name flag Id
    RAHUL_HELLO_WORLD 1 N
    RAHUL_HELLO_WORLD2 Y 2
    RAHUL_HELLO_WORLD N 3
    RAHUL_HELLO_WORLD3 N 4

    ----------------------------------------------------

    Help, please.

    Concerning
    Rahul

    Transform your dynamic string in an anonymous PL/SQL block:

    strng := 'begin '||i.proc_name||'(''rahul''); end;';
    
  • How to set multiple parameters in a sql EXECUTE IMMEDIATE

    I want to set nls_language and nls_date_language and set them as different languages. fnd_global.set_nls_context () does not work. So I think I can use the EXECUTE IMMEDIATE and add them together into a single statement. But I don't know how to make that happen. Can someone help me? Thank you very much.

    PS: It must be done in a single call.

    928091 wrote:
    Hey, thanks for your reply, I forgot to mention that it should be in the begin-end block, do you know how?

    EXEC is a more SQL API which can be used to execute the PL/SQL code. What it does is put the PL/SQL code in a BEGIN block... END of block and run.

    So, you can also manually put code in a BEGIN block... END of block and run like that.

    SQL> begin
      2     execute immediate q'[begin execute immediate 'alter session set nls_date_language = ''AMERICAN'''; execute immediate 'alter session set nls_language = ''AMERICAN'''; end;]';
      3  end;
      4  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    And I don't understand what possible benefit he made a single run in a BEGIN block... Terminate during execution of multiples.

    Why this code is not in your interest, something like this

    begin
         execute immediate 'alter session set nls_date_language = ''AMERICAN''';
         execute immediate 'alter session set nls_language = ''AMERICAN''';
    end;
    /
    
  • call a function to listener programmatically

    I have a function that is called on a ListEvent. I want to call it programmatically on the startup of the program as the default even if the user has not triggered the event.

    How can I do this?

    var tmpE:ListEvent = new ListEvent;
    tmpE.index = 0;
    
    onItemSelected(tmpE);
    
    private function onItemSelected(e:ListEvent):void {
          // some code
    }
    

    It is called and it works very well when the event is raised, but I would like the event to be triggered or call the listener automatically function at startup.

    Dave

    Thanks for the responses... Sorry to be a clear, I was really tired when the post was created.

    I want to be clicked on the list box (blue list as a user has clicked on it by default)

    I call the function of default listener like this:

    var tmpE:ListEvent = new ListEvent("listItemClicked", null, 0, 0, 0, 0, null);
    onItemSelected(tmpE);
    

    and he calls this function to listener:

    private function onItemSelected(e:ListEvent):void {
        if (currentList) {
            rightContainer.removeChild(currentList);
            currentList = null;
        }
    
        trace ("cell:" + e.cell + " data:" + e.data);
    
        switch (e.index) {
            case 0:
                trace("About");
                buildAbout();
                break;
            case 1:
                trace("General");
                break;
        }
        if (currentList) {
            rightContainer.addChild(currentList);
            rightContainer.layout();
        }
    }
    

    The listener function works perfectly if the user selects a list item, it relies also the default option at the start of the first section of code without problem, but the words or the first item in the list is not selected.

    When the program loads the first item by default, it is not obvious to the user that the first item in the list is already loaded and selected because the list item is not selected...

    Thanks for your help guys.

    @pyth... use it in future thanks.

  • call a function from a webview actionscript

    In the mobile application that I develop, I need to be able to open a webview that displays a Web site that is saved locally in the app. Then, I need to be able to press a button in the webview and do call a function in the application itself. Is there a way to do this? Can a webview (via javascript or something) call a function in the application? If so, how?

    In JavaScript, set the custom document.location on some channels of URL property. You can use your own URL scheme to pass parameters of JS to AS3, as3 example: / / actions/document/record? overwrite = false. Then in ActionScript, handle the LocationChangeEvent.LOCATION_CHANGING event and examine or decode the URL.

    Call Event.preventDefault () in your AS3 event handler to cancel the navigation and stay on the same page.

  • EXECUTE IMMEDIATE or DBMS_UTILITY. EXEC_DDL_STATEMENT

    Hello

    I recently became aware of DBMS_UTILITY. EXEC_DDL_STATEMENT and I was wondering if it works in pretty much the same way as EXECUTE IMMEDIATE. I'm guessing that EXECUtE IMMEDIATE offers more flexibility when putting together the command you want to run, but you are the only real difference? All opinions accepted with gratitude,

    Kind regards

    Kevin.

    This isn't an exact answer to your question, but it may be useful.

    Execute Immediate is the approach privileged 9i or higher. If you decide which to use, go with EXECUTE IMMEDIATE. You never know when the other dynamic SQL methods will be deprecated. In addition, EXECUTE IMMEDIATE has also been optimized (and will continue to be optimized), so you can usually expect better performance during use.

    The exact differences between EXECUTE IMMEDIATE and DBMS_UTILITY. EXEC_DDL_STATEMENT go, I can't give you an exact answer. (Also the fact that DBMS_UTILITY. EXEC_DDL_STATEMENT DDL is, of course).

    You may or may not find this article helpful: http://okjsp.pe.kr/seq/9789. He did a good job to compare the differences between EXECUTE IMMEDIATE and another way inherited to the dynamic SQL statements (DBMS_SQL. RUN)

    Bob

  • Dynamically to catch a call of function of an object at run time

    Hello

    I kinda an interesting question.

    I have a dynamic object called Foo. He may have a set of clearly defined functions:

    public function helloWorld (): String

    {

    return "hello world";

    }

    public function get name (): String

    {

    return to 'My Name';

    }

    etc.

    I want to be able to create another function

    public function handleFunctionCall (functionCall:String, args:Array) :*

    {

    trace ("function:" + functionCall + "has been called with the arguments :");)

    for (var i: int = 0; i < args.length; i ++)

    {

    trace (args [i]);

    }

    }

    This is so that I can declare the Foo object and then call any function and therefore manipulate during execution.

    for example

    var foo:Foo = new Foo();

    foo.bar ();

    foo. WhatHaveYou();

    foo. Whatever();

    Hope someone can point me in the right direction.

    If you can have your dynamic class extend proxy ( http://livedocs.adobe.com/flex/3/langref/flash/utils/Proxy.html ), maybe it's what you need.

  • Call to function on a MovieClip confined

    Not sure if this is possible however, my current project requires this feature...

    Overview: user accesses the Web page and given their profile, they get a Questionnaire as part of the content of their Flash movie. The Questionnaire is a SWF file that is retrieved on the server and displayed by the Flash container movie.

    The < other > button is on film, not in the Questionnaire. When the user presses the < other > button, I need answers to the user of the SWF content questionnaire and send it to the server.

    Is it possible to add a function to the SWF, say GetResults(), allowing input from the user and return to the container movie for further processing?

    In Java / C++ + / etc, I would like to declare an interface and I all SWFs questionnaire implement this interface and could even check the SWF (is a) type, and then call a function defined in the interface.

    Is there another way to do this in Flash if this does not work?

    TIA,
    GEO

    You simply need to have the results (in the movie of the child) sent to the
    Server?
    If so, why you can not build a function called the type getResults
    loadVars in the film of the child, then call that works with the following button
    It is in the parent movie (for example, Next.onRelease = function() {})
    files childmovie.getResults} see Help on the loadVars.

    Now, if you try to draw on the results of the child movie in the
    film of parent for the treatment of some sort before sending it to the server that
    would be treated differently.

    "flashgruven" wrote in message
    News:enlqps$47s$1@forums. Macromedia.com...
    > Do not know if this is possible, however, my current project requires
    > feature?
    >
    > Preview: user accesses the Web page and in view of their profile, they get a
    > Questionnaire as part of the content of their Flash movie. The Questionnaire is
    > a
    > Retrieved from the server and displayed by the container SWF file
    > Flash Movie.
    >
    > The < next=""> button is on film, not in the Questionnaire. When
    > the
    > user press the button , I need to get the user? s answers
    > the
    > contained SWF questionnaire and send it to the server.
    >
    > Is it possible to add a function to the SWF, say GetResults(), which will be
    > collect the user? s of entry and return to the film container for
    > other
    > treatment?
    >
    > Java / C++ + / etc, I have? d declare an interface and have all the Questionnaire
    > Sovereign wealth funds
    > implement this interface, and could even check the type of the SWF (is a)
    > and
    > and then call a function defined in the interface.
    >
    > Y at - it another way to do this in Flash if it won? t work?
    >
    > TIA,.
    > geo
    >
    >

  • How to create and insert data with Execute Immediate?

    Hi guys

    Am stuck on a procedure of formatting in a package... script works okay however integrating a module turns out to be difficult!

    Am not used to oracle... I have the script runs, but not in the package... Well not all that... Drop Table worked

    CREATE or REPLACE PACKAGE BODY is

    PROCEDURE DropTable1 IS

    BEGIN

    run immediately ("DROP TABLE mytable1");

    END;

    PROCEDURE PopulateTable1 IS

    BEGIN

    immediately execute ('CREATE TABLE mytable1 )

    AS LONG AS)

    Select

    substr (T1.genarea, 3, 3) as M_Class,

    substr (T1.genarea, 6, 30) as M_Description,

    substr (T1.genarea, 36, 3) as M_Class,

    substr (T1.genarea, 39, 30) as M_Description,

    substr (T1. ItemItem, 1, 3) as product_code,.

    T3. CHANNEL_NUM as SALES_CHANNEL,

    to_date(''t2.time_id'',''dd-mon-yyyy'') as mis_date,

    Sum (T2.ap_cw_cfi_irp + T2.ap_cw_issues_irp) as ap_gross,

    sum (t2. Ap_Cw_Cfi_Irp + t2. Ap_Revivals_Irp) as ap_net,

    Sum (T2.sp_inc_irp + T2.sp_issues_irp) as sp_gross,

    Sum (T2.sp_dec_irp + T2.sp_fs_irp) as sp_net

    Of

    d_pr t1, t2 age_map t3 law

    where

    T1.pfx = "WE"and t1.coy ="1" and t1.tabl = "T81" and substr (t1.itemitem, 1, 3) = t2.product_id and t3. AGE_NUM = t2.age_id

    Group

    substr (T1.genarea, 3, 3),

    substr (T1.genarea, 6, 30),

    substr (T1.genarea, 36, 3),

    substr (T1.genarea, 39, 30),

    substr (T1. ItemItem, 1, 3).

    T3. CHANNEL_NUM,

    to_date(''t2.time_id'',''dd-mon-yyyy'')

    )');

    COMMIT;

    END PopulateTable1;

    END test;

    /

    Thank you

    Hello

    a few notes.

    1. to_date(t2.time_id,'dd-mon-yyyy')

    New York T2.Time_ID Cis the varchar2 data type that contains values to JJ-me-YYYY format?

    And if, in which language is used for the names of the months? Conversions are point impossible to solve in reasonable time limits without logging of dml errors and unique failure on charges of staging nightly!


    2 single quote escaping "alternative in string literals.

    You can use Q or q to escape single quotes in strings.

    http://docs.Oracle.com/database/121/SQLRF/sql_elements003.htm#SQLRF00218

    3. validation

    Not required because the DDL commands commit implied.

    In general I recommend you write commit clauses only in calling script rather than in the code unless it connects with an autonomous transaction.

    You end up with a lot of validation of code here and there and you don't know where it is and where it isn't. That is, your process may have more than one appeal process and commit the middle of the process, it is not atomic processes.

    Here's the demo although I recommend also using the static table and truncate to efficiency. ETG is good choice for the purpose of maintenance table.

    create or replace
    package testing is
      procedure staging_one;
    end;
    /
    create or replace
    package body testing is
      --
      procedure staging_one is
        --
        procedure drop_staging_one is
          table_does_not_exist exception;
          pragma exception_init(table_does_not_exist, -00942);
        begin
          execute immediate q'{
            drop table staging_one purge
          }';
        exception when table_does_not_exist then
          return; -- fine
        end;
        --
        procedure create_staging_one is
        begin
          execute immediate q'{
    
            -- remove >>>
            create table staging_one nologging
            as
            select * from dual
            -- <<< remove
    
            /* uncomment >>>
            create table staging_one nologging
            as
            select
              substr(t1.genarea,3,3)                    as m_class,
              substr(t1.genarea,6,30)                   as m_description,
              substr(t1.genarea,36,3)                   as m_class,
              substr(t1.genarea,39,30)                  as m_description,
              substr(t1.itemitem,1,3)                   as product_code,
              t3.channel_num                            as sales_channel,
              to_date(t2.time_id,'dd-mon-yyyy')         as mis_date,
              sum(t2.ap_cw_cfi_irp+t2.ap_cw_issues_irp) as ap_gross,
              sum(t2.ap_cw_cfi_irp+t2.ap_revivals_irp)  as ap_net,
              sum(t2.sp_inc_irp   +t2.sp_issues_irp)    as sp_gross,
              sum(t2.sp_dec_irp   +t2.sp_fs_irp)        as sp_net
            from
              d_pr t1,
              act t2,
              age_map t3
            where
              t1.pfx                      = 'IT'
              and t1.coy                  = '1'
              and t1.tabl                 = 'T81'
              and substr(t1.itemitem,1,3) = t2.product_id
              and t3.age_num              = t2.age_id
            group by
              substr(t1.genarea,3,3),
              substr(t1.genarea,6,30),
              substr(t1.genarea,36,3),
              substr(t1.genarea,39,30),
              substr(t1.itemitem,1,3),
              t3.channel_num,
              to_date(t2.time_id,'dd-mon-yyyy')
            <<< uncomment */
          }';
          --
        end;
      -- main
      begin
        drop_staging_one;
        create_staging_one;
      end;
    end;
    /
    
    set serveroutput on
    
    exec testing.staging_one;
    
    select * from staging_one
    ;
    commit
    ;
    
    PACKAGE TESTING compiled
    PACKAGE BODY TESTING compiled
    anonymous block completed
    DUMMY
    -----
    X 
    
    committed.
    
  • Execute Immediate with DOF and TABLE() - error ORA-22905

    Hello

    I have a problem trying to use a user defined the Type of the Table in a statement Execute Immediate containing a CREATE TABLE statement.

    Is there no work around for this problem?

    The actual code for the SELECT * OF TABLE(:T) is dynamic and slow. That's why I try to avoid to create/fill the table in two steps (as does with MY_TABLE1). Also, in this case, I can't use SELECT * but must specify all the columns (amount variable and over 100 columns).

    CREATE TYPE MY_TABLE_TYPE AS TABLE OF VARCHAR2(30);
    /
    DECLARE
        MT MY_TABLE_TYPE;
    BEGIN
        SELECT * BULK COLLECT INTO MT FROM DUAL;
        -- Two steps
        EXECUTE IMMEDIATE 'CREATE TABLE MY_TABLE1 (A VARCHAR2(30))';
        EXECUTE IMMEDIATE 'INSERT INTO  MY_TABLE1    SELECT * FROM TABLE(:T)' USING MT; -- OK
        -- One step
        EXECUTE IMMEDIATE 'CREATE TABLE MY_TABLE2 AS SELECT * FROM TABLE(:T)' USING MT; -- ERROR ORA-22905   
    END;
    /
    

    byee

    Andrea

    In my view, the error message is incorrect or the less misleading. Bind variables cannot be used in DDL:

    SQL > declare
    2 number of v_var: = 99;
    3. start
    4 run immediately "' create the my_table2 in select table: double T" using v_var; "
    5 end;
    6.
    declare
    *
    ERROR on line 1:
    ORA-01027: bind variable not allowed for data definition operations
    ORA-06512: at line 4 level

    SQL >

    What you could do is use the package variable:

    SQL > CREATE OR REPLACE
    2 PACKAGE PKG1
    3 EAST
    4 MT MY_TABLE_TYPE;
    5 FUNCTION GET_MT
    6 RETURN MY_TABLE_TYPE;
    7 END;
    8.

    Package created.

    SQL > CREATE OR REPLACE
    PACKAGE 2 BODY PKG1
    3 EAST
    4 GET_MT FUNCTION
    5 RETURN MY_TABLE_TYPE
    6 EAST
    7. START
    8 RETURN MT;
    9 END;
    10 END;
    11.

    Package body created.

    SQL > DROP TABLE MY_TABLE1 PURGE
    2.

    Deleted table.

    SQL > DROP TABLE MY_TABLE2 PURGE
    2.
    DROP TABLE MY_TABLE2 PURGE
    *
    ERROR on line 1:
    ORA-00942: table or view does not exist

    SQL > START
    2. SELECT * BULK COLLECT INTO PKG1.MT FROM DUAL;
    3 - two steps
    4 RUN IMMEDIATELY "CREATE TABLE MY_TABLE1 (A VARCHAR2 (30))';"
    5 IMMEDIATELY EXECUTE "INSERT INTO MY_TABLE1 SELECT * FROM TABLE (PKG1." GET_MT)';
    6 - one step
    7 IMMEDIATE EXECUTION "CREATE TABLE MY_TABLE2 AS SELECT * FROM TABLE (PKG1." GET_MT)';
    8 END;
    9.

    PL/SQL procedure successfully completed.

    SQL > select * from my_table1;

    A
    ------------------------------
    X

    SQL > select * from my_table2;

    COLUMN_VALUE
    ------------------------------
    X

    SQL >

    SY.

  • Call the function in LabView from a DLL, and then access the global variable of DLL

    I've created a DLL in LabWindows with a function and structure.  I want to call the function from LabView and then access the overall structure.  I am able to call the function in the DLL with a "call library function node" and has access to the return value, but I can't understand how to access the overall structure.  The structure is declared in the header DLL with __declspec (dllimport) struct parameters file.

    Is it possible to access this structure without using the library of network variables?

    My guess is that you need two bytes of padding after "in_out" and another to two bytes of padding after "anin."  The reason being that ints are 4 bytes, and most of them C compilers will align on 4-byte boundaries.  The struct will naturally start to such a limit (in fact, in Windows, it will probably start to an 8 byte boundary).  If you then count bytes in your structure, you are 70 byte after "in_out."  70 is not divisible by 4, so you need 2 bytes more to reach the next 4 byte boundary.  You can also you could reorganize your struct so that "anin" follows "in_out" and this is probably the best option if it won't cause you other problems.

    Unlike most C compilers, LabVIEW compressed structures as closely as possible, without filling.  I don't know enough about the history of LabVIEW and internal parts to explain the reasons and to do this performance penalty, but, as choice of LabVIEW "endianness", it is probably a remnant of the first versions of LabVIEW that were running on the Mac.

    If for some reason you want to force your C struct to match package LabVIEW, you can use the #pragma pack (x) directive, but I wouldn't recommend that here because you can control the C and LabVIEW.

    EDIT: in the cases where it was not clear, add padding to your cluster of LabVIEW, insert appropriate size or items at the place desired in the cluster.

  • How to call external functions without one. DLL (just using a.) H and. LIB file)?

    Hi all

    in fact, I am facing difficulties on how to get an external function is called in CVI (Version 2009).

    I was delivered with a. H file and a. LIB file to call an external function of my project CVI. The. H file looks like this:

    void exportedFunction(double *parameter);
    

    As far as I know, the external function was written with MS Visual C++ 6.

    So, I tried to link statically to the al extern like this function:

    -Add the. H file and the. LIB file to the CVI project

    -#include the. Folder H when I needed to call the external function

    -do the external function call

    During construction I get unresolved CVI external function call error, so this seems not work.

    I did some research autour and stood up with two possible problems. Maybe one of you can help me get a bit further and do work things out.

    (1) of the code of the 'real' function inside the DLL file that was not delivered to me. Or y at - it a way to get concrete results (calling external functions) with just one. H and a. LIB file (with none. Included DLL file)?

    (2) the external function does not export according to the rules of Style 'C '. The signature of the function in the. H file shows some things don't like

    extern "C" __declspec(dllexport) void __stdcall ...
    

    Or maybe it's a combination of these two issues (missing. DLL + bad export style function)?

    I guess I could get around the incorrect service export style when I managed to write a wrapper around the original function that actually uses Style C exporters. But I guess I need to the. DLL file for this test as well.

    Thank you very much for your answers.

    Best regards

    Bernd

    There is no need for the stuff of dllexport. There is also the option of a static library without any DLL.  But the "extern"C"' is essential, because it forces the C++ compiler, which was probably used to compile the library to use the C calling convention.

    If you are unable to ask the library vendor to provide a version that was compiled using C calling convention is the way to write a wrapper with VC ++ 6 around this library that functions using C calling convertion reexports. Something like

    extern 'C' myfunc1 type0 (type1 arg1,...) {

    Back to func1 (arg1,...);

    }

    for each function, you must use.

    BTW. "unresolved symbol" is the error message from the linker, you can expect if you try to bind the C code against a generation of library with the C++ calling convention.

Maybe you are looking for