Execute the sql statement stored in table

friends i m in complication that, how can i execute sql statement which is stored in database table.
how can i fetch that particular statement from table and make it execute!!!
Thanks in advance

I think we should stop at this point and have a little think.
My understanding is that your plan is to do the following
-Execute a Dynamic SQL statement which is constructed from values in several columns in a table (Bad idea to begin with)
-The result of the execution is then loaded into PL/SQL.....not sure how you are handling different column lists but I'll assume you are not having to convert every column value to a VARCHAR2
-The values returned are then used in an INSERT statement
So basically your goal here is to take some data from one table and insert it into another table by moving data from SQL to PL/SQL then back to SQL in an elaborate, dynamic way. This is a costly waste of resources and will not scale (this is before we get to the problem of having to read the SQL statement from a table in the first place)
I would recommend looking the INSERT SELECT statement here: http://psoug.org/reference/insert.html
This will get the job done in one go. If you really do need it to be dynamic (which you don't, trust me) then you can still store this statement in your "dynamic SQL" table and execute it using EXECUTE IMMEDIATE although I can say for sure that you're going to run into more problems down the line with this architecture, it won't scale very well, and you'll probably waste at least *1* day of your time every week trying to fix a bug caused by the removal of a table, change to a column name etc.......
However if you believe that storing SQL in a table is the best solution to your problem then go ahead.....at least when you find out that it isn't you'll have learned a valuable lesson.

Similar Messages

  • Executing the SQL statement is not allowed - Error

    I am getting "Executing the SQL statement is not allowed" for an INSERT cfquery that I'm running.  I checked the usual suspects:
    - DSN allows INSERT
    - I've seen reports online where certain field names or values are considered key words, so for protection CF blocks the query in this way (it would be nice if there was a different error message when it gets blocked this way vs. the DSN doesn't allow INSERT error message).  The field names and values were all benign strings, so it didn't seem like that.
    I took the same string for the query and ran it on another page and it ran fine (same DSN, too).

    SOLVED: I decided to enter this in here, just to get it into web searches for others since I couldn't find anything.
    - I was calling a function for one of the values in the query:  get_db_status_code("initialize")  Apparently CF parses the query to see if it's allowed BEFORE it runs the CFML in it, so something in that function name, or the parameter "initialize" was a key word that CF doesn't allow.  I moved the function call outside of the query and loaded a temp variable for use in the query and it then worked.

  • Patterns to execute a SQL Statement from a Droplet (select)

    Hi,
    I need to perform a query on a table, Example: select * from ARF_QUERY "the database used is Oracle. I would like to know if the atg has some
    standard method to perform this database connection and execute the SQL statement from a Droplet (select).
    Thank.

    I dont think there is any generic droplet to run a select query directly against a table.
    However, there are various lookup droplets available that run on the repositories.
    Like /atg/targeting/RepositoryLookup droplet. you can run it for specific id or for all.
    You might want to have a look at it in documentation of how exactly to use it.
    Thanks

  • BIDS 2008 DataFlow viewer not showing even though the sql statement returns data

    Have a dataflow and trying to see why no rows are being written to the destination.  I popped a viewer on the connection, but it doesnt show up when I run.  What can I check?
    The DataFlow source runs a sql statement and it runs fine and returns a result.

    Why would that be if I can execute the sql statement that is being used in the OLEDB Source, and I get a result, yet the destination gets no rows afterwards.  Even executing the Dataflow task by itself, no rows are written.
    I do have a script task that modifies the connection before the dataflow, but this was working fine yesterday :)
    Even so, if there was a problem with the connection, I would get an error.  There no no errors, it just sees no rows and the dataviewer is never displayed.
    What the heck can I check?

  • How to process sql statements stored in a table

    I have a rule table that contain rule_type, rule_status and rule_condition. The rule condition is a sql statement. In a report I need to be able to expand this condtion based on the status selected. E.g When rule status is terminated the rule_condition is as below. When a user pick terminated status, I need to be able to go to the table and expand the sql statement. Another example is active status.
    RULE_STATUS TERMINATED
    SELECT leaseid
    FROM leatatt
    WHERE txtattid = 'LEAS END'
    and value = 'TERMINATED'
    RULE_STATUS ACTIVE
    SELECT leaseid
    FROM lease
    WHERE redoc_class = 'MASTER'
    AND TRUNC(SYSDATE) <=
    NVL(TRUNC(enddate),TRUNC(SYSDATE)+1)
    AND functional_status IN ('ACTIVE','OVERHOLD')
    Any suggestion will be appreciated.

    Please refer to
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:246014735810
    I am sure you would be twist this to bring it in to your use.
    <PRE>
    the proper way to do this is to NOT use a PLSQL table type but to use a SQL Object Type
    instead. It would look like this:
    [email protected]> create or replace type myScalarType as object
    2 ( x int,
    3 y date,
    4 z varchar2(25)
    5 )
    6 /
    Type created.
    [email protected]> create or replace type myTableType as table of myScalarType;
    2 /
    Type created.
    [email protected]> create or replace
    2 function demo_proc( p_start_row in number,
    3 p_end_row in number )
    4 return myTableType
    5 as
    6 l_data myTableType := myTableType();
    7 l_cnt number default 0;
    8 begin
    9 for x in ( select * from emp order by sal desc )
    10 loop
    11 l_cnt := l_cnt + 1;
    12 if ( l_cnt >= p_start_row )
    13 then
    14 l_data.extend;
    15 l_data(l_data.count) :=
    16 myScalarType( x.empno,
    17 x.hiredate,
    18 x.ename );
    19 end if;
    20 exit when l_cnt = p_end_row;
    21 end loop;
    22
    23 return l_data;
    24 end;
    25 /
    Function created.
    [email protected]> select *
    2 from the ( select cast( demo_proc(2,6) as mytableType )
    3 from dual ) a
    4 /
    X Y Z
    7788 09-DEC-82 SCOTT
    7902 03-DEC-81 FORD
    7566 02-APR-81 JONES
    7698 01-MAY-81 BLAKE
    7782 09-JUN-81 CLARK
    [email protected]>
    </PRE>

  • Log for all the sql statement executed

    Hi,
    I would like to know how to see the log for all the sql statement executed starting from connection to all the database related actions.
    Is it something that i need to set it up in the driver?
    I'm using Tomcat and JDBC driver.
    Please reply.
    Thanks,
    Anjana

    Make your own.
    Calendar cal = new GregorianCalendar();
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH) + 1;
    int day = cal.get(Calendar.DAY_OF_MONTH);
    //use calendar object to get other infos such as time of query
    //append your query string
    File f  =new File ("c:\\jakarta-tomcat-3.2.4\\webapps\\ASD\\LOGS\\log" + df.format(day) + df.format(month) + year + ".txt");
                   if (! f.exists())
                        f.createNewFile();
                   FileWriter fw = new FileWriter (f, true);
                   // append new log to end of file
                   fw.write(buf.toString());
                   fw.write("\n");
                   fw.flush();
                   fw.close();
              catch (IOException ioe)
                   System.out.println(ioe.toString());

  • Find all the sql statements that are executed in a database

    Hi
    I would like to get all the sql statements that have been executed till now on the database. Also, i need the session and user details who has executed the statement.
    I know this can be done after enabling auditing.
    I would like to get the details without enabling the auditing option.
    I am using oracle 9i and oracle 10g.
    Regards,
    Vamsi

    You can use {noformat}{noformat} tags to preserve the SQL format. Below is an example of how to use it.
    <place your code here>\When your do that your code may look like this.select
         substr(sid || ',' || serial#,0,15) sid,
         USERNAME,
         PROGRAM,
         MACHINE,
         OSUSER,
         TERMINAL,
         sql_text Query
    from
         v$sqltext,
         v$session
    where
         address=sql_address
         and hash_value=sql_hash_value
         and status='ACTIVE'
    order by LOGON_TIME,sid,piece
    This one is more readable to everyone.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • OpenSQLException - The SQL statement "INSERT INTO "KMC_SUB_RCPT"...

    Hallo,
    We have the problem that subscriptions cannot be sent. In defaultTrace I have found following entry:
    #1.5 #32B150008004002400001641000710B80004539FE52B4274#1217846116565#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#sap.com/irj#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Fatal##Plain###Cannot unsubscribe user. Context: ResourceContext: user=LI01736, creationTime=1217846116420, locale=de. User: LI01736. ID: 50cdd784-51ac-2810-2393-ea9709f50de3. Recipient: com.sapportals.wcm.util.channels.wcm.Recipient@ce9b7f70. Step: Executing SQL INSERT. . Trying to rollback transaction.#
    #1.5 #32B150008004002400001643000710B80004539FE52B989A#1217846116586#com.sap.sql.jdbc.common.StatementAnalyzerImpl#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Error#1#/System/Database/sql/jdbc/common#Java#com.sap.sql_0019##Exception of type com.sap.sql.log.OpenSQLException caught: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
    [EXCEPTION]
    #3#com.sap.sql.log.OpenSQLException#The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
    #com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.check(StatementAnalyzerImpl.java:38)
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:101)
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:87)
         at com.sap.sql.jdbc.common.CommonStatementImpl.executeUpdate(CommonStatementImpl.java:159)
         at com.sap.engine.services.dbpool.wrappers.StatementWrapper.executeUpdate(StatementWrapper.java:162)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL$SqlCommand.executeUpdate(SubscriptionsOpenSQL.java:3834)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL.unsubscribe(SubscriptionsOpenSQL.java:2127)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3226)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3205)
         at com.sapportals.wcm.repository.service.subscription.wcm.ActionInboxItemProducer.executeItemAction(ActionInboxItemProducer.java:222)
         at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemAction(ActionInboxService.java:610)
         at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemActions(ActionInboxService.java:1221)
         at com.sapportals.wcm.control.actioninbox.ActionInboxDetailsControl.onClick(ActionInboxDetailsControl.java:396)
    Any Idea?
    Regards,
    Gerhard

    Statement statement = connection.createStatement();
    //createing a statement object
    String query= "INSERT INTO table......"
    output.append("\nSending query:" + connection.nativeSQL(query));
    int result = statement.executeUpdate(query);//updates database wit record
    if (result==1)
    output.append("\ninsertation successfull");
    JOptionPane.showMessageDialog(null,"Insertation successfull ",
    JOptionPane.INFORMATION_MESSAGE);
    else
    output.append("\ninsertation unsuccessfull");
    JOptionPane.showMessageDialog(null,"Insertation unsuccessfull",
    JOptionPane.WARNING_MESSAGE);
    statement.close();
    have left out the trys and catches and some other bits and pieces that i dont think ud need its the bare bones but it might help or at least give u an idea. have used this code before to do something similar.

  • Sql statement in a table not accepting variable

    I have the following problem on 10.1.0.3.0 with varialbe in an execute immediate statement
    here is the code that I am using
    declare
    remote_data_link varchar2(25) := 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA VARCHAR2(40) := 'UDE_OLTP';
    l_last_process_date date := to_date(to_char(sysdate,'mm-dd-yyyy hh:mi:ss'),'mm-dd-yyyy hh:mi:ss') - 1;
    stmt varchar2(4000) := 'MERGE into applicant_adverseaction_info theTarget USING (select * from '||FROM_SCHEMA||'.applicant_adverseaction_info@'||remote_data_link||' where last_activity > :l_last_process_date ) theSource ON(theTarget.applicant_id = theSource.applicant_id) WHEN MATCHED THEN UPDATE SET theTarget.cb_used = theSource.cb_used, theTarget.cb_address = theSource.cb_address, theTarget.scoredmodel_id = theSource.scoredmodel_id, theTarget.last_activity = theSource.last_activity WHEN NOT MATCHED THEN INSERT(CB_USED, CB_ADDRESS, SCOREDMODEL_ID, APPLICANT_ID, LAST_ACTIVITY) values(theSource.cb_used, theSource.cb_address, theSource.scoredmodel_id, theSource.applicant_id, theSource.last_activity)';
    stmt2 varchar2(4000) := 'MERGE into edm_application theTarget USING (select * from '||from_schema||'.edm_application@'||remote_data_link||' where last_activity > :l_last_process_date) theSource ON (theTarget.edm_appl_id = theSource.edm_appl_id) WHEN MATCHED THEN UPDATE SET theTarget.APP_REF_KEY = theSource.APP_REF_KEY, theTarget.IMPORT_REF_KEY = theSource.IMPORT_REF_KEY, theTarget.LAST_ACTIVITY = theSource.LAST_ACTIVITY WHEN NOT MATCHED THEN INSERT (EDM_APPL_ID, APP_REF_KEY, IMPORT_REF_KEY, LAST_ACTIVITY) values(theSource.EDM_APPL_ID, theSource.APP_REF_KEY, theSource.IMPORT_REF_KEY, theSource.LAST_ACTIVITY)';
    v_error varchar2(4000);
    T_MERGE VARCHAR2(4000);
    stmt3 varchar2(4000);
    BEGIN
    select merge_sql
    INTO T_MERGE
    from transfertables
    where table_name= 'edm_application';
    remote_data_link:= 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA := 'UDE_OLTP';
    --DBMS_OUTPUT.PUT_LINE(SUBSTR(stmt2,1,200));
    --STMT2 := T_MERGE;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    EXECUTE IMMEDIATE stmt2 using l_last_process_date;
    --execute immediate stmt3 ;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    dbms_output.put_line(substr(stmt2,1,200));
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    V_ERROR := SQLCODE||' '||SQLERRM;
    v_ERROR := V_ERROR ||' '||SUBSTR(stmt2,1,200);
    DBMS_OUTPUT.PUT_LINE(V_ERROR);
    --dbms_output.put_line(substr(stmt2,1,200));
    END;
    This works perfectly
    but if I change it to get the same statement in a db table
    declare
    remote_data_link varchar2(25) := 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA VARCHAR2(40) := 'UDE_OLTP';
    l_last_process_date date := to_date(to_char(sysdate,'mm-dd-yyyy hh:mi:ss'),'mm-dd-yyyy hh:mi:ss') - 1;
    stmt varchar2(4000) := 'MERGE into applicant_adverseaction_info theTarget USING (select * from '||FROM_SCHEMA||'.applicant_adverseaction_info@'||remote_data_link||' where last_activity > :l_last_process_date ) theSource ON(theTarget.applicant_id = theSource.applicant_id) WHEN MATCHED THEN UPDATE SET theTarget.cb_used = theSource.cb_used, theTarget.cb_address = theSource.cb_address, theTarget.scoredmodel_id = theSource.scoredmodel_id, theTarget.last_activity = theSource.last_activity WHEN NOT MATCHED THEN INSERT(CB_USED, CB_ADDRESS, SCOREDMODEL_ID, APPLICANT_ID, LAST_ACTIVITY) values(theSource.cb_used, theSource.cb_address, theSource.scoredmodel_id, theSource.applicant_id, theSource.last_activity)';
    stmt2 varchar2(4000) := 'MERGE into edm_application theTarget USING (select * from '||from_schema||'.edm_application@'||remote_data_link||' where last_activity > :l_last_process_date) theSource ON (theTarget.edm_appl_id = theSource.edm_appl_id) WHEN MATCHED THEN UPDATE SET theTarget.APP_REF_KEY = theSource.APP_REF_KEY, theTarget.IMPORT_REF_KEY = theSource.IMPORT_REF_KEY, theTarget.LAST_ACTIVITY = theSource.LAST_ACTIVITY WHEN NOT MATCHED THEN INSERT (EDM_APPL_ID, APP_REF_KEY, IMPORT_REF_KEY, LAST_ACTIVITY) values(theSource.EDM_APPL_ID, theSource.APP_REF_KEY, theSource.IMPORT_REF_KEY, theSource.LAST_ACTIVITY)';
    v_error varchar2(4000);
    T_MERGE VARCHAR2(4000);
    stmt3 varchar2(4000);
    BEGIN
    select merge_sql
    INTO T_MERGE
    from transfertables
    where table_name= 'edm_application';
    remote_data_link:= 'UDE_DATATRANSFER_LINK';
    FROM_SCHEMA := 'UDE_OLTP';
    --DBMS_OUTPUT.PUT_LINE(SUBSTR(stmt2,1,200));
    STMT2 := T_MERGE;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    EXECUTE IMMEDIATE stmt2 using l_last_process_date;
    --execute immediate stmt3 ;
    dbms_output.put_line(from_schema||' '||remote_data_link||' '||l_last_process_date);
    dbms_output.put_line(substr(stmt2,1,200));
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    V_ERROR := SQLCODE||' '||SQLERRM;
    v_ERROR := V_ERROR ||' '||SUBSTR(stmt2,1,200);
    DBMS_OUTPUT.PUT_LINE(V_ERROR);
    --dbms_output.put_line(substr(stmt2,1,200));
    END;
    I get ora-00900 invalid sql statement
    can somebody explain why this happens
    Thanks

    I agree with jan and anthony. Your post is too long and ill-formatted. However here's my understanding of your problem (with examples though slightly different ones).
    1- I have a function that returns number of records in a any given table.
      1  CREATE OR REPLACE FUNCTION get_count(p_table varchar2)
      2     RETURN NUMBER IS
      3     v_cnt number;
      4  BEGIN
      5    EXECUTE IMMEDIATE('SELECT count(*) FROM '||p_table) INTO v_cnt;
      6    RETURN v_cnt;
      7* END;
    SQL> /
    Function created.
    SQL> SELECT get_count('emp')
      2  FROM dual
      3  /
    GET_COUNT('EMP')
                  14
    2- I decide to move the statement to a database table and recreate my function.
    SQL> CREATE TABLE test
      2  (stmt varchar2(2000))
      3  /
    Table created.
    SQL> INSERT INTO test
      2  VALUES('SELECT count(*) FROM p_table');
    1 row created.
    SQL> CREATE OR REPLACE FUNCTION get_count(p_table varchar2)
      2     RETURN NUMBER IS
      3     v_cnt number;
      4     v_stmt varchar2(4000);
      5  BEGIN
      6     SELECT stmt INTO v_stmt
      7     FROM test;
      8     EXECUTE IMMEDIATE(v_stmt) INTO v_cnt;
      9     RETURN v_cnt;
    10  END;
    11  /
    Function created.
    SQL> SELECT get_count('emp')
      2  FROM dual
      3  /
    SELECT get_count('emp')
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at "SCOTT.GET_COUNT", line 8
    ORA-06512: at line 1
    --p_table in the column is a string and has nothing to do with p_table parameter in the function. And since there's no p_table table in my schema function returns error on execution. I suppose this is what you mean by "sql statement in a table not accepting variable"
    3- I rectify the problem by recreating the function.
      1  CREATE OR REPLACE FUNCTION get_count(p_table varchar2)
      2     RETURN NUMBER IS
      3     v_cnt number;
      4     v_stmt varchar2(4000);
      5  BEGIN
      6     SELECT replace(stmt,'p_table',p_table) INTO v_stmt
      7     FROM test;
      8     EXECUTE IMMEDIATE(v_stmt) INTO v_cnt;
      9     RETURN v_cnt;
    10* END;
    SQL> /
    Function created.
    SQL> SELECT get_count('emp')
      2  FROM dual
      3  /
    GET_COUNT('EMP')
                  14
    Hope this gives you some idea.-----------------------
    Anwar

  • Error while executing the .sql file

    Hello,
    Every time when i execute the below plsql it's keep throwing the error message as show in below output, this happens even when i manually create the trigger before executing the .sql file of all the below statements, can you please correct me what i am doing wrong here. Thank you.
    DROP TABLE FCSDWH.REF_DATA_MASTER;
    CREATE TABLE FCSDWH.REF_DATA_MASTER
    REF_DATA_MASTER_ID                      NUMBER PRIMARY KEY,
    DESCRIPTION                                     VARCHAR2(255 CHAR),
    CREATE_ID                                       VARCHAR2(10 CHAR),
    CREATE_DT                                       DATE,
    LST_UPD_ID                                      VARCHAR2(10 CHAR),
    LST_UPD_DT                                      DATE,
    ACT_STRT_DT                                     DATE,
    ACT_END_DT                                      DATE
    TABLESPACE FCSDWH
    STORAGE(INITIAL 50K);
    DROP SEQUENCE FCSDWH.REF_DATA_MASTER_SEQ;
    CREATE SEQUENCE FCSDWH.REF_DATA_MASTER_SEQ START WITH 1 INCREMENT BY 1;
    DROP TRIGGER "FCSDWH.REF_DATA_MASTER_TRG";
    CREATE OR REPLACE TRIGGER FCSDWH.REF_DATA_MASTER_TRG
    BEFORE INSERT ON FCSDWH.REF_DATA_MASTER
    FOR EACH ROW
    BEGIN
    SELECT FCSDWH.REF_DATA_MASTER_SEQ.NEXTVAL INTO :NEW.REF_DATA_MASTER_ID FROM DUAL;
    END;
    /Output:
    SQL> @/home/smadala/REF_DATA_MASTER.SQL
    Table dropped.
    Table created.
    Sequence dropped.
    Sequence created.
    DROP TRIGGER "FCSDWH.REF_DATA_MASTER_TRG"
    ERROR at line 1:
    ORA-04080: trigger 'FCSDWH.REF_DATA_MASTER_TRG' does not exist
    Trigger created.
    SQL>

    The trigger is "attached" to the table so when you drop the table the trigger goes as well.
    John

  • 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

  • Toplink generate the SQL statement correctly but it does not return any row

    Hi
    I faced an strange problem when using Toplink as JPA provider. Following snippet shows how I create and execute a query using Toplink JPA:
    q = em.createQuery("SELECT B FROM Branch B WHERE B.street LIKE :street");
    q.setParameter("street", "'%a%'");
       List<Branch> l = q.getResultList();
      System.out.println("List Size: " + l.size());The SQL statement resulted by this query is as follow (according to the generated log file)
    SELECT ID, STREET FROM BRANCH WHERE (STREET LIKE CAST (? AS VARCHAR(32672) ))
      bind => [%a%]Problem is that List size is always 0, independent of what I provide as parameter. I tried and executed the generated SQL statement in the SQL manager and I got some tens of record as the result. The SQL statement i tested in the SQL manager is like:
    SELECT ID, STREET FROM BRANCH WHERE (STREET LIKE CAST ('%a%' AS VARCHAR(32672) ))Can someone please let me know what I am missing and how I can fix this problem?
    Thanks.

    Hi,
    Thank you for reply.
    All data are stored in lower case so, the case sensitivity is not a problem. I am wondering how the generated query works fine when I execute it in the sql manager but it return no result when it is executed by the JPA.
    Thanks for looking into my problem.

  • The SQL statement "SELECT * FROM "SDBAH"" contains the semantics error[s]:

    Hello all together,
    actually I try to implement an user interface for using BRTools from a J2EE Application.
    I created a datasource-alias "BRTOOLS" using netweaver administrator.
    inside the implementation i execute the following code:
    DataSource ds = (DataSource) ctx.lookup("jdbc/BRTOOLS");
    Connection con = ds.getConnection();
    String query = "select * from SDBAH;";
    Statement stmt = con.createStatement();
    try {
       ResultSet rs = stmt.executeQuery(query);
    As the result I get the following message:
    The SQL statement "SELECT * FROM "SDBAH"" contains the semantics error[s]: - 1:15 - the table or view >>SDBAH<< does not exist.
    Using SQLplus or dbconsole I can see and use the table SDBAH. The table scheme is "SAPSR3DB"which is the standard scheme for J2EE.
    If I try:
    select * from SAPSR3DB.SDBAH;
    I get the same result.
    What is wrong in my constellation?
    Thank you very much in advance.
    Greetings Stephan

    Dear Yordan,
    yes I did a restart of the whole system.
    If I do a wrong lookup:
    e.g:
    DataSource ds = (DataSource) ctx.lookup("jdbc/BRToolsFailure");
    where Alias  "BRToolsFailure" does not exist, I get
    Object not found in lookup of BRToolsFailure.
    So I think that the Alias of the default data source is right and visible.
    Next try:
    I use an already existing alias "ADS" in my code and get the same message:
    The SQL statement "SELECT * FROM "SDBAH"" contains the semantics error[s]: - 1:15 - the table or view >>SDBAH<< does not exist.
    If I extend the tablename with the scheme-name "SAPSR3DB" I get the following:
    The SQL statement "SELECT * FROM "SAPSR3DB"."SDBAH"" contains the semantics error[s]: - 1:24 - the table or view >>SDBAH<< does not exist
    When I use SQLPLUS SAPSR3DB/password and call:
    select * from SDBAH;
    I get a result like expected.
    Thanks a lot,
    Stephan

  • Why has the sql statement been extucted two times in shell script?

    I tried to test rac load balance using the following shell script on suse 10 + oracle 10g rac.
    oracle@SZDB:~> more load_balance.sh
    #!/bin/bash
    for i in {1..20}
    do
    echo $i
    sqlplus -S system/oracle@ORA10G <<EOF
    select instance_name from v\$instance;
    EOF
    sleep 1
    done
    exit 0After execute shell script, I got the follow result.
    oracle@SZDB:~> ./load_balance.sh
    1
    INSTANCE_NAME
    ora10g2
    INSTANCE_NAME
    ora10g2
    2
    INSTANCE_NAME
    ora10g1
    INSTANCE_NAME
    ora10g1
    3
    INSTANCE_NAME
    ora10g1
    INSTANCE_NAME
    ora10g1Seem the sql statement has been executed two times in each loop. If you feel free please help to have a look. Thanks in advance.
    Robinson

    You can end a SQL command in one of three ways:
    * with a semicolon (;)
    * with a slash (/) on a line by itself
    * with a blank line
    A semicolon (;) tells SQL*Plus that you want to run the current command that was entered. SQL*Plus processes the command and also stores the command in the SQL buffer.
    A blank line in a SQL statement or script tells SQL*Plus that you have finished entering the command, but do not want to run it yet, but it's stored the command on SQL Buffer.
    A slash (/) on a line by itself tells SQL*Plus that you wish to run the command stored on SQL buffer.

  • How to view the SQL statement generated during execution of the BW Query?

    Dear Experts,
    I am trying to retrieve data in a SAP BW Query from a Non-SAP system.
    I think if I am able to see the complete SQL statement that was generated when I executed the BW Query, I may be able to use it to retrieve the data.
    Do you know how and where I can see the SQL statement of a BW Query's SQL statement?
    I tried RSRT options to execute the Query but still could not find the SQL statement.
    Thanks in advance.
    Regards,
    Shunhui.

    hi
    goto rsrt
    give your query name
    select execute + debug option
    in the debug option under data manager check the check box "display SQL/BIA query
    selcet continue
    you can see the sql statement
    thanq

Maybe you are looking for

  • SUBMIT Rfitemar, field G/L Account

    Hi guys! I'm working with SUBMIT RFITEMAR, inside a loop sentence like this: loop at t_fbl5n into st_fbl5n CALL 'LIST_FREE_MEMORY'. SUBMIT rfitemar WITH dd_bukrs EQ st_fbl5n-bukrs                     WITH dd_hkont EQ st_fbl5n-hkont                   

  • My dvd drive won't open so I can insert a disc.  It has opened in the past by pushing the button on my mac

    I can't insert any dvd's because my dvd drive won't open when I push the open key.  It has always worked in the past.  Any suggestions on how to fix this?

  • Permissions keep changing on a NAS volume?

    I have an 8TB NAS with a few shares set up.  Randomly, a padlock appeared on the lower left corner of one of the shares' icon (my media share).  I can still access the share fine.  If I SSH into the NAS via Cyberduck, the permissions for the media sh

  • Problem in setting focus in JTable

    Hi, In my application I am using JTable with a customized table model. The table has two columns. First column has jcombobox as its editor and the second column has the customized editor developed by me. This particular table appears in a wizard. Whe

  • Cisco Call Manager 10

    Anyone know where I can find free training for Cisco Call Manager 10? Cheers