EXEC_SQL.PARSE

I wrote a very simple program unit in my form
v_actual_cursor :=
'SELECT * from dual';
begin
EXEC_SQL.PARSE(cursor_number, v_Actual_cursor,exec_sql.V7);
exception when others
     then      erm :=sqlerrm;
     err :=sqlcode;
     insert into xx_temp3 values(erm,err,1);
     commit;
end;      
This gives me values 306500: non-ORACLE exception, -306500, 1 in the table xx_temp3...
What can be the problem ??
Please let me know
Thanks
Prash

Thanks
I was missing
cursor_number := Exec_SQL.Open_cursor;
and also had the datatypes mis-matched, I was sending Varchar to a Number.
Thanks a bunch.
Also this sample dynamic_sql form did not open using forms 6i. I luckly had 10g on my system.

Similar Messages

  • Exec_Sql.Parse Hang

    Hi,
    I have problem with Sql statement when i try to parse the following statement ..............Why?
    V_Sql := ' Select Group_Name '||
         ' From Nvs_Users_Vs_Groups_Vw '||
         ' Where RowNum = 1 '||
         ' And Upper(Usr_Name) = '||Upper(User);
    Exec_Sql.Parse (V_Connection_Id,V_Cursor,V_Sql,Exec_sql.V7);

    As explained before the exec_sql package is not provided by Oracle Corporation.A gut feeling tells me OP means one the common built-in packages for Oracle Forms Developer (Pages 45). ;)
    So for OP: better to post the question in the Forms forum.

  • How can i pass input date parameter in where condition in exec_sql.parse

    EXEC_SQL.PARSE(source_connid, source_cursor,'SELECT substr(empid,3,6) ,
    attdate ,
    to_char(intime1,''HH24MI'') ,
    nvl(to_char(outtime2,''HH24MI''),nvl(to_char(intime2,''hh24mi''),nvl(to_char(outtime1,''hh24mi''),null))) ,
    ''G'' ,
    null ,
    null ,
    55
    FROM ' || source_table||'
    WHERE attdate = '||:control_main.input_dt);
    when i gave this input_dt the output is zero.
    without this where condition i am getting records.
    its urgent,please help me in this.
    Edited by: saru on Jan 12, 2009 2:06 AM
    Edited by: saru on Jan 12, 2009 2:53 AM

    I guess you have a problem with your formats...
    try this:
    [...]WHERE attdate = to_date('''||to_char(:control_main.input_dt,'dd.mm.yyyy')||''', ''dd.mm.yyyy'')[...]regards

  • Help required in Exec_Sql Package

    Hi,
    Plz help me in this program unit
    <PRE>
    BEGIN -- obtain the default connection and check that it is valid
         connection_id := EXEC_SQL.DEFAULT_CONNECTION;
         bIsConnected := EXEC_SQL.IS_CONNECTED;
         IF bIsConnected = FALSE THEN
              P_Alert('No primary connection. Please connect before retrying.');
         END IF; --
         cursorID := EXEC_SQL.OPEN_CURSOR;
         sqlstr := 'select emp_no from Hr_Employee';
         EXEC_SQL.PARSE(cursorID, sqlstr, exec_sql.V7);
    --     EXEC_SQL.DEFINE_COLUMN(cursorID,1,V_Emp_Id);
         nIgn := EXEC_SQL.EXECUTE(cursorID);
         LOOP
              IF (EXEC_SQL.FETCH_ROWS(cursorID) > 0) and i <= 5 THEN
                        EXEC_SQL.COLUMN_VALUE(cursorID, 1, V_EMP_ID);
                        P_ALERT(V_EMP_ID);
              ELSE
              RAISE FORM_TRIGGER_FAILURE;
              END IF;
         END LOOP;
         EXEC_SQL.CLOSE_CURSOR(cursorID);
         EXEC_SQL.CLOSE_CONNECTION;
    End </PRE>
    The Problem is it is raising the exception. It is not displaying the emp_id.
    the other one is with "EXEC_SQL.DEFINE_COLUMN(cursorID,1,V_Emp_Id);
    " I'm facing the error too many declaration with this statement.
    Thanks in advance.
    Regards,
    Alok

    Hello,
    <p>Have you read this article?. It contains code that queries the EMP table with the EXEC_SQL package.</p>
    Francois

  • Exec_sql package is not performing an update....

    Hello everybody, i'm working on oracle forms 10g R2, i used the exec_sql built in package, my problem is that the update statement is not performed....
    here is the code:
    declare
    connection_id EXEC_SQL.CONNTYPE;     
    cursorID EXEC_SQL.CURSTYPE;
    sqlstr varchar2(1000):= 'update test_connect_by set parent=10450 where parent=10452';
    nRes number;
    begin
         connection_id := EXEC_SQL.OPEN_CONNECTION('hr/admin@db10g');
         cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
         EXEC_SQL.PARSE(connection_id, cursorID, sqlstr);
         nRes := EXEC_SQL.EXECUTE(connection_id,cursorID);
         EXEC_SQL.CLOSE_CURSOR(connection_id, cursorID);
    EXEC_SQL.CLOSE_CONNECTION(connection_id);
         message('row(s) updated '|| to_char(nRes));
    end;
    the messahe give me rows updated is 0 why????
    i check the database there is a record where parent value=10452......
    thank you....

    Your code worked for me. All I changed was the login string, table name and column name. In my test, it reported:
    row(s) updated 2

  • Troubles with using twice exec_sql in a procedure

    Then I've written a procedure (1), using exec_sql.execute, that executes an SQL string, given the number of columns.
    Then, I've written a procedure (2), using exec_sql.describe_column, that identifies the columns in the result of an SQL string.
    Both of them work.
    So I tried to merge them, so I shouldn't need to know how many columns I have to extract in the procedure (2), but, after executing the "(1)" part, an exception (ORA-306500: non-Oracle exception) is thrown when "res := exec_sql.execute(cursID)" is executed.
    Excluding exclusively one of the two parts with /* and */, I see that each part, stand alone from another, works!
    I use the same cursor (exec_sql.curstype) for both parts. I've also tried to use two different cursors, closing the former before opening the latter, but the results don't change.
    Where is the trouble?
    Thanks in advance.

    Here is the code. Thanks in advance.
    procedure push_xls_query(wh text_io.file_type, wh_web varchar2, titolo varchar2, testoquery varchar2) is
         type stringArray is table of varchar2(500) index by binary_integer;
         type intArray is table of pls_integer index by binary_integer;
         valori stringArray;
         tipi intArray;
         nRows number := 0;
         i number := 0;
         cursorID exec_sql.curstype;
         result pls_integer;
         colName varchar2(30);
         colLen number;
         colType pls_integer;
         numerocampi number;
         temp1 varchar2(80);
    begin
         -- Se la lunghezza del titolo e' maggiore di 31 caratteri, lancia una eccezione
         if length(titolo) > 31 then
              raise xls_exception;
         end if;
         pkg_txt_io.putline(wh, wh_web, '<Worksheet ss:Name="'||to_xml(titolo)||'"><Table>');
         numerocampi := 0;
    cursorID := exec_sql.open_cursor;
    exec_sql.parse(cursorID, testoquery, exec_sql.V7);
    message('Prima di execute'); message(' ', no_acknowledge);
         result := exec_sql.execute(cursorID);
    message('Dopo di execute'); message(' ', no_acknowledge);
         -- Stampa i nomi dei campi
         pkg_txt_io.putline(wh, wh_web,'<Row>');
         loop
              numerocampi:=numerocampi+1;
              begin
                   exec_sql.describe_column(cursorID, numerocampi, colName, colLen, colType);
                   tipi(numerocampi) := colType;
                   if colType in (exec_sql.NUMBER_TYPE,
                             exec_sql.FLOAT_TYPE,
                             exec_sql.ROWID_TYPE) then
                        temp1 := 'rightbold';
                   else
                        temp1 := 'bold';
                   end if;
                   pkg_txt_io.putline(wh, wh_web, '<Cell ss:StyleID="'||temp1||'"><Data ss:Type="String">'||to_xml(colName)||'</Data></Cell>');
              exception
                   when others then
                        if sqlcode=1 then -- -306500 then
                             exit;
                        else
                             message('Errore imprevisto: '||SQLCODE||' - '||SQLERRM);
                             message(' ', no_acknowledge);
                             return;
                        end if;
              end;
         end loop;
         pkg_txt_io.putline(wh, wh_web,'</Row><Row></Row>');
    i := 1;
    while i <= numerocampi loop
    valori(i) := null;
    exec_sql.define_column(cursorID, i, valori(i), 500);
    i := i+1;
    end loop;
    while (exec_sql.fetch_rows(cursorID)>0) loop
    nRows := nRows + 1;
         pkg_txt_io.putline(wh, wh_web, '<Row>');
    i := 1;
    while i <= numerocampi loop
    exec_sql.column_value(cursorID, i, valori(i));
              if tipi(i) in (exec_sql.NUMBER_TYPE,
                             exec_sql.FLOAT_TYPE,
                             exec_sql.ROWID_TYPE) then
                   temp1 := 'Number';
              else
                   temp1 := 'String';
              end if;
              pkg_txt_io.putline(wh, wh_web, '<Cell><Data ss:Type="'||temp1||'">'||to_xml(valori(i))||'</Data></Cell>');
    i := i+1;
    end loop;
         pkg_txt_io.putline(wh, wh_web, '</Row>');
    end loop;
         exec_sql.close_cursor(cursorID);
         pkg_txt_io.putline(wh, wh_web, '</Table></Worksheet>');
    end;
    procedure push_xls_simplequery(filename varchar2, testoquery varchar2) is
         wh text_io.file_type;
         wh_web varchar2(1);
    begin
         begin
              pkg_txt_io.delete_temp_file(filename);
         exception
              when pkg_txt_io.ex_web_io then null;
         end;
         pkg_txt_io.open(filename, 'w', wh, wh_web);
         push_xls_begin(wh, wh_web);
         push_xls_query(wh, wh_web, 'Sheet1', testoquery);
         push_xls_end(wh, wh_web);
         pkg_txt_io.close(wh, wh_web);
    end;

  • EXEC_SQL Package  With Ora-306500 error

    I write this pl/sql and the Ora-306500 and i dont know where is the error
    declare
    con1 exec_sql.conntype;
    cur1 exec_sql.curstype;
    nign2 PLS_INTEGER;
    begin
    con1:= exec_sql.open_connection('user1/pass@server');
    cur1:= exec_sql.open_cursor(haj3_con con1);
    exec_sql.parse(con1,cur1,'begin create table user1.x as select * from user2.y; end;' , exec_sql.v7);
    -- and i try this also
    --exec_sql.parse(con1,cur1,'create table user1.x as
    --select  * from user2.y' , exec_sql.v7);
    nign2 := exec_sql.EXECUTE(con1,cur1);
    exec_sql.close_cursor(con1,cur1);
    exec_sql.close_connection(con1);
    end;
    so plz anybody can help me??

    Hi,
    write and exception-handler where you capture the EXEC_SQL.Package_Error exception and then show the last error raised by the exec_sql package.
    eg.
    BEGIN
    EXCEPTION
    WHEN EXEC_SQL.Package_Error THEN
    MESSAGE('Code: ' || EXEC_SQL.Last_Error_Code || ' Msg: ' || EXEC_SQL.Last_Error_Mesg || ' Position: ' || EXEC_SQL.Last_Error_Position );
    END;
    Patrick

  • Exec Stored Function in EXEC_SQL?

    Hi!
    How to execute a function in EXEC_SQL? I need a sample. Thanks!
    Steenie

    Please follow the following Example to implement EXEC_SQL.
    PROCEDURE Test IS
    connection_id EXEC_SQL.CONNTYPE;
    cursorID EXEC_SQL.CURSTYPE;
    sql_string VARCHAR2(1000);
    lv_ename VARCHAR2(30);
    lv_eno NUMBER;               
    lv_hiredate DATE;
    exec_id PLS_INTEGER;
    BEGIN
    connection_id := EXEC_SQL.OPEN_CONNECTION(connect_str);
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    sql_string := 'select ename, empno, hiredate from emp ';
    EXEC_SQL.PARSE(connection_id, cursorID, sql_string, exec_sql.V7);
    EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, ':bn', input_empno);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, lv_ename, 30);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, lv_eno);     
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 3, lv_hiredate);
    -- after parsing, and calling BIND_VARIABLE and DEFINE_COLUMN, if necessary, you are ready to execute the statement. Note that all information
    -- about the statement and its result set is encapsulated in the cursor referenced as cursorID.
    exec_id := EXEC_SQL.EXECUTE(connection_id, cursorID);
    END;
    If you still get error after following the above example please send me your code to [email protected]

  • EXEC_SQL connection error

    Hi,
    I'm trying to use EXEC_SQL to connect to a remote database to copy an image(BLOB) to my form.
    I've tested the code using dbms_sql access non-BLOB columns from the remote database then adapted those lines to EXEC_SQL to use from a different database BEFORE adding the access to a BLOB and getting error ... ORA 306500
    Error trapping using messages shows the connection line is the issue, so guessing my connection isn't working. As you can see below I've used string scott/tiger@remote_db but if my actual connection isn't working, is there a way I can test it and get a better message?
    I'm migrating from v6 to 10g forms and testing it in both.
    Thanks for your time :-)
    Elaine
    ==========Form Program Unit =====================
    PROCEDURE GET_DATAHUB_INFO_EXEC IS
    connection_id EXEC_SQL.CONNTYPE;
    cursorID EXEC_SQL.CURSTYPE;
    connect_str VARCHAR2(100);
    -- cursorID INTEGER;
    sqlstr VARCHAR2(1000);
    new_perid NUMBER;
    new_image BLOB;
    block_perid varchar2(10);
    nIgn PLS_INTEGER;
    BEGIN
         block_perid:=to_char(:images.person_id);
         connect_str:='scott/tiger@remote_db';
    -- a connection string is typically of the form 'username/password@database_alias'
    MESSAGE('before connect');
    connection_id := EXEC_SQL.OPEN_CONNECTION('connect_str');
    MESSAGE('before Open');
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    -- cursorID := DBMS_SQL.OPEN_CURSOR;
    -- sqlstr := 'SELECT new.person_id, new.image FROM IBANK.IMAGES@remote_db new
    sqlstr := 'SELECT new.person_id FROM IBANK.IMAGES new
    WHERE new.person_id=to_number(:curr_perid)';
    -- DBMS_SQL.PARSE(cursorID, sqlstr,0);
    -- DBMS_SQL.BIND_VARIABLE(cursorID, ':curr_perid', block_perid);
    -- DBMS_SQL.DEFINE_COLUMN(cursorID, 1, new_perid);
    -- DBMS_SQL.DEFINE_COLUMN(cursorID, 2, new_image);
    MESSAGE('After opne');
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, ':curr_perid', block_perid);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, new_perid);
    MESSAGE('After Define');
    -- EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, new_image);
    -- after parsing, and calling BIND_VARIABLE and DEFINE_COLUMN, if necessary, you
    -- are ready to execute the statement. Note that all information about the
    -- statement and its result set is encapsulated in the cursor referenced as cursorID.
    nIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    -- nIgn := DBMS_SQL.EXECUTE(cursorID);
    LOOP
         --Fetch rows
    IF EXEC_SQL.FETCH_ROWS(connection_id, CursorId)=0 THEN
    -- IF DBMS_SQL.FETCH_ROWS(CursorId)=0 THEN
         EXIT;
    END IF;
    -- retrieve into variables
    EXEC_SQL.COLUMN_VALUE(connection_id, CursorId,1,new_perid);
    -- EXEC_SQL.COLUMN_VALUE(connection_id, CursorId,2,new_image);
    -- DBMS_SQL.COLUMN_VALUE(CursorId,1,new_perid);
    -- DBMS_SQL.COLUMN_VALUE(CursorId,2,new_image);
    :images.nbt_curr_person_id:=new_perid;
    END LOOP;
    EXEC_SQL.CLOSE_CURSOR(cursorID);
    -- DBMS_SQL.CLOSE_CURSOR(cursorID);
    EXCEPTION
    WHEN EXEC_SQL.Package_Error THEN
    -- code obtained from another discussion thread that doesn't work
    MESSAGE('Code: ' || EXEC_SQL.Last_Error_Code ||
    ' Msg: ' || EXEC_SQL.Last_Error_Mesg ||
    ' Position: ' || EXEC_SQL.Last_Error_Position );
    RAISE;
    WHEN OTHERS THEN
    -- close the cursor and raise error again
    EXEC_SQL.CLOSE_CURSOR(cursorID);
    -- DBMS_SQL.CLOSE_CURSOR(cursorID);
    RAISE;      
    END;
    ==========================

    Still not had an answer to this problem. So let's recap
    1) I'm trying to test accessing data from a different DB (my_newDB) in forms by using EXEC_SQL and creating a new connection for the data.
    [I eventually need to access an image as a BLOB so can't use a simple DB link but am testing without for the moment]
    2) I have condensed the code used and included it below. If I don't have an Exception section I get error:
    FRM-40735: Key-nxtrec trigger raised unhandled exception ORA-306500
    3) If I add the exception section :
    EXCEPTION WHEN EXEC_SQL.Package_Error THEN
    Declare vSQLcode number := SQLcode;
    vSQLerrm Varchar2(200) := SQLerrm;
    Begin
    If vSQLcode = -306500 then -- Exec_SQL.package_error
    vSQLcode := -abs(Exec_SQL.Last_Error_Code);
    vSQLerrm := Exec_SQL.Last_Error_Mesg;
    End if;
    Message('Except: ' || vSQLerrm );
    Message(' ',no_acknowledge);
    End;
    I then get
    Except: ORA-00000: normal, successful completion
    Note this fires at open_connection line and then no more of Program unit runs
    You can see my debug messages, so I know where it is.
    -------------------- condensed Program Unit - Fires on KEY-NXTREC and KEY-DOWN
    PROCEDURE GET_DATABASE_INFO IS
    bIsConnected BOOLEAN ;
    connection_id EXEC_SQL.CONNTYPE; -- holds the connection
    cursorID EXEC_SQL.CURSTYPE;
    connect_str VARCHAR2(100);
    sqlstr VARCHAR2(1000);
    new_perid NUMBER;
    block_perid varchar2(10);
    nIgn PLS_INTEGER;
    BEGIN
         block_perid:=to_char(:b_images.person_id);
         connect_str:='scott/tiger@my_newdb';
    MESSAGE('before connect');
    connection_id := EXEC_SQL.OPEN_CONNECTION('connect_str');
    MESSAGE('before Open');
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    sqlstr := 'SELECT new.person_id FROM IBANK.IMAGES@my_newdb new
    WHERE new.person_id=to_number(:curr_perid)';
    MESSAGE('After open');
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, ':curr_perid', block_perid);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, new_perid);
    MESSAGE('After Define');
    nIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    LOOP
         --Fetch rows
    IF EXEC_SQL.FETCH_ROWS(connection_id, CursorId)=0 THEN
         EXIT;
    END IF;
    -- retrieve into variables
    EXEC_SQL.COLUMN_VALUE(connection_id, CursorId,1,new_perid);
    Message('new_perid='||new_perid);
    :b0.nbt_curr_person_id:=new_perid;
    END LOOP;
    EXEC_SQL.CLOSE_CURSOR(connection_id, cursorID);
    exec_sql.close_connection(connection_id);
    END;

  • Migrate to 5.0 to 6i and the exec_sql stop working

    Hi,
    I4ve migrate my application from Forms 5.0... to 6i(6.0.8.17.1). I have a function that uses EXEC_SQL, and this funcionallity stops working. When I execute the following commands I have an ORA-306500 error.
    -- Open the cursor
    cursor_count := exec_sql.open_cursor(p_conexao);
    -- Command to be executed
    exec_sql.parse(p_conexao, cursor_count,'select count(*) from ' || p_dctabela || dcwhere);
    -- Defining columns
    exec_sql.define_column(p_conexao, cursor_count, 1, lcounttabela);
    -- Executing
    ignore := exec_sql.execute(p_conexao, cursor_count);
    At this point I4ve got the ORA-306500 error.
    I4ve installed :
    - Oracle Open Client Adapter for ODBC 2.0.2.15.0
    -- Oracle Open Client Adapter Deployment Components 2.0.2.15.0
    -- Oracle Open Client Adapter Development Components 2.0.2.15.0
    -- Oracle Open Client Adapter Language Supplement 2.0.2.15.0
    - Oracle Open Client Adapter for ODBC 6.0.5.35.0
    -- Oracle Open Client Adapter Deployment Components 6.0.5.35.0
    -- Oracle Open Client Adapter Language Supplement 6.0.5.29.0
    The ODBC is correctly configured, the source is DBF.
    Thanks in advance,
    Jorge

    I have the same problem!
    Let me know if you find any solution.
    /Tobias Lindblom
    [email protected]

  • How to fetch rows using exec_sql

    hello to all
    i want to open a cursor and fetch some field values dynamically."the fields to be fetched will be selected by the user" i.e i have to get the data of the fields selected by the user.
    for this i am using the exec_sql method.
    its giving a message as 'FRM-01747: invalid user.table.column,table.column or column specification"
    i don't where i am wrong in the code.
    this is my code to fetch the values
    Declare
         Con_id EXEC_SQL.CONNTYPE;
         Cur_id EXEC_SQL.CURSTYPE;
         sqlstr varchar2(3000);
         fld1 number(20,2);
         fld2 number(20,2);
         fld3 number(20,2);
         fld4 number(20,2);
         fld5 number(20,2);
         fld6 number(20,2);
         fld7 number(20,2);
         fld8 number(20,2);
         nEmpno number(10,4);
         nIgn PLS_INTEGER;
         totRows number(5);
         a number;
    Begin
    --1
    Con_id := EXEC_SQL.DEFAULT_CONNECTION;--('scott/tiger@siil');
    go_block('BlkDet');
    Cur_id := EXEC_SQL.OPEN_CURSOR();
    sqlstr := 'Select A.EmpNo,A.'||:BlkMain.LstFld1||',A.';
    sqlstr := sqlstr||:BlkMain.LstFld2||',A.';
    sqlstr := sqlstr||:BlkMain.LstFld3||',A.';
    sqlstr := sqlstr||:BlkMain.LstFld4||',B.';
    sqlstr := sqlstr||:BlkMain.LstFld1||',B.';
    sqlstr := sqlstr||:BlkMain.LstFld2||',B.';
    sqlstr := sqlstr||:BlkMain.LstFld3||',B.';
    sqlstr := sqlstr||:BlkMain.LstFld4;
    sqlstr := sqlstr||' from Tempsalmast A, SalMast B';
    sqlstr := SqlStr||' where A.EmpNo=B.EmpNo';
    Message(SqlStr);
    Message(SqlStr);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,1,nEmpNo);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,2,Fld1);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,3,Fld2);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,4,Fld3);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,5,Fld4);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,6,Fld5);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,7,Fld6);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,8,Fld7);
    EXEC_SQL.DEFINE_COLUMN(Con_id,Cur_id,9,Fld8);
    EXEC_SQL.PARSE(Con_id,Cur_id,sqlstr,EXEC_SQL.V7);
    nIgn:=EXEC_SQL.EXECUTE(Con_id,Cur_id);
    while (EXEC_SQL.FETCH_ROWS(Con_id,Cur_id)>0) Loop
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,1,nEmpNo);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,2,Fld1);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,3,Fld2);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,4,Fld3);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,5,Fld4);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,6,Fld5);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,7,Fld6);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,8,Fld7);
    EXEC_SQL.COLUMN_VALUE(Con_id,Cur_id,9,Fld8);
    :BlkDet.TxtEmpNo:=nEmpNo;
    :BlkDet.DisFld1 :=Fld1;
    :BlkDet.DisFld2 :=Fld2;
    :BlkDet.DisFld3 :=Fld3;
    :BlkDet.DisFld4 :=Fld4;
    :BlkDet.TxtFld1 :=Fld5;
    :BlkDet.TxtFld2 :=Fld6;
    :BlkDet.TxtFld3 :=Fld7;
    :BlkDet.TxtFld4 :=Fld8;
    next_record;
    end Loop;
    --next_record;
    end;
    exception
         when others then
         Message(Dbms_Error_Text);
         Message(Dbms_Error_Text);
    can any body pls. help me out
    aditya

    Fetching rows to display them is a task for the client tool. You need to define a ref cursor therefore.
    If you just want to play around, here we go
    SQL> DECLARE
      2    type t1 is table of emp%rowtype index by binary_integer;
      3    var1 t1;
      4    v_counter number:=0;
      5  BEGIN
      6    select * bulk collect into var1 from emp;
      7    for vr in 1..var1.count loop
      8      dbms_output.put_line(var1(vr).ename);
      9      update dept set deptno=var1.deptno Here also Error occured.
    10    end loop;
    11  END;
    12  /
    SCOTT
    ADAMS
    PL/SQL procedure successfully completed.
    SQL>

  • Exec_sql.open_connection

    I am building a client form (this is supposed to be a preliminary of what an ORACLE web app will look like...)
    I use EXEC_SQL.OPEN_CONNECTION to connect to database.
    ( I also do an EXEC_SQL.OPEN_CURSOR and EXEC_SQL.PARSE and EXEC_SQL.DEFINE_COLUMN and EXEC_SQL.EXECUTE and EXEC_SQL.FETCH_ROWS ... yada ... yada ... yada to verify that there is a database connection.
    Then I call another form. The called form generates the exception that says/indicates that there is not a connection to the database.
    Right now it looks as though the EXEC_SQL results stay local to the block from where it is generated. I can force the application to work by redoing all of the EXEC_SQL stuff for each form-item trigger. There has to be a better way; I just cant find it in the documentation.
    (It seems rather silly to initiate 10 connections just to satisfy a couple of form triggers associated with one record.)
    How do I make the connection_id stuff available to everything in a forms module? (I tried assigning the connection ID to a global value, but globals dont like conntypes. )
    Thanks in advance.
    Len

    King i checked your coding there is no connection problem actually error is generating to the following line,
    Sqlstr := 'CREATE USER '||'sajid'||' IDENTIFIED BY '||'123';
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    so when i rem two lines and just define grant to existing user that running successfully, but i am still checking your code probably it will resolve.
    Declare
    Connection_id EXEC_SQL.CONNTYPE;
    CursorID EXEC_SQL.CURSTYPE;
    SqlStr VARCHAR2(2000);
    Loc_EName VARCHAR2(30);
    Loc_Eno NUMBER;
    Loc_Hiredate DATE;
    NIgn PLS_INTEGER;
    Begin
    --Connection_id := EXEC_SQL.OPEN_CONNECTION('SYSTEM','ORACLE','SYSDBA');
    Connection_id := EXEC_SQL.OPEN_CONNECTION('SYSTEM','ORACLE','orcl');
    --Connection_id := EXEC_SQL.OPEN_CONNECTION('SYSTEM/ORACLE@ORCL');
    CursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    Sqlstr := 'CREATE USER '||'sajid'||' IDENTIFIED BY '||'123';
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    NIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    Sqlstr := 'GRANT CONNECT TO '||:BLK_NVS_USERS_ALL.USR_NAME;
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    NIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    End;

  • EXEC_SQL loose Default_Connection

    hi,
    as you suggested in a previous post ("DBMS_SQL signature error"), I replaced DBMS_SQL with EXEC_SQL package to run dynamic SQL. It works until I do SELECT queries. But I came into an issue when trying to run an UPDATE query.
    This is my scenario (like in the previous thread). Pushing a button, procedure P is called
    PROCEDURE P IS
    BEGIN
    --log out the current user and log on with another user
    LOGOUT;
    LOGON ('USER2','PWD2' || '@' || 'DB',FALSE);
    UPDATE_PARAMS(....);
    END;
    PROCEDURE UPDATE_PARAMS(...) IS
         STR_QUERY      VARCHAR2(5000);
         connection_id      EXEC_SQL.CONNTYPE;
         cursorID      EXEC_SQL.CURSTYPE;
         bIsConnected      BOOLEAN;
         nRes           PLS_INTEGER;
    BEGIN
         STR_QUERY := 'UPDATE MYTAB SET....';
         BEGIN
              CONNECTION_ID := EXEC_SQL.Default_Connection;
              IF NOT BISCONNECTED THEN
                   MESSAGE('NOT CONNECTED');
              END IF;
              cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
              EXEC_SQL.PARSE(connection_id, cursorID, STR_QUERY, exec_sql.V7);                                   nRes := EXEC_SQL.EXECUTE(CONNECTION_ID,cursorID);
              EXEC_SQL.CLOSE_CURSOR(CURSORID);
         EXCEPTION
              when exec_sql.package_error then
                   MESSAGE('Error in updating.'|| chr(10) || EXEC_SQL.LAST_ERROR_MESG(connection_id));
                   EXEC_SQL.CLOSE_CURSOR(CURSORID);
                   EXEC_SQL.CLOSE_CONNECTION(CONNECTION_ID);                    
                   RAISE FORM_TRIGGER_FAILURE;
         END;
    END;
    This works on first call of P. If I push the button again, UPDATE_PARAMS cause an error due to the lack of connection. In fact, at the second call of UPDATE_PARAMS, the 'NOT CONNECTED' message is displayed. I tried to re-open the connection, but the error persists. How can I resolve this problem?

    hi christian,
    I will consider your suggestion of using DB Links instead of log out/log on approach. I must point out that USER1 and USER2 work on different Databases, and point to different report servers. What my application must do is this:
    1) USER2 (from DB_2 and report Server 2) log on to application; then, send a request to USER1 (working on DB_1 and report Server 1) for him to run a report.
    2) USER1 should log on to application, build parameter list for the report, run the report, and save the resulting PDF file into USER2 Database.
    3) now, USER1 must disconnect, USER2 can relog on application and keep working.
    So, while I guess USER2 could use a DB link to USER1's Database, I dont know what may happen if I try to call the report from USER2's connection. But above all, I wish to know why this approach works good in one environment (test environment) and doesnt in another.

  • How To Open A Cursor Using Exec_SQL?

    Declare
    V_Connection_id Exec_SQL.ConnType;
    V_CursorID Exec_SQL.CursType;
    V_SqlStr VarChar2(30000);
    V_NIgn PLS_Integer;
    Cursor V_User_Cur Is
    Select Group_Name
    From NVS_USERS_VS_GROUPS_VW
    Where Upper(USR_NAME) = User;
    Begin
    V_Connection_id := Exec_SQL.Open_Connection('PAL_SECURITY','PAL_SECURITY','DPC');
    V_CursorID := Exec_SQL.Open_Cursor(V_Connection_id);
    --------------------> Can't open a cursor here ?
    For V_User_Cur_Rec In (Select Group_Name
    From NVS_USERS_VS_GROUPS_VW
    Where Upper(USR_NAME) = User ) Loop
    V_SqlStr := 'Grant Nvs$_'||V_User_Cur_Rec.Group_Name ||'To '||User;
    Exec_SQL.Parse(V_Connection_id, V_CursorID, V_SqlStr, Exec_SQL.V7);
    V_NIgn := Exec_SQL.Execute(V_Connection_id, V_CursorID);
    End Loop;
    /******************* Error*******************************/
    Exec_SQL.Close_Cursor(V_CursorID);
    Exec_SQL.Close_Connection;
    END;

    What is the Error you are getting? Since you are attempting to grant privileges using the EXEC_SQL package, the error code/message is very important! ;-)
    Craig...

  • How to use more than one connection in forms 6.0

    Hello to all,
    I'm working with FORMS 6.0 and tried to open a second connection which should only be opened at once when Fomrs is starting and closed when FORMS is closing.
    The following code is working very well: (I've cut the defines and the exceptionhandling)
    Connection_Id := EXEC_SQL.OPEN_CONNECTION (Connection_String);
    cursor_number := EXEC_SQL.OPEN_CURSOR(Connection_Id);
    EXEC_SQL.PARSE(Connection_Id, Cursor_number, sql_string);
    ret := EXEC_SQL.EXECUTE (Connection_Id, cursor_number);
    EXEC_SQL.CLOSE_CURSOR (Connection_Id, cursor_number);
    EXEC_SQL.CLOSE_CONNECTION (Connection_Id);
    My problem is, that I want to use this connection from different scripts (procedures / packages and triggers) of my application. This means opening and closing the connection should be done not in the same function than accessing the SQL-command.
    The only way I could find to create a variable is to use :global.varname. The ConnectionId I get as returnvalue is of the type EXEC_SQL.ConnType. You can not define globals of this type.
    So, does anybody know how to define a variable from this type, so that it is accessible from each script in froms?
    Thanks in advance.
    Susanne

    Susanne,
    database links are named connections to other databases established between databases. So if you are working against database1 but require access to a schema in database2 then you can access this through database1 using the database link.
    however this doesn't solve your problem and unfortunately nothing will solve your problem. Forms uses internal caching and automated locking that doesn't allow Forms to recover if the database you are connected to goes down. All you can do is to setup the database in that a user that disconnects due to the administrator shutting down the database (naughty boy) will be connected to another database when restarting the application.
    For the authorized actions, I suggest to wrap these actions in stored procedures and grant access privileges through database roles. This way a user that tries to perform an action that he isn't allowed to do will get an Exception that you can gracefully handle in Forms. The stored procedure can handle the logging as well.
    Another really cool feature of the Oracel database is fine grained access control akna (Virtual private Databases VPD). Using VPDs a user specific context is set when the user connects so that he can't see what he isn't allowed to and cannot do what he isn't authorized. If you have the chance to read the database documentation, its fairly easy to implement.
    Fran

Maybe you are looking for

  • Warning while submitting XML Publisher Report..

    Hi All, I am getting warning status when i run a XML Publisher report..Its Working fine when i previewed in RTF template.. The Concurrent Program is generating XML Tags.. Can anyone help me.. The following is the log file content.. Arguments P_FROM_D

  • How to Configure HTTPs sender communication in XI

    Hi, I have a request for new interface setup, in which i need to configure HTTPs sender communication from a B2B server to SAP system. Scenario is to receive XML 0rders from HTTPs B2B system and convert to Idoc and post it to SAP. Please could some o

  • Report Tree for PS

    Hi Guys, Is there a transaction code for Report tree in PS. Like we have for AP - F.98, assets ART0 Thanks, Satya

  • Delayed output

    Hi Gurus, following query is taking a very long time      SELECT belnr gjahr buzei bukrs xstov augdt blart       INTO CORRESPONDING FIELDS OF  TABLE it_bsis       FROM bsis       WHERE hkont  IN glac        AND     blart    IN s_blart        AND    

  • New movies showing up in iTunes not purchased

    I have rec'd new movies on itunes and I have no clue why. I have not order anything from Itunes store. Does anyone know why this would happen?