Problem returning variables from dynamic SQL/PLSQL

Hi, I have a problem I am trying to solve using a very short piece of dynamic SQL or PLSQL but I am having problems getting the variable values out of the dynamic block.
I have 16 counters whose names are made up of three variable parts - 'scheme', 'contributory category' and 'employment category'
The 'scheme' can be either 'no1', 'no2', 'off', 'cg' or 'amc'
The 'contributory category' can be either 'cont' or 'noncont'
The 'employment category' can be either 'ft' or 'pt'
(There are only 16 because only 16 combinations are possible)
For example the total counter name could be 'v_cg_noncont_ft_count'
I have created a variable by concatenating the various elements called v_incr_count_name which holds the name of the counter I want to increment.
I am running this whole thing within an anonymous PLSQL block so I cannot use global variables meaning that my variables are not visible within a dynamic PLSQL block.
I believe this means that either I need to bind the variables within a PLSQL block or use a SELECT FROM INTO SQL block.
I have tried a few solutions with no luck such as the following PLSQL:
v_incr_count := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
sql_stmt := 'BEGIN :a := :a + 1; END;';
EXECUTE IMMEDIATE sql_stmt USING v_incr_count_name;
Unfortunately I am getting the 'IN bind variable bound to an OUT position' error which I believe is because it is trying to return a value into v_incr_count_name which has been defined by default as an IN variable. The problem is that I need to store the returned value into the variable whose name is stored in v_incr_count_name.
Another solution I tried is:
v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
sql_stmt := 'SELECT '||v_incr_count_name||' + 1 FROM DUAL';
EXECUTE IMMEDIATE sql_stmt INTO v_return;
This solution gives me an 'Invalid colum error'
Any help would be greatly appreciated
Cheers, Dan

Repost:
Problem with variables in dynamic SQL/PLSQL

Similar Messages

  • Problem with variables in dynamic SQL/PLSQL

    Hi, I have a problem I am trying to solve using a very short piece of dynamic SQL/PLSQL but I am having problems getting the variable values out of the dynamic block.
    I need to increment a counter which could be any one of 16 counters I am using and I want to avoid using nested IF statements.
    The variable to be incremented is made up of the 'scheme', the 'contributory category' and the 'employment category' (although not every combination is valid)
    The 'scheme' can be either 'no1', 'no2', 'off', 'cg' or 'amc'
    The 'contributory category' can be either 'cont' or 'noncont'
    The 'employment category' can be either 'ft' or 'pt'
    For example the total variable name could be 'v_cg_noncont_ft_count'
    I have created a variable by concatenating the various elements called v_incr_count_name which holds the name of the variable I want to increment.
    I am running this within an anonymous PLSQL block so I cannot use global variables meaning that my variables are not visible within a dynamic PLSQL block.
    As a result I think I will need to use bind variables with a PLSQL block or a SELECT FROM INTO SQL string
    I have tried various solutions including the following PLSQL solution:
    v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'BEGIN :a := :a + 1; END;';
    EXECUTE IMMEDIATE sql_stmt USING v_incr_count_name;
    Unfortunately I am getting the 'IN bind variable bound to an OUT position' error which I suppose makes sense as I am trying to change the value of a variable in the main PLSQL block from within the dynamic block.
    Another (SQL) solution I tried was:
    v_incr_count_name := 'v_'||v_scheme||'_'||v_cont_cat||'_'||v_emp_cat||'_count';
    sql_stmt := 'SELECT '||v_incr_count_name||' + 1 FROM DUAL';
    EXECUTE IMMEDIATE sql_stmt INTO v_return;
    While this executes and returns the incremented value into v_return, I am still left unable to copy the returned value into the variable whose name is stored in v_incr_count_name
    Any help appreciated
    Cheers, Dan

    this shows the syntax for the using clause
    declare
    a number := 1;
    b number := null;
    v varchar2(10) := 'A';
    begin
    execute immediate 'begin :v1 := :v1 + 1; end;' using in out a;
    dbms_output.put_line(a);
    end;
    /but what you want cannot be done
    SQL> declare
      2  a number := 1;
      3  b number := null;
      4  v varchar2(10) := 'A';
      5  begin
      6  execute immediate 'begin '||v||' := :v1 + 1; end;' using in out a;
      7  dbms_output.put_line(a);
      8  end;
      9  /
    declare
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'A' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ORA-06512: at line 6the variable "V" contains the name of the desired output variable ("A"). this errors because "A" is not defined within the scope of the dynamic sql.
    "into the variable whose name is stored in v_incr_count_name"
    pl/sql does not support dereferencing variables, so you can't do it.

  • OUTPUT variable from dynamic query with openquery

    I am working on a dynamic sql statement that uses openquery to retrieve some columns from an Oracle source.  My goal is to take the variables from the select openquery statement and store them, so they can be passed to an insert statement.  I am
    having no problem getting the emplid but the first_name and last_name are NULL
    Any help would be appreciated.
    DECLARE @sql nvarchar(max)
    declare @emplid varchar(11)
    declare @first_name varchar(50)
    set @emplid = '1234'
    BEGIN
    SET NOCOUNT ON;
    SET @sql = 'select distinct emplid,
    First_name ,
    Last_name
    from openquery(DWHCRPT, ''select p.emplid, p.First_nAME, p.last_nAME
    FROM PS_OCC_BIODEMO_S P
    where P.emplid = ''''' + @emplid + ''''''') A';
    EXEC SP_executesql @SQL, N'@emplid VARCHAR (11), @first_name varchar(50) OUTPUT', @emplid, @first_name = first_name;
    select @emplid, @first_name --currently returning NULL
    END

    Patrick's query would work, but it would drag the entire table over to SQL Server, which could be expensive.
    The code you posted have several flaws. You are not assigning @first_name, and you have failed to provide OUTPUT for the actual parameter. Also, the DISTINCT looks out of place. Isn't emplid a key?
    This should work better:
    SET @sql = 'select @first_name = First_name 
            from openquery(DWHCRPT, ''select p.First_nAME, p.last_nAME
                                          FROM PS_OCC_BIODEMO_S P
                       where P.emplid = ''''' + @emplid + ''''''') A'; 
       EXEC SP_executesql @SQL, N'@emplid VARCHAR (11), @first_name varchar(50) OUTPUT', @emplid, @first_name = @first_name OUTPUT;
    select @emplid, @first_name --currently returning NULL
    Also, look at this link for some tips how to write queries with OPENQUERY without going insane over all nested quotes:
    http://www.sommarskog.se/dynamic_sql.html#OPENQUERY
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to use the column names generated from Dynamic SQL

    Hi,
    I have a problem with Dynamic SQL.
    I have written an SQL which will dynamically generate the Select statement with from and where clause in it.
    But that select statement when executed will get me hundreds of rows and i want to insert each row separately into one more table.
    For that i have used a ref cursor to open and insert the table.
    In the select list the column names will also be as follows: COLUMN1, COLUMN2, COLUMN3,....COLUMNn
    Please find below the sample code:
    TYPE ref_csr IS REF CURSOR;
    insert_csr ref_csr;
    v_select VARCHAR2 (4000) := NULL;
    v_table VARCHAR2 (4000) := NULL;
    v_where VARCHAR2 (4000) := NULL;
    v_ins_tab VARCHAR2 (4000) := NULL;
    v_insert VARCHAR2 (4000) := NULL;
    v_ins_query VARCHAR2 (4000) := NULL;
    OPEN insert_csr FOR CASE
    WHEN v_where IS NOT NULL
    THEN 'SELECT '
    || v_select
    || ' FROM '
    || v_table
    || v_where
    || ';'
    ELSE 'SELECT ' || v_select || ' FROM ' || v_table || ';'
    END;
    LOOP
    v_ins_query :=
    'INSERT INTO '
    || v_ins_tab
    || '('
    || v_insert
    || ') VALUES ('
    || How to fetch the column names here
    || ');';
    EXECUTE IMMEDIATE v_ins_query;
    END LOOP;
    Please help me out with the above problem.
    Edited by: kumar0828 on Feb 7, 2013 10:40 PM
    Edited by: kumar0828 on Feb 7, 2013 10:42 PM

    >
    I Built the statement as required but i need the column list because the first column value of each row should be inserted into one more table.
    So i was asking how to fetch the column list in a ref cursor so that value can be inserted in one more table.
    >
    Then add a RETURNING INTO clause to the query to have Oracle return the first column values into a collection.
    See the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/returninginto_clause.htm#sthref2307

  • Including variable into dynamic sql

    Hi,
    Ive problems including v_end_month variable.
    which is the correct way to include v_end_month in the next dynamic sql expression?
    v_end_month DATE;
    v_max_day DATE;
    EXECUTE IMMEDIATE 'SELECT max(date) FROM table1 WHERE trunc(date,''mm'') = '''||v_end_month||'' INTO v_max_day;thanks in advanced..

    what is the way to know if I need the statement to be dynamic in the first place?Are you building the SQL string with, for example, a variable table name?
    More generally, is there any part of the statement that's not known at runtime?
    If the answer's no, then you don't need dynamic SQL, just use :
    SELECT max(dt)
    INTO v_max_day
    FROM table1
    WHERE trunc(dt, 'MM') = v_end_month
    ;

  • Invalid table name when pass in the table name as variable in dynamic sql

    Hi,
    I need to create a stored procedure which will return a list of data to my java application like the following.
    first, select the table name from the first table.
    For example : SELECT T_NAME FROM MDR_SMSTABLES
    second, select the data from the table which returned by first select statement
    For example : SELECT * FROM T_NAME.
    I use dynamic sql with cursor to select the data. But it returns "java.sql.SQLException: ORA-00903: invalid table name"
    I fetch the table name to varchar2. I think this might the cause it returns me the this error. But i don't know what type should i put for the table name other then varchar2.
    val2 VARCHAR2(200);
    OPEN cv FOR
    SELECT T_NAME FROM MDR_SMSTABLES WHERE T_DATE=d_dt_sent;
    FETCH cv INTO val2;
    WHILE cv%FOUND
    LOOP
    OPEN refcur FOR
    'SELECT * FROM :t WHERE MID = :m' USING val2, msg_id;
    EXIT WHEN refcur IS NOT NULL;
    FETCH cv INTO val2;
    END LOOP;
    As my stored procedure is quite long, so i just paste some of the code here. Hope the information is enough. Can anyone please help?
    Thanks

    DECLARE
    val2 VARCHAR2 (200);
    cv sys_refcursor;
    refcur sys_refcursor;
    BEGIN
    OPEN cv FOR
    SELECT table_name
    FROM user_tables
    WHERE table_name IN ('EMP', 'DEPT');
    FETCH cv INTO val2;
    WHILE cv%FOUND
    LOOP
    OPEN refcur FOR 'SELECT * FROM '||val2;
    EXIT WHEN refcur IS NOT NULL;
    FETCH cv INTO val2;
    END LOOP;
    END;

  • Unknow number of binding variables in Dynamic SQL

    I have to use a dynamic sql and binding variables. The problem is the number of binding variable varies due to the form input.
    EX.
    if ( something is not null ) then
    query := query || ' and column = :column';
    end if;
    if ( something_else is not null ) then
    query := query || ' and another_column = :another_column';
    end if;
    When I use in my USING clause, I don't know which of the four combinations of column/another_column I could be
    open query;
    open query using A,B;
    open query using A;
    open query using B;
    How can I solve this problem?
    Thanks a lot!

    Always with NVL:
    query := query || ' AND column = NVL(:column,column ) AND another_column = NVL(:another_column,another_column)';Invoke:
    DECLARE
      a_null CHAR(1); -- set to NULL automatically at run time
    BEGIN
      --open query
      open query using (a_null,a_null)
      --open query using A,B
      open query using A,B;
      --open query using A
      open query using A,a_null;
      --open query using B
      open query using a_null ,B;
    END;
    /Edited by: jortri on 04-dic-2008 18:34

  • Compare character variable in dynamic sql

    hi all
    i have a requirment in which i'll be using a dynamic sql:
    sql_string :='select * from temp_table where emp_name='||v_name;
    execute immediate ;
    i'm getting this error
    ORA-06502: PL/SQL: numeric or value error
    this is becouse v_name is character variable and we have to write
    select * from temp_table where emp_name='joe';
    can any one plz help me out..

    More correctly you should use bind variables (if you really really have to do dynamic SQL in the first place)...
    sql_string :='select * from temp_table where emp_name=:n;
    execute immediate sql_string using v_name;This allows the optimiser to re-use the execution plan rather than hard-parsing the query every time.
    However this still isn't right because within PL/SQL you will need to be selecting your result INTO something e.g.
    sql_string :='select * from temp_table where emp_name=:n;
    execute immediate sql_string into v_data using v_name;v_data will be a variable declared suitably to accept whatever data is being selected in the query.

  • DB adapter not returning return variable from database function

    Hi,
    We are calling a function using db adapter from our BPEL Process. It worked fine in 10.1.3.3.
    after we migrated to 10.1.3.4 MLR# 8 , we are not able to see the return variable which function is returing.
    Function is working fine when executed standalone. Its returing the variable. But we are not able to see that variable in bpel process invoke response variable. This is causing issue.
    Any idea what causing the issue.
    Thanks

    Check your XSD to see if it is qualified (elementFormDefault="qualified") or unqualified. The XSDs were unqualified in 10.1.3.3. They became qualified in 10.1.3.4. If you have an unqualified XSD and you're using a 10.1.3.4 runtime you will likely have namespace issues that cause problems with the generated XML. The solution is to regenerate your XSD so that it becomes qualified.

  • Return rows from pl-sql record type

    We have a requirement to create function which returns cursor to java application. This cursor will have data from pl-sql record type.
    Tried with pipelined function. I have written code below.
    CREATE or replace PACKAGE test_pkg IS
        TYPE tp_rec IS RECORD(tt_id INTEGER,tt_text VARCHAR2(40));
        TYPE obj_tp_recs IS TABLE OF tp_rec;
        TYPE obj_tp_recs1 IS TABLE OF tp_rec;
        FUNCTION test_func RETURN tp_rec;
        function type_out return obj_tp_recs1 PIPELINED;
        PROCEDURE test_type (result out sys_refcursor);
    END;
    CREATE OR REPLACE PACKAGE BODY OMS.test_pkg IS
        FUNCTION test_func RETURN tp_rec
        AS
           currec tp_rec;
        BEGIN
           currec.tt_id := 1;
           currec.tt_text := 'test1';
        END;
         FUNCTION type_out RETURN obj_tp_recs1 PIPELINED
             AS
           currec1 test_pkg.tp_rec;
          begin
                    currec1 := test_pkg.test_func;
                    PIPE ROW(currec1);
                    dbms_output.put_line(currec1.tt_id);
                end;
        PROCEDURE test_type (result out sys_refcursor)
        AS   
        BEGIN
                  OPEN RESULT
                  FOR SELECT * FROM TABLE(test_pkg.type_out());
        END;
    END;
    SQL> VARIABLE x REFCURSOR
    SQL> exec test_pkg.test_type(:x);
    PL/SQL procedure successfully completed.
    SQL> print xThis code returns no data found exeception from function. How to achieve result 1 and test1 from above code?
    Thanks in advance

    SQL> VARIABLE x REFCURSOR
    SQL> exec test_pkg.test_type(:x);
    PL/SQL procedure successfully completed.
    SQL> print x
    ERROR:
    ORA-06503: PL/SQL: Function returned without value
    ORA-06512: at "SCOTT.TEST_PKG", line 8
    ORA-06512: at "SCOTT.TEST_PKG", line 14
    no rows selectedIf you look at test_func body it is missing return statement. Now:
    SQL> CREATE OR REPLACE PACKAGE BODY test_pkg IS
      2      FUNCTION test_func RETURN tp_rec
      3      AS
      4         currec tp_rec;
      5      BEGIN
      6         currec.tt_id := 1;
      7         currec.tt_text := 'test1';
      8         RETURN currec;
      9      END;
    10     
    11       FUNCTION type_out RETURN obj_tp_recs1 PIPELINED
    12       AS
    13         currec1 test_pkg.tp_rec;
    14        begin
    15          currec1 := test_pkg.test_func;
    16          PIPE ROW(currec1);
    17          dbms_output.put_line(currec1.tt_id);
    18          end;
    19  
    20      PROCEDURE test_type (result out sys_refcursor)
    21      AS   
    22      BEGIN
    23        OPEN RESULT
    24        FOR SELECT * FROM TABLE(test_pkg.type_out());
    25       
    26      END;
    27  END;
    28  /
    Package body created.
    SQL> exec test_pkg.test_type(:x);
    PL/SQL procedure successfully completed.
    SQL> print x
         TT_ID TT_TEXT
             1 test1
    SQL> SY.

  • Need to get os variable from PL/SQL

    Hi,
    I have a small problem, I need to get some os variable for example disc space left on disc, from pl/sql i have heard that this should be possible to via JAVA. Does anyone have any example to achive this?
    Thanks.
    Lars

    Here is one way to call java function ->
    Connect Sys,
    satyaki>set serveroutput  on
    satyaki>exec dbms_java.grant_permission('HR','SYS:java.lang.RuntimePermission','writeFileDescriptor','');
    PL/SQL procedure successfully completed.
    satyaki>exec dbms_java.grant_permission('HR','SYS:java.lang.RuntimePermission','readFileDescriptor','');
    PL/SQL procedure successfully completed.
    satyaki>exec dbms_java.grant_permission('HR','SYS:java.io.FilePermission','E:\OracleRND\*.*','read,write,execute,delete');
    PL/SQL procedure successfully completed.
    Connect HR,
    satyaki>create or replace and compile java source named "Print_Hello"
      2     as
      3       import java.io.*;
      4       public class Print_Hello
      5         {
      6            public static void dislay()
      7              {
      8                 System.out.println("Hello World...... In Java Through Oracle....... ");
      9              }
    10         };
    11  /
    Java created.
    satyaki>
    satyaki>
    satyaki>create or replace procedure java_print
      2     as
      3       language java
      4       name 'Print_Hello.dislay()';
      5  /
    Procedure created.
    satyaki>call dbms_java.set_output(1000000);
    Call completed.
    satyaki>
    satyaki>
    satyaki>set serveroutput on size 1000000;
    satyaki>
    satyaki>exec java_print;
    Hello World...... In Java Through Oracle.......
    PL/SQL procedure successfully completed.Now, you have to prepare your code accordingly.
    Regards.
    Satyaki De.

  • Problem accessing variables from java file to JSP page

    Hello Everyone,
    I have small problem accessing my method variables from my java bean file to a JSP page. can some please take a look and tell me why I can't populate my JSP page, I've been trying all day to get this done!!!
    This is my Java file
    package dev;
    import java.io.*;
    import java.util.*;
    public class RoundDetail2
    public String string_gameID;
    public int string_card1;
    public String readDetail_topLayer;
    public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
    public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
    public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
    public RoundDetail2() throws FileNotFoundException
    DataInputStream inFile=
                 new DataInputStream(
                    new BufferedInputStream(
                   new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
    try { 
                 while((readDetail_topLayer = inFile.readLine()) != null)
              StringTokenizer tokenizer_topLayer = new StringTokenizer(readDetail_topLayer,"\t", true);
                   while  (tokenizer_topLayer.hasMoreTokens())
                        string_gameID = tokenizer_topLayer.nextToken();
         catch(IOException e)
                    System.out.println(e.getMessage());
         Thanks KT

    ......How are you declaring the class in your JSP? ... are you instantiating it as a bean using the useBean tag, or just instantiating it in your code like normal.
    Maybe you could post the relevant JSP code too?
    Hello again,
    Only the last string is populating after the file has be tokenized. What I'll like to accomplish is passing the very first string in the file. I did not get too far in the JSP file setup because the code is still in it's testing stage, but any help will be highly appreciated.
    Here is the JSP code
    <%@page import="dev.*" %>
    <%@page session="true" language="java" import="java.io.*" %>
    <jsp:useBean id="wagerhist" scope="request" class="dev.RoundDetail2" />
    <html>
    <head>
    <title>Round Detail</title>
    <body>
      <table width="530" bordercolor="#000000" valign="top">
        <tr>
              <td align="left"  width="19%">Game ID<%=wagerhist.string_gameID%></td>
              <td align="left"  width="30%">  </td>
              <td align="left"  width="20%">card1</td>
              <td align="left"  width="31%">  </td>
            </tr>
      </table>
    </body>
    </html>

  • Creating static sql from dynamic sql

    HI ,
    I have a dynamic sql and  I have to convert it into a static sql .
    this query is somehow having a special case which states that if the values of one parameter @bounce_type is D then it appends some more conditions(column conditions) on this query .
    I want to know a way to convert this kind of SQL to a static sql .
    I want a static code for the code where the condition is as mentioned below
    for the where clause where @bounce_type='D'
    if @bounce_type is not null and @bounce_type = 'D'
    begin
    print @bounce_type
    set @WhereClause = @WhereClause + ' and per.event_type_id=4 and per.aspen_action_detail_id not in
    (select
    aspen_action_detail_id
    from
    program.email_response pers with (readuncommitted)
    inner join action.action ac with(nolock,readuncommitted) on
    pers.action_id = ac.action_id
    where
    pers.dealer_id in( ' + cast(@dealer_did as varchar(10)) + ' ) and
    pers.aspen_action_dt between ''' + convert(varchar(10),@from_date,101)+''' ' + 'and ''' + convert(varchar(10),@to_date,101) + ''' and
    pers.program_type_id in (4,5) and
    pers.event_type_id=1 and
    pers.is_enabled=1) and aa.program_group<>''Unknown'''
    I was able to convert almost all of the code but the code mentioned above.

    Perhaps this one
    if @bounce_type is not null and @bounce_type = 'D' 
    begin
    print @bounce_type
    SELECT * FROM tbl WHERE ... and per.event_type_id=4 and per.aspen_action_detail_id not in
    (select
    aspen_action_detail_id
    from 
    program.email_response pers with (readuncommitted)
    inner join action.action ac with(nolock,readuncommitted) on
    pers.action_id = ac.action_id  
    where 
    pers.dealer_id in(  cast(@dealer_did as varchar(10)))  and 
    pers.aspen_action_dt between  convert(varchar(10),@from_date,101) and 
    convert(varchar(10),@to_date,101)  and 
    pers.program_type_id in (4,5)
    and
    pers.event_type_id=1
    and
    pers.is_enabled=1) and aa.program_group<>'Unknown' 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Newbie: Return variable from class?

    I'm calling a class to verify some data. The verification is quite complicated so the class will use a JFrame to make things clearer and will popup some additional dialogs. What I can't work out is the syntax for returning a variable from the class.
    I'm using the constructor to build and show the JFrame with the data to be verified and then triggering off a JButton to start the verification. If all is OK then the class would return a result.
    What I would like is to call either the Constructor or a Method in the class to show the JFrame, and to get that to return a value to me when a JButton is clicked. Does anyone have any code samples of something like this, or could point me in the right direction? It feels messed up right now.

    The simplest way is to use JDialog with setModal(true). Write your subclass of it and include a result field, typically a boolean that determines whether you exited via "OK" or "Cancel". The handlers for the buttons set this field appropriately, then you do "show" on the dialog (which waits until one of the button handlers calls "dispose" on the dialog), then test the flag.
    public class MyDialog extends JDialog {
           boolean resultOk;
           JButton okButton, cancelButton;
         public  MyDialog(Frame parent) {
             super(parent, "Validate dialog", true);
           okButton = new JButton("OK");
           okButton.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                   if(formIsValid()) {
                         resultOk = true;
                         dispose();
          cancelButton = new JButton("Cancel");
          cancelButton.addActionListner(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  resultOK = false;
                 dispose();
         private boolean formIsValid() {
            .... validation
        MyDialog dlg = new MyDialog(parentFrame);
        dlg.show();
         if(dlg.resultOK)  { // ok button selected
           ...

  • Bind variables and Dynamic sql

    I have this function which works only when i'm not passing bind variables. The moment i add bind variables it is not able to execute the function.
    Oracle Db Version: 8.1
    Thanks
    Source Code
    FUNCTION TestFunction( In_Test_id in Number,
    In_Asof in Date )
    Return ScoreType
    IS
    LvScore ABC.LV_SCORE.SCORE%TYPE;
    DVScore ABC.LV_SCORE.SCORE%TYPE;
    Begin
    EXECUTE IMMEDIATE
    'SELECT SCORE,DVSCORE
    FROM
    SELECT SCORE,DVSCORE
    DENSE_RANK() OVER (PARTITION BY TEST_ID ORDER BY ASOF_DT DESC) AS score_RANK
    FROM ABC.LV_SCORE
    WHERE TEST_ID = :x
    AND ASOF_DT <= :y
    ) WHERE score_RANK = 1'
    INTO LvScore,DVScore
    USING In_tEST_ID,In_Asof;
    Return ScoreType( LvScore,
    DVScore);
    End;

    It just keeps on executing for sometime and then disconnects itself from database What was the indication that told you that it disconnected? Was there a visible indication of this disconnect?
    Did you get ORA-03113?
    ===========================================
    ORA-03113: end-of-file on communication channel
    Cause: The connection between Client and Server process was broken.
    Action: There was a communication error that requires further investigation. First, check for network problems and review the SQL*Net setup. Also, look in the alert.log file for any errors. Finally, test to see whether the server process is dead and whether a trace file was generated at failure time.

Maybe you are looking for

  • Multiple-record form

    HI Everybody, Could anyone be so kind to assist me in the following problem? I have built a master-detail form with several records displayed. Screen items are Read/Write, Read-only and text for domains in popup-lists (these will be populated at the

  • LSMW data Reading Error

    HI, In the LSMW process i am getting the below error while doing 9th step Reading data. Unable to write to file 'E:\Z1XK01_ZXK01_ZXK01.lsmw.read' Message no. /SAPDMC/LSMW804 Rgds Mani

  • How to find out memory occupied by a table and a user?

    I want to find out how much memory space is occupied by a table and I also wants to know how much data, a user is using. Eg: Consider Emp table of 8 columns and 14 rows. I need memory occupied by Emp table. Suppose consider "Scott" user is created 4

  • How to use CBitmap as CNiPicture

    I am programming with CNiGraph and would like to use a manipulated bitmap as image for Annotation. I am having troubles to transform the bitmap to CNiPicture, any ideas?

  • What causes the ORG_ID to be null sometimes in RA_BATCH_SOURCES_ALL?

    I know batch_source_id is the pk but is there a way to link back to the correct org_id on RA_BATCH_SOURCES_ALL if it's null? Thanks, Chad