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;

Similar Messages

  • 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

  • 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;

  • 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

  • How to connect more than one oracle databases in single form?

    Hi,
    I have installed Oracle database in three different servers with different users, but the table's structure are same in all three different database users.
    Now in one D2K form i want to connect and access, all three different database users at a time.
    If anybody know answer for this please replay.
    My mail Id: [email protected]
    Regards
    Mahaveer

    You can access other databases/schemas by means of the built-in-package EXEC_SQL. See online help in Forms Builder, especially EXEC_SQL.Open_Connection, EXEC_SQL.Open_Cursor, EXEC_SQL.Fetch_Rows, ...
    If you want to base your blocks on several database connections at the same time, you should write your own on-select, on-fetch, on-lock, ... triggers, I suppose.
    Marc

  • Dynamic SQL in Form Builder 6.0

    Hai,
    I would like to know how to create Dynamic SQL in Form Builder 6.0. I'am using oracle 9i database...Please help me.....

    I studied the EXEC_SQL and i wrote these syntax(below), but it gives me error...Could you help me please......:
    PROCEDURE Dynamic_sql IS
    connection_id EXEC_SQL.CONNTYPE;
    cursorID EXEC_SQL.CURSTYPE;
    sql_string VARCHAR2(1000);
    v_pc varchar2 (4);
    v_pd varchar2 (30);
    v_poc varchar2(4);
    v_pvd DATE;
    v_pid DATE;
    exec_id PLS_INTEGER;
    out_file TEXT_IO.FILE_TYPE;
    linebuf varchar2(7000);
    vchFileName VARCHAR2(100);
    Vchfolder VARCHAR2(100);
    AppID      PLS_INTEGER;
    nmbAlert          varchar2(50);
    BEGIN
    SET_APPLICATION_PROPERTY(CURSOR_STYLE,'BUSY');
    vchFileName := 'dynamic_sql_'||sysdate||'.txt';
    Vchfolder := 'D:\KONS\Damar\';
    host('mkdir '||Vchfolder,NO_SCREEN);
    out_file := text_io.fopen(vchfolder||vchFileName,'w');
    TEXT_IO.PUT_LINE (out_file,'PRODUCT CODE PRODUCT DESC PRODUCT OBJECT CODE PRODUCT VALID DATE PRODUCT INVALID DATE ');
    connection_id := EXEC_SQL.OPEN_CONNECTION('FIFDBA/F1FDBA@REPL_DAILY');
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    sql_string := 'SELECT PROD_CODE, PROD_DESC, PROD_OBJT_CODE, PROD_VALID_DATE, PROD_INVALID_DATE
    FROM HOUS_PRODUCT_TYPE ';
    EXEC_SQL.PARSE(connection_id, cursorID, sql_string, exec_sql.V7);
    --EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, '', input_empno);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1,v_pc, 4);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, v_pd, 30);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 3, v_poc, 4);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 4, v_pvd);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 5, v_pid);
    exec_id := EXEC_SQL.EXECUTE(connection_id, cursorID);
    WHILE (EXEC_SQL.FETCH_ROWS(connection_id, cursorID) > 0 ) LOOP
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1, v_pc, 4);
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 2, v_pd);
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 3, v_poc);
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 4, v_pvd);
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 5, v_pid);
    TEXT_IO.PUT_LINE(out_file,v_pc || v_pd ||v_poc||v_pvd||v_pid);
    --Forms_DDL('INSERT INTO TEMP VALUES('||''''||nRows||' '||v_state_id||''''||')');
    --COMMIT_FORM();
    END LOOP;
    EXEC_SQL.CLOSE_CURSOR(connection_id, cursorID);
    EXEC_SQL.CLOSE_CONNECTION(connection_id);
    SET_APPLICATION_PROPERTY(CURSOR_STYLE,'DEFAULT');
    TEXT_IO.FCLOSE(out_FILE);

  • Reading foxpro dbf files from forms6i

    hi all,
    can anyone tell me how can i read a dbf file and access data from that.
    Thanks
    Uday

    Exec_Sql Package allows you to acess non Oracle Database
    You will have to follow following steps as follows:-
    1-First Find OCA.PLL and EXEC_SQL.PLL libraray.
    2-Attach Both libraries to ur concerned Forms.
    3-Create VFP odbc driver.
    3-Create a Button to write follwing codes on WHEN-BUTTON-PRESSED trigger or u can write
    these code on any Trigger as you required.
    Decalre
    conidodbc exec_sql.conntype;
    B varchar2(100);
    C varchar2(100);
    curid exec_sql.cyrstype;
    sqlstr varchar2(1000);
    nres pls_integer;
    Begin
    --This exec_sql.open_connection Procedure connect your 
    --non Oracle Database through ODBC Driver
    coniidodbc:=exec_sql.open_connection
    ('scott/tiger@odbc:yourodbcdivername');
    --exec_sql.opne_cursor return the curid of your non
    --Oracle Database
    curid:=exec_sql.opne_cursor(conidodbc);
    --It is Your non Oracle Database Statement follow there
    --Syntax rule of your non Oracle Database Syntax
    sqlstr:='Select A from yourdbffilename ';
    --exec_sql.Parse procedure parse your Stement to non
    --Oracle Database
    exec_sql.Parse(connidodbc,curid,sqlstr,exec_sql.V7);
    --After succesful Parsing it Executes your Ststment
    nres:=exec_sql.execute(conidodbc,curid);
    --exec_sql.Define column mapping for your local
    --variable to Non Oracle Database Column
    exec_sql.Define column (conidodbc,curid,B,30);
    while (Exec_Sql.fetch_rows(conidodbc,curid)>0)
    loop
    --Exec_Sql.column_value intiliaze your Non Oracle
    --Database to your Local Variable
    Exec_Sql.column_value (conidodbc,curid,1,B);
    C:=B;
    message('C value '||C);
    end loop;
    End;
    --Rest Explanation About Exec_Sql Package Find Help in
    --You Forms Still If any Problem then add me on MSN my id
    --is [email protected] may be I can help you more
    Thanks
    Khurram Siddiqui

  • Create .dbf file from Forms 6i

    Hello,
    I know how to create a text file with Only col of tables in Text File(*.txt) using Text_io Package.
    How To get the same Output as DBF File(*.dbf) directly so that there is no Extra overhead of converting *.txt to *.dbf using Visual Foxpro?
    Thanks in Advance

    You can use the Exec_SQL package.
    The following code successfully copies the EMP form block into a emp.dbf file.
    The ODBC Data Source "prashanth" must be configured.
    declare
      fox_tab  EXEC_SQL.conntype;
      cur      EXEC_SQL.curstype;
      ret      pls_integer;
    begin
      begin -- Delete emp.dbf
        fox_tab := exec_sql.open_connection(null, null, 'ODBC:prashanth');
        cur := EXEC_SQL.open_cursor(fox_tab);
        EXEC_SQL.parse(fox_tab, cur, 'drop table emp ');
        ret := exec_sql.execute(fox_tab, cur);
      exception 
        when OTHERS then NULL;
      end;
    -- create new emp.dbf file
    EXEC_SQL.parse(fox_tab, cur, 
        'create table emp (EMPNO INTEGER,'||
                          'ENAME CHAR(10),'||
                          'JOB CHAR(9),'||
                          'MGR NUMBER,'||
                          'HIREDATE DATE,'||
                          'SAL NUMBER,'||
                          'COMM NUMBER,'||
                          'DEPTNO NUMBER)');
    ret := exec_sql.execute(fox_tab, cur);
    Go_Block('EMP');
    execute_query;
    loop
      EXEC_SQL.parse(fox_tab, cur, 
         'insert into emp(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)'||
                          values('||:EMP.EMPNO||','''||:EMP.ENAME||''','''||
                          :EMP.JOB||''','||
                          NVL(TO_CHAR(:EMP.MGR), 'NULL')||','''||
                          TO_CHAR(:EMP.HIREDATE, 'DD-MON-YYYY')||''','||
                          NVL(TO_CHAR(:EMP.SAL), 'NULL')||','||
                          NVL(TO_CHAR(:EMP.COMM), 'NULL')||','||
                          NVL(TO_CHAR(:EMP.DEPTNO), 'NULL')||')');
      ret := exec_sql.execute(fox_tab, cur);
      if :system.last_record = 'TRUE' then exit; else next_record; end if;
    end loop;
    EXEC_SQL.close_cursor(cur);
    EXEC_SQL.close_connection(fox_tab);
    end;

  • Frm-40375 and ora-306500 with ODBC connection

    Hi experts,
    I am getting frm-40375 , ora-306500 when clicking a button on form , the code behind the button is actually connecting to a database other than oracle using the ODBC connection and importing data in variables and than inserting in an oracle table.
    The error only appears on other PCs and not on my pc , means there is no problem in the code and is working fine on my pc (importing the desired data when using my pc).
    The question is what is missing on other PCs or in other words what is additional component in my PC.
    Please tell when and why this ora-306500 occurs.
    Hope I defined the problem correctly.
    (the following is part of the code
    connection_string:='user/pass123@ODBC:abcd123';
         connection_id := EXEC_SQL.OPEN_CONNECTION(connection_string);
         cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    Using Oracle 9i Database
    and 6i Forms
    Thanks in advance
    Edited by: zulfffi on Jun 29, 2010 11:08 PM

    ora-306500I seriously doubt this is actual error code.
    AFAIK - Oracle errors have not yet reached 6 decimal places.
    please use COPY & PASTE in the future

  • Conn to Ms-Access thru Forms

    Hi everyone
    i m getting a problem while connecting to MS-Access thru ODBC in forms, using EXEC_SQL Pkg
    its giving me a message Frm-40734:internal error.
    the error is at line
    EXEC_SQL.OPEN_CONNECTION(/@odbc:conac)
    where "conac" is the ODBC connection name
    can nybody help in this case

    Hello,
    There is no OCX, ActiveX or COM component that will work in any version of Access now. All have been deprecated.
    If you can hook into .NET assemblies through Access then look on Microsoft's site for more info or if it's possible.
    Also Office 2010 is not supported in any version of CR at this time.
    Thank you
    Don

  • How to connect Forms 6i with MS Access

    Dear All:
    Can we connect Forms 6i with MS Access? If yes then how? Any document? Any suggestions?
    Thanks
    Hassan

    Thanks Jose for your suggestions:
    I am sorry I did not use the search utility of Forum.
    Anyway I have connect the Forms 6i with MS Access
    I created two text item in a Non-Database block and write following coding on a Push Button:
    declare
    connection_id EXEC_SQL.CONNTYPE;
    cursorID EXEC_SQL.CURSTYPE;
    sqlstr VARCHAR2(1000);
    d1 VARCHAR2(100);
    d2 NUMBER;
    nIgn PLS_INTEGER;
    nRows PLS_INTEGER := 0;
    BEGIN
    connection_id := EXEC_SQL.OPEN_CONNECTION('hsn','hsn','odbc:test');
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    sqlstr := 'select d1,d2 from abdali ';
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, '', '');
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, d1, 100);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, d2, 100);
    nIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    WHILE (EXEC_SQL.FETCH_ROWS(connection_id, cursorID) > 0 ) LOOP
    nRows := nRows + 1;
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1, :d1);
    --EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 2, :d2);
    next_record;
    END LOOP;
    message(nrows);
    IF (nRows <= 0) THEN
    TEXT_IO.PUT_LINE ('Warning: query returned no rows');
    END IF;
    END;
    I can retrieve the data from MS Access but there is a problem occured.
    The data type of one column in Access is defined as Intiger
    I also defined a text item in form as Intiger but when retrieved then it returned following error:
    FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-306500.
    I remarked the following coding it works fine.
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 2, :d2);
    Any suggestions: I also read the OCA_INFO.pdf but did not find how to handle this type of problem.
    If you can help me to find out how to match the data types of both the databases?
    Also can I insert the data from a Database Block of Oracle into MS-ACCESS thru write code on the Button.
    Thanks for help
    Hassan

  • How to connect from a form modulo at two different db user

    i a button of a module form i have tried this
    forms_ddl ('connect scott/tiger@db9');
    There was no error during compilation, but at runtime the connect don't change !
    Noone have any idea to do this ??

    Mike,
    keep in mind that Exec_SQL.Open_Connection() does allow you to query a second database connection, but not to place datablock on.
    An alternative to this would be a database link from teh database you originally connected to.
    Frank

Maybe you are looking for

  • Help with page links

    i've created a design in photoshop and am now uploading that design into dreamweaver to create the site. i tried using a template, but for some reason when i try to link my pages together and view in ie none of my links work. they will navigate to th

  • [solved] Synaptics Touchpad works in GDM but not in Gnome Session

    Hey, i just installed arch x86_64 to a Amilo Pa 3553 Notebook with synaptics touchpad driver. It's working in gdm perfectly but after login i cannot click, wether tabbing nor klicking. But i can move the coursor. Touchpad is recognized in Xorg.log wi

  • What is the correct way to customize GDM?

    Hello. I want to add the Arch Linux logo to GDM. Apparently the info on the wiki is outdated, because it didn't work. The info in the in the Gnome wiki seems updated, too, because it references things that aren't present anymore. Using the dconf edit

  • Printing freezes many applications

    Hi All, I have a Windows 7 laptop that sporadically experiences program hangups when printing to any printer. It's not just one program, it happens in Office 2013, Acrobat XI, even the Windows photo printer. But it doesn't hang "low-level" apps like

  • Recruitment Vs E recruitment

    Hello People I have one clarification to make. Is recruitment prerequist for E recruitmetn or not? I mean can we implement E recruitment without the implementation of recruitment.