Dynamic DML statements

I would like to Execute SQL statements entered by the users. I have a text box where the users can enter a SQL statement. I am storing this statement in the database (table_query)and when the user is another screen and presses Execute I would like to execute this statement.
For Example :The Test_table has 3 varchar2 columns and the insert statement entered is
insert into test_table values ('1','1','1');
I store this insert statement in the test_query table. I want to execute this statement from a form. I tried querying this value from the test_query table and did a forms_ddl(queried value) but I get a error. I was wondering if anyone had a different approach/solution or know what my problem is??
Thanks in advance.

I think the good code is like this :
DECLARE
VQUERY VARCHAR2;
BEGIN
SELECT query INTO vquery FROM table_query;
FORMS_DDL(:VQUERY);
END;
See if you have an error and if try to know if the problem come from the SELECT or the FORMS_DDL line.

Similar Messages

  • PLS-00435: DML statement without BULK In-BIND cannot be used

    My requirement
    I am dynamically creating a staging table my_stg, and then populate it. Seems simple, but not sure why i get this error,
    create table gtest4(myid varchar2(10), mykey varchar2(10));
    create table gtest5(myid varchar2(10), mykey varchar2(10));
    insert into gtest4 values(1,3);
    insert into gtest4 values(2,7);
    insert into gtest5 values(5,3);
    insert into gtest5 values (1,7);
    commit;
    /* Formatted on 2012/01/27 17:52 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE PROCEDURE px
    IS
    TYPE rectype IS RECORD (
    myid VARCHAR2 (100),
    mykey VARCHAR2 (100)
    TYPE tabtype IS TABLE OF rectype
    INDEX BY BINARY_INTEGER;
    rec tabtype;
    cur sys_refcursor;
    BEGIN
    EXECUTE IMMEDIATE 'create table my_stg(myid varchar2(100), mykey varchar2(100)) ';
    OPEN cur FOR 'select a.myid, b.mykey
    from gtest4 a, gtest5 b
    where a.mykey = b.mykey';
    LOOP
    FETCH cur
    BULK COLLECT INTO rec LIMIT 500;
    FORALL i IN 1 .. rec.COUNT
    EXECUTE IMMEDIATE 'insert into my_stg(myid, mykey) values (rec(i).myid,
    rec(i).mykey)';
    EXIT WHEN cur%NOTFOUND;
    END LOOP;
    END;
    I compile the above proc, and get
    PLS-00435: DML statement without BULK In-BIND cannot be used
    the reason I do insert in execute immediate is because the table my_stg does not exist, it is created on the fly

    I tried the below, used plsql table variables instead of record type
    CREATE OR REPLACE PROCEDURE px
    IS
    TYPE rectype IS RECORD (
    myid VARCHAR2 (100),
    mykey VARCHAR2 (100)
    TYPE tabtype1 IS TABLE OF varchar2(100)
    INDEX BY BINARY_INTEGER;
    TYPE tabtype2 IS TABLE OF varchar2(100)
    INDEX BY BINARY_INTEGER;
    rec1 tabtype1;
    rec2 tabtype2;
    cur sys_refcursor;
    BEGIN
    EXECUTE IMMEDIATE 'create table my_stg(myid varchar2(100), mykey varchar2(100)) ';
    OPEN cur FOR 'select a.myid, b.mykey
    from gtest4 a, gtest5 b
    where a.mykey = b.mykey';
    LOOP
    FETCH cur
    BULK COLLECT INTO rec1, rec2 LIMIT 500;
    FORALL i IN 1 .. rec.COUNT
    execute immediate 'insert into my_stg(myid, mykey) values (:1,:2)
    using rec1(i).myid, rec2(i).mykey;
    EXIT WHEN cur%NOTFOUND;
    END LOOP;
    END;
    I get error
    PLS-00103: Encountered the symbol "insert into my_stg(myi
    mykey) values (:1,:2)
    using rec1(i).myi" when expecting one of the following:
    ( - + case mod new not null <an identifier>
    <a double-quoted delimited-identifier> <a bind variable>
    count current exists max min prior sql stddev sum varianc
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal
    Please help

  • If we use DML statement in function then that function can be used inside s

    if we use DML statement in function then that function can be used inside select query or any DML query?

    select f from t2;I think you meant to query t1.
    It works if the function is an autonomous transaction:
    create or replace function f return number
    is
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
        update t1 set c=2;
        commit;
        return 1;
    end;
    select f from t1But as Billy said why would you want to do DML this way. And this is not the way autonomous procedures should be used either.
    An an answer to an interview question though nothing wrong with it.

  • Dynamic IF statement in PL/SQL on-insert trigger in Forms 6.0

    I would like to build a dynamic IF statement for the on-insert trigger in a form... Users are restricted to which "projects" they are allowed to enter into the database. These restrictions are based on a security table. The same restrictions are used to build the dynamic where clause that limits which previously inserted records the users can see when they are in the form. Since the restrictions are identical, I want to use the same logic that I use to build a where clause to build a dynamic If statement instead... If the statement is true, the user can insert the record. If its false, they can't.
    I'm trying to this as follows:
    declare
    big_if varchar2(10000) :=' ';
    begin
    if :global.admin='YES'
    then
    insert_record;
    else
    declare
    cursor cur1 is
    select paren1, field, comparison_operator, value, paren2, and_or
    from rcdb.user_project_assign2
    where user_id = user;
    c1_rec cur1%ROWTYPE;
    begin
    for c1_rec in cur1 loop
    big_if:= big_if &#0124; &#0124; c1_rec.paren1 &#0124; &#0124; ':tbl_main_data.' &#0124; &#0124;c1_rec.field &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    end loop;
    end;
    if big_if
    then
    insert_record;
    else message('You are not allowed to insert this record');
    end if;
    end if;
    end;
    The problem is in the line
    IF big_if
    big_if is the variable that holds the text to my if statement (hense dynamic If statement) but I can't get the code to allow me to use that variable.
    Can anyone do this?
    null

    That code was great, but forms isn't allowing me to use the dbms_sql so I have to make a procedure out of forms and call it from the form. Both my form code and the procedure are compiling, but I"m still getting an error when the result is coming back to the form...
    the code in the form is:
    declare
    big_if varchar2(10000) :=' ';
    result varchar2(5) :=' ';
    check_state varchar2(2):=:tbl_main_data.state_abr;
    check_region varchar2(3):=:tbl_main_data.region_abr;
    check_program varchar2(25):=:tbl_main_data.program;
    begin
    if :global.admin='YES'
    then
    insert_record;
    else
    declare
    cursor cur1 is
    select paren1, field, comparison_operator, value, paren2, and_or
    from rcdb.user_project_assign2
    where user_id = user;
    c1_rec cur1%ROWTYPE;
    begin
    for c1_rec in cur1 loop
    big_if:= big_if &#0124; &#0124; c1_rec.paren1;
    if c1_rec.field = 'state_abr' then
    big_if:=big_if &#0124; &#0124; 'check_state' &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    elsif c1_rec.field = 'region_abr' then
    big_if:=big_if &#0124; &#0124; 'check_region' &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    elsif c1_rec.field = 'program' then
    big_if:=big_if &#0124; &#0124; 'check_program' &#0124; &#0124;c1_rec.comparison_operator &#0124; &#0124; '''' &#0124; &#0124; c1_rec.value &#0124; &#0124; '''' &#0124; &#0124; c1_rec.paren2 &#0124; &#0124; ' '&#0124; &#0124; c1_rec.and_or &#0124; &#0124; ' ';
    end if;
    end loop;
    end;
    message(big_if); pause;
    message(check_state); pause;
    message(check_region); pause;
    message(check_program); pause;
    rcdb.check_if(big_if,result,check_state,check_region,check_program);
    message('resulte = &#0124; &#0124;result&#0124; &#0124;');
    if result = 'TRUE' then insert_record;
    else
    message ('you cant enter');
    end if;
    end if;
    end;
    AND THE CODE IN THE PROCEDURE IS....
    create or replace procedure check_if (
    big_if in varchar2,
    result out varchar2,
    check_state in varchar2,
    check_region in varchar2,
    check_program in varchar2
    IS
    v_indx binary_integer := 0;
    v_sql_syntax varchar2(32767);
    root_cursor number;
    ignore integer;
    your_if_statement VARCHAR2(32767);
    v_check VARCHAR2(5);
    BEGIN
    your_if_statement := ' if '&#0124; &#0124;big_if&#0124; &#0124;' then :v_check := ''TRUE''; end if;';
    v_sql_syntax := 'begin '&#0124; &#0124;your_if_statement&#0124; &#0124;' end;';
    root_cursor := dbms_sql.open_cursor;
    v_sql_syntax := replace(replace(REPLACE(v_sql_syntax,chr(10),' '),chr(13),' '),chr(9),' ');
    dbms_sql.parse(root_cursor,v_sql_syntax,dbms_sql.v7);
    dbms_sql.bind_variable( root_cursor, ':v_check',v_check,5);
    ignore := dbms_sql.execute(root_cursor);
    dbms_sql.variable_value(root_cursor, ':v_check', v_check);
    if v_check = 'TRUE' then result:='TRUE';
    else
    result:='FALSE';
    end if;
    dbms_sql.close_cursor(root_cursor);
    END check_if;
    DO YOU KNOW WHATS WRONG?

  • Dynamic SELECT statement causing CX_SY_DYNAMIC_OSQL_SEMANTICS error.

    Hello Gurus,
    We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
              SELECT (lt_select_flds)
                FROM (lf_tab_name)
                INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
                FOR ALL ENTRIES IN <lt_source_data>
                WHERE (lf_where).
    In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
    WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
    This code was working fine till yesterday when we encountered serious performance problems and the Basis team had to do some changes at the DB level [Oracle]. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS.
    Is setting changes at the Oracle level cause issues with how the data is being read at the DB. If yes, can you suggest what can we do to this code to get is working correctly [in case Basis can't revert back their changes]?
    Would appreciate any help we can get here.

    You don't understand - this error comes up when we run specific BEx queries.  It was working yesterday, but today it is not.  Our support package did not change from yesterday.  We did not apply any OSSnotes.
    We are however doing pre-prepare on our Prod system.
    The temporary table is used to store SIDs for use in the join.  the table exists in the dictionary, but not at an Oracle level.

  • DYnamic select statement in JDBC adapter?

    Hi guys,
                 Is it possible so send dynamic select statement in jdbc adapter?
    XIer

    Aamir,
    The poster did not specify whether this was sender or receiver channel, but it would only make sense that a "dynamic query" must be on the receiver communication channel since if it was on the sender channel, the channel would have to intelligently determine how to do dynamic queries.
    Also, the poster asked if there was a way to "send a dynamic query" to the channel.  This seems to imply that the channel is receiving information from somewhere to determine the query, which could only mean it is a receiver channel.
    If you would like more information on the JDBC sender communication channel, please open a new thread.

  • Dynamic UPDATE statement with parameters for column names.

    Hello,
    On this* website I read "The SQL string can contain placeholders for bind arguments, but bind values cannot be used to pass in the names of schema objects (table or column names). You may pass in numeric, date, and string expressions, but not a BOOLEAN or NULL literal value"
    On the other hand, in this Re: execute immediate with dynamic column name update and many other
    posts people use EXECUTE IMMEDIATE to create a dynamic UPDATE statement.
    dynSQL:='UPDATE CO_STAT2 CO SET CO.'||P_ENT_B_G_NAME||' = '||P_ENT_E_G_WE||'
    WHERE ST IN
    (SELECT ST FROM STG_CO_STAT2_TEST CO WHERE
    '||P_ST||' = CO.ST AND
    CO.'||P_ENT_E_G_NAME||' > '||P_ENT_E_G_WE||' AND
    CO.'||P_ENT_B_G_NAME||' < '||P_ENT_E_G_WE||');';
    EXECUTE IMMEDIATE dynSQL ;
    Since this statement is part of a Stored Procedure, I wont see the exact error but just get a ORA-06512.
    The compiling works fine and I use Oracle 11g.
    http://psoug.org/definition/EXECUTE_IMMEDIATE.htm

    OK I extracted from all of your posts so far that I have to use "bind-variables with :"
    From all the other tuorials and forums posts, I assume using the pipe is correct so I added those as well into the script:
    set serveroutput on format wraped;
    DECLARE
    dynSQL VARCHAR2(5000);
    P_ENT_E_G_NAME VARCHAR2 (100) :='test1'; P_ENT_E_G_WE VARCHAR2 (100) :='01.02.2012'; P_ENT_B_G_NAME VARCHAR2 (100) :='01.01.2012';
    P_ST                VARCHAR2 (100) :='32132';
    BEGIN
    dynSQL:= 'UPDATE CO_STAT2 CO SET CO.'||:P_ENT_B_G_NAME||' = '||:P_ENT_E_G_WE||'
                  WHERE ST IN (SELECT ST FROM STG_CO_STAT2_TEST CO WHERE
                  '||:P_ST||'                           = CO.ST                  AND
                  CO.'||:P_ENT_E_G_NAME||'     > '||:P_ENT_E_G_WE||' AND
                  CO.'||:P_ENT_B_G_NAME||'    
    < '||:P_ENT_E_G_WE||')';
    --this is somehow missing after the last < '||:P_ENT_E_G_WE||')';
    dbms_output.enable;
    dbms_output.put(dynSQL);
    --EXECUTE IMMEDIATE dynSQL;    
    END;Problem:I think I figured it out, the dates that I parse into the query need additional '

  • Dynamic TSQL Statement with Dynamic Parameters

    I'm trying to utilize a dynamic TSQL Statement where I can have various parameters passed of differing kinds, e.g. In some cases parameter 1 would be an int, other cases it may be a datetime, or varchar, etc.
    I'm going to keep  a table of with certain key SQL Statements, and then parameters in another column so this can be resusable.
    Here is my code:
    Case 1
    Declare @FromDate as DATE='2013-10-01'
    Declare @ToDate as DATE='2013-10-31'
    Declare @FamilyMember as nvarchar(2)='20'
    DECLARE @retval int
    DECLARE @sSQL nvarchar(500);
    DECLARE @ParmDefinition nvarchar(500);
    DECLARE @tablename nvarchar(50)
    --Select Convert(nvarchar(15), @FromDate,126)
    SELECT @sSQL = N'select count(distinct id) as AggregateCount from [Table] where familyMember = @FamilyMember
    and DateStamp between @FromDate and @ToDate';
    SET @ParmDefinition = N'@retvalOUT int OUTPUT';
    EXEC sp_executesql @sSQL, @ParmDefinition, @retvalOUT=@retval OUTPUT;
    Case 2
    Declare @FromDate as DATE='2013-10-01'
    Declare @ToDate as DATE='2013-10-31'
    Declare @Id as int=3510021
    DECLARE @retval int
    DECLARE @sSQL nvarchar(500);
    DECLARE @ParmDefinition nvarchar(500);
    DECLARE @tablename nvarchar(50)
    --Select Convert(nvarchar(15), @FromDate,126)
    SELECT @sSQL = N'select count(distinct id) as AggregateCount from [Table] where Id=@Id
    and DateStamp between @FromDate and @ToDate';
    SET @ParmDefinition = N'@retvalOUT int OUTPUT';
    EXEC sp_executesql @sSQL, @ParmDefinition, @retvalOUT=@retval OUTPUT;
    John

    The following is an example I found, but I am receiving a Message "Must declare the scalar variable @StudentNumber"
    Alter Procedure [dbo].[spInsertStudentDoc2]
    @StudentNumber integer
    AS
    Begin
    DECLARE @P_StudentNumber integer
    DECLARE @ParameterList nvarchar(max)
    DECLARE @SQLSnippit as nvarchar(max)
    SET @ParameterList = N'@P_StudentNumber integer'
    SET @SQLSnippit = N'Select Count(*) from dbo.student where patid=@StudentNumber'
    PRINT @SqlSnippit -- debug & test
    Exec SP_EXECUTESQL @SqlSnippit, @ParameterList, @P_StudentNumber=@StudentNumber
    End
    John

  • Will Materialized view log reduces the performance of DML statements on the master table

    Hi all,
    I need to refresh a on demand fast refresh Materialized view in Oracle 11GR2. For this purpose I created a Materialized view log on the table (Non partitioned) in which records will be inserted @ rate of 5000/day as follows.
    CREATE MATERIALIZED VIEW LOG ON NOTES NOLOGGING WITH PRIMARY KEY INCLUDING NEW VALUES;
    This table already has 20L records and adding this Mview log will reduce the DML performance on the table ?
    Please guide me on this.

    Having the base table maintain a materialised view log will have an impact on the speed of DML statements - they are doing extra work, which will take extra time. A more sensible question would be to ask whether it will have a significant impact, to which the answer is almost certainly "no".
    5000 records inserted a day is nothing. Adding a view log to the heap really shouldn't cause any trouble at all - but ultimately only your own testing can establish that.

  • Getting result of dynamic select statement into variable

    I have a function that builds a dynamic sql statement. I then want to take the result of that statement and insert it into a variable. I have tried this
    execute immediate strSQL USING OUT intCounter;but that is giving me an error on that line of code. The SQL is a select count(*) and works fine. It is just how to get it into the variable that is tripping me up.
    Thanks,
    Eva

    Sure. Version 11g. The complete procedure reads as follows:
    CREATE OR REPLACE FUNCTION VALIDATIONQUESTIONRESULT
        p_ShortName VARCHAR2,
        p_SiteID    VARCHAR2
    RETURN NUMBER IS
        strSQL VARCHAR2(5000);
        strTableName VARCHAR2(200);
        strPatIDFieldName VARCHAR2(200);
        intCounter NUMBER;
    BEGIN
        select VALIDATIONSQL into strSQL from vwvalidationquestions where upper(shortname) = upper(p_ShortName);
        select
                case UPPER(DBTABLENAME)
                    when 'CPTICODES' then 'CPTIPATID'
                    when 'CPTIICODES' then 'CPTIIPATID'
                    when 'DEMOGRAPHICS' then 'PATID'
                    when 'FAMILYHISTORY' then 'FHPATID'
                    when 'GCODES' then 'GCODEPATID'
                    when 'HOSPITALIZATION' then 'HPATID'
                    when 'MEDICALHISTORY' then 'MHPATID'
                    when 'MEDICATIONS' then 'MPATID'
                    when 'PROCEDURES' then 'PPATID'
                    when 'VISITS' then 'VPATID' end into strPatIDFieldName
        from DATASPECIFICATIONS where UPPER(SHORTNAME) = UPPER(p_ShortName);
        strSQL := strSQL||' and '||strPatIDFieldName||' in (select PATID from DEMOGRAPHICS where PARTICID = '||p_SiteID||');';
        execute immediate strSQL into intCounter;
        return intCounter;
    END VALIDATIONQUESTIONRESULT; strSQL when checked builds perfectly. I get 100% what I expect from it. An example of what I am getting from strSQL is:
    select count(*) from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);I am getting the number I would expect from this. I just need to put that number into intCounter. I tried altering strSQL so it looked like this:
    select count(*) into intCounter from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);but that gave me an error on the execute immediate line as well.
    Sorry, I thought it would be simple so that was why I only put that bit of info. I guess it is more complicated than it at first appeared!
    Eva

  • Help With SUBSTR in dynamic SQL statement

    Following is the dynamic SQL statement.
    EXECUTE IMMEDIATE 'UPDATE table_name pml
    SET pml.'|| con_fields.field ||' = SUBSTR(pml.'||con_fields.field||' ||'' ''||
    (SELECT pml1.'||con_fields.field||'
    FROM table_name pml1
    WHERE pml1.grp_id = '||los_concats.grp_id ||'
    AND pml1.row_id = '||los_concats.row_id||'
    AND pml1.loser_flg = ''Y''),1, '||con_fields.max_length||')
    WHERE pml.grp_id = '||los_concats.grp_id ||'
    AND pml.loser_flg IS NULL ';
    what it does is that it updates a particular field. This field is concatenated by a field of a similar record.
    My problem is with SUBSTR function. Since I am concatenating fields I do not want the field to be updated greater than max_length on that field, the reason why I use SUBSTR. the select query inside SUBSTR works alright with one of the AND condition in a WHERE clause not present. When I add that additional condition it gives me this error.
    ORA-00907: missing right parenthesis.
    Is there any way to get around this problem. Does SQL has other than SUBSTR function which can limit the character length.
    Appreciate it.

    The other alternative I thought about was to do this first
    EXECUTE IMMEDIATE 'SELECT pml.'||con_fields.field||'
    FROM table_name pml
    WHERE pml.grp_id = '||los_concats.grp_id||'
    AND pml.row_id = '||los_concats.row_id||'
    AND pml.loser_flg = ''Y''
    ' INTO v_concat_field;
    write into the variable v_concat_field and then use it into the previous script.
    But on this I get SQL Command not properly terminated, I don't get it Why?
    Donald I tried with your suggested script. It works fine with one of the conditions eliminated. I don't understand what the error trying to say?
    Thanks

  • Can we do Dml statements on materialize views

    I want to know can we do Dml statements on materialize views .If yes, how

    Can you? Maybe. Depends on how you created the materialized view. Should you? Maybe. Are you running a multi-master environment? Or are you using materialized views for one-way replication? If you are doing one-way replication, do you want your DML changes to be retained beyond the next refresh of the materialized view?
    Justin

  • Preparing Dynamic SQL statement for inserting in Pro*C

    Hi Friends,
    From quite some time i am struggling writing Dynamic SQL statement for dynamic insert and update in Pro*C.
    Can somebody go through my code and suggest me the rigth way of doing.
    Right now it throws an error saying " Error while updating ORA-00904: invalid column name "
    Please help me.
    Girish.
    int main()
    EXEC SQL BEGIN DECLARE SECTION;
    char *uid ="scott/tiger";
    static char sqlstmt[129];
    struct /* DEPT record */
    int dept_num;
    char dept_name[15];
    char location[14];
    } dept_rec;
    EXEC SQL END DECLARE SECTION;
    EXEC SQL WHENEVER SQLERROR DO sql_error();
    EXEC SQL CONNECT :uid;
    dept_rec.dept_num = 50;
    strcpy(dept_rec.dept_name,"ADMIN");
    strcpy(dept_rec.location,"IN");
    strcpy(sqlstmt,"UPDATE dept set DNAME = dept_rec.dept_name where DEPTNO = dept_rec.dept_num");
    EXEC SQL EXECUTE IMMEDIATE:sqlstmt;
    EXEC SQL COMMIT;
    exit(0);
    void sql_error()
    printf("\nError while updating %s",sqlca.sqlerrm.sqlerrmc);
    EXEC SQL ROLLBACK;
    }

    A bit rusty here but this is how I see it.
    Think of it this way ..
    all Oracle is going to see is:
    UPDATE dept set DNAME = dept_rec.dept_name where DEPTNO = dept_rec.dept_num
    Its NOT going to know what dept_rec.dept_name is or dept_rec.dept_num is ..
    it doesnt go back and fill in those values.
    You need something like
    strcpy(sqlstmt,"UPDATE dept set DNAME = \"");
    strcat(sqlstmt,dept_rec.dept_name);
    strcat(sqlstmt,"\" where DEPTNO = ");
    strcat(sqlstmt,dept_rec.dept_num);
    printf(sqlsmt); # Just to be sure the update statement look right during testing.

  • How can I execute Dynamic SQL statement in Forms?

    Hi All,
    I have to execute dynamic SQL statement from Forms
    Below statement I have to execute
    "EXECUTE IMMEDIATE v_stmt INTO v_return;".
    Googled for the same got results saying, Better use Database function or procedures to execute these Dynamic Statements but We want to execute in forms only.
    Can any one help me..
    Thanks,
    Madhu

    So in short you are trading code obfuscation for maintainability and the ability to share code between tools? If from somewhere else you need a procedure already implemented in database PL/SQL (and now ported to forms) this would mean you'd need to implement it in every other tool. In times where you might want to integrate your forms with $other_technology and putting stuff on the database is the first step to share functionality you just go the opposite way? And all that because someone is afraid that somebody might steal your source code? I am sorry to be blunt, but this is just plain stupid.
    Leaving aside that some things like Analytic Functions, Bulk processing or execute immediate are not even available in forms your software consists of how many LOC? How long does it take to bring a new developer up to speed with your source code? Imagine how long that would take for a developer who doesn't have coleagues who know their way around.
    And just so you know: I work for a ISV selling a closed-source product as well. We have 200+ customers all over the planet. We are well aware that wrapped packages can be reverse engineered. The premise is: stored procedures can be reused in every tool we have, if it makes sense to put stuff on the database by all means do it. If someone would want to reverse engineer our software I'd wish him good luck as some parts are implemented in such a hilarious complicated way I have troubles understanding them (and quite frankly I refuse to understand certain parts, but that's another story). I do work for almost 10 years for that ISV.
    In any case the possible solutions have already been mentioned: you have exec_sql, create_group_from_query and forms_ddl to execute dynamic SQL in forms whereas forms_ddl is a one way street and most certainly not the thing you need or want. Take a look at the documentation for the other 2 things.
    cheers

  • Golden Gate - DML statements are not replicated to target database

    Hi,
    Testing Environment
    Source:
    OS: RHEL 4.6, Database: 11gR2, Golden Gate 10.4, ASM
    extract ext1
    connection to database
    userid ggate, password qwerty
    hostname and port for trail
    rmthost win2003, mgrport 7800
    path and name for trial
    rmttrail C:\app\admin\GOLDENGATE\dirdat\lt
    EXTTRAIL /u01/oracle/goldengate/dirdat/lt
    --TRANLOGOPTIONS ASMUSER SYS@ASM, ASMPASSWORD sys ALTARCHIVELOGDEST /u03/app/arch/ORCL/archivelog
    --DDL support
    ddl include mapped objname sender.*;
    --DML
    table sender.*;
    Target:
    OS: Windows 2003, Database: 11gR2, Golden Gate 10.4
    --replicate group
    replicat rep1
    --source and target defintions
    ASSUMETARGETDEFS
    --target database login
    userid ggate, password ggate
    --file for discared transaction
    discardfile C:\app\admin\GOLDENGATE\discard\rep1_disc.txt, append, megabytes 10
    --ddl support
    DDL
    --specifying table mapping
    map sender.* ,target receiver.* ;
    I've Successfully setup Oracle Golden Gate test environment as above.
    DDL statements are replicating successfully to target database.
    while DML statements are not being replicated to target database.
    Pl. try to solve the problem
    Regards,
    Edited by: Vihang Astik on Jul 2, 2010 2:33 PM

    Almost ok but how you will handle the overlapping (transactions captured by expdp & captured by Extract too) of transactions for the new table ?
    Metalink doc ID 1332674.1 has the complete steps. Follow the "without HANDLECOLLISIONS" approach.

Maybe you are looking for