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.

Similar Messages

  • 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

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

  • IMessage beta loose all saved conversations when I open and close a window.

    iMessage beta looses all saved conversations when I open and close a window.
    Just reporting this bug... Could not find anyother place to do it.
    Jonathan

    I thought it was doing that also. But I found that if I start a new chat with someone I was messaging before, then the old messages re-appear in the messages window.

  • I have 2 apple ids for iTunes...is there anyway I can combine them into one I'd without loosing all my music?

    I have an older iPod and new iPhone 5s. I have two separate accounts for each. Can I take my iPod account/Id and make into my iPhone id and transfer my music over?...without loosing my music!?

    If you mean Apple IDs, they can't be merged at all.
    If you mean iTunes libraries, import the content and playlists from one to the other.
    You can have content from multiple Apple IDs in one library.
    (104094)

  • HT1632 I can view a workout on my ipod touch history, but not in itunes or on nike+ website.  I can't seem to upload this run and it's really annoying as I'm loosing about 12k of runs.  It seems to happen when I program in a custom run.  Can you help?

    Hi there,
    I have just done a custom run on my Ipod touch 2nd Gen of 12k.  When I finished the run is appearing in my run history on my iPod touch, however it is not appearing in my itunes 'Nike+' tab, or on the Nike + website.  I can't seem to get this run to sync and it is really annoying because I'll be loosing 12k.  Can anyone help or has experienced this before?  I know there are solutions to add runs to iPod nano's and older iPods using the 'Enable disk' and iPod_control function however from what I'm aware you cannot do this on an iPod touch.  Can anyone please help?
    Many thanks
    Phil

    You should really read the manual.
    "How do you restore from backup? "
    Restore.  When given the choice, choose to use backup.
    "And how can I check to see if the pics and videos are on my computer somewhere first??"
    They would only be where you put them.  What program did you use to import them?  Pics/vids taken with ipod are not part of the sync process at all.  You should be importing them just as you would with any digital camera.
    If you did not import them, then they are not on your computer.

  • I have music on my ipod that is no longer on my pc. How can I sync new music that is on my pc to my ipod without loosing the music that is currently on the ipod?

    I have an iPod Generation 4. I have been using it with my pc Windows 8 iTunes for some time with no problem. Recently I had to do a system restore and reinstall itunes 7. It works great but  I lost all of my music in itunes but  I still have all of my music on my iPod. When  I try to sync new music I have to my ipod itunes tells me it will erase all existing content on my ipod and replace it with the new content. My question is: How can I add my new music without loosing my old music?

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • Greeting,  I want to reformat my external hard drive using Mac OS Extended (Journaled, Encrypted ) but before formatting it, I want to make sure that if I loose the hard drive or the hard drive get stolen, no one will be able to retrieve or recover the in

    Greeting,
    I want to reformat my external hard drive using Mac OS Extended (Journaled, Encrypted ) but before formatting it, I want to make sure that if I loose the hard drive or the hard drive get stolen, no one will be able to retrieve or recover the information on it so could you tell me what kind of encryption will be used or is there any way to recover the information?
    Thanks!

    I think FileVault is used to encryp internal hard drive but I wanna encrypt an external hard drive with Mac OS Extended Journaled Encrypted which is completely different!

  • Is anyone having a problem with the new iPad (Gen. 3) not staying connected to the charger? It seems to ALWAYS get jiggled loose and no longer be charging. My iPad 1 has no issue but I can't browse Internet w/o new iPad unplugging. Horrible!

    I notice that my new IPad (3rd generation) will not stay connected to the power cord at all, I'm not exagerating, if I plug it in and browse the Internet without fail it will become unplugged and I will have to push the plug back in (Ba-beep). Ive actually grown to despise that sound when you plug your iPhone or iPad in because it reminds me of how much money I spent on something that PHYSICALLY will not charge while I'm using it.
    I know the problem with it holding a charge while in use, I get it, the screen is amazing and it takes a lot to run the display, however, it is unacceptable to me that I can't even keep the thing plugged in while I'm using it. I can not even leave it on my Cal King bed overnight because I will wake up in the morning to find that the plug has been jiggled loose in a corner, so it's still attached but not making a connection thus not being charged. 
    I love the 4GLTE from Verizon and I love the iPad, but I'm actually using my 1st generation IPad while I am at home so I can leave my new $900 iPad on a table to charge free of incident so I can use the 4G while I'm away from wifi during the day. I have been getting more upset about this because I can not even use the Griffin extended cord to charge the iPad and be far from the plug because only the original apple sync/charge cord will have a better shot at staying in. Absolutely none of my non apple cables will stay in the iPad 3 while having it in my hands.
    The plug is at an angle, unlike the first iPad, not sure about the iPad 2. Please let me know if they have same issue.
    If anyone else is having this problem with the Gen 3 iPad please let me know because I'm tempted to do something about it with apple and I'm hoping that I just for some reason have a bad cable receiver or something and maybe I can get a replacement and enjoy the iPad as I had expected to. There is no reason why I should be even using my first iPad and I have friends that want to buy it but I am not selling it because I'm unable to sell it because I can't handle the new iPad while it's plugged in, that is ridiculous if it's a common issue so please let me know!

    Thanks for the swift reply, I have been looking online and a loose plug seems to be somewhat of an issue with many, I hope mine is actually a problem and not what others are experiencing. It's taken me this long to even reach out for the simple fact I HATE being a complainer but this is just horrible.
    Do you have an iPad 3 as well? And is yours not experiencing any issues close to mine?
    Thanks again!

  • Why does everyone at my work loose their internet connection when I update Adobe Cloud Products?

    Why does everyone at my work loose their internet connection when I update Adobe Cloud Products? We are on a 20mb broadband connection and there is around 20 people using computers at my work but when I start my Adobe Cloud Product update or when I try and download my Adobe Cloud Product everyone at my work looses their internet connection and so do I. But the update keeps downloading and installing.

    I am sorry FooWingLi but the difficulties you are describing sounds more like a local network configuration issue.  I would recommend working with your I.T. department to investigate this matter.

  • HT4623 When I plug my ipad to itunes i get the error message that it is not supported and I have to go to itunes and get itunes re-installed?  i never had this problem before.  if i do this will i loose all my files, music, etc?

    When I plug me ipad to itunes i get the error message that it is not supported and that i have to go to itunes and get "itunes installer" and re-install.  if i do this will i loose my files and music?

    No, you should not lose anything.

  • HT4623 I did the update to my iPhone 4 and I loose my voice memos how can I recover them?

    I did the update to my iPhone 4 and I loose my voice memos how can I recover them?

    Once it's in recovery mode, everything on the phone is already gone.  If you've been backing it up and syncing on a regular basis, it should restore just fine.

  • Battery problem!!!!heating up while charging and battery loosing in short time

    i just brought new iphone 5 !!!! while charging it heats up...and while using 3g it looses battery very fast after full recharge .
    While using 3g battery decreases by 1percent in 2minutes...m using ios 6.0.1............

    Hi swaraj.vidhate,
    If you are experiencing what appears to be unusually short battery life, you may want to check out the "Power/Battery: Battery life seems short" section of the following article:
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    In particular, the Restore iPhone step will help isolate if any potential issue is software or hardware related.
    With regard to the iPhone warming during charging:
    iPhone, iPad, and iPod touch (4th generation): Keeping device within acceptable operating temperatures
    http://support.apple.com/kb/HT2101
    When using the device or charging the battery, it is normal for it to get warm. The exterior of the device functions as a cooling surface that transfers heat from inside the device to the cooler air outside.
    If you are still having issues with the battery life, or have any further concerns, there is a link to Apple iPhone Support at the bottom of the Hardware Troubleshooting document; I am sure they would be happy to be of assistance.
    Cheers,
    - Brenden

  • How do I move iTunes and all songs to new computer without loosing ratings?

    I recently purchased a new computer and have been trying to migrate everything to it. I downloaded Itunes to my new computer and moved all music on to the new computer. While I have successfully set up iTunes on the new computer (including setting the proper iTunes Music folder location under Edit/Preferences/Advanced/General), I cannot find a way to import ALL (Over 60 gig) of music into iTunes. The best I have been able to figure out is to add each individual folder from an artist to the library (this would be a HUGE amount of time!) and in so doing I would loose ALL the time I have spent rating songs (very important to me for My Top Rated). Is there a way to import all music on a specific drive into iTunes AND keep the preferences from the prior computer. Any help would be greatly appreciated.
    Thanks

    If you want Everything moved over...
    See here
    Copy iTunes to an External Drive
    http://support.apple.com/kb/HT1751
    There is also this...
    iTunes: How to move your music to a new computer

  • Data mart from two DSOs to one - Loosing values - Design issue

    Dear BW experts,
    I´m dealing with a design issue for which I would really appreciate any help and suggestions.
    I will be as briefly as possible, and explain further based on the doubts , questions I received in order to make it easier go through this problem.
    I have two standard DSOs (DSO #1 and #2) feeding a third DSO (DSO #3), also standard.
    Each transformation DOES NOT include all fields, but only some of them.
    One of the source DSO (let´s call it DSO #1) is uploaded with a datasource that allows reverse type of records  (Record Mode = 'R'). Therefore some updates on DSO #1 comes with one entry with record mode 'R' and a 2nd entry with record mode = 'N' (new).
    Both feeds are delta mode, and not the same entries are updated through each of them, but the entries that are updated can differ (means an specific entry (unique key values)  could be update by one of the feeds, but no updates on the 2nd feed for that entry).
    Issue we have:  When a 'R' and 'N' entries happen in DSO #1 for any entry, that entry is also reversed and re created in the target DSO #3 (even being that not ALL fields are mapped in the transformation), and thefore we loose ALL the values that are exclusively updated through DSO #2, becoming blank.
    I don´t know it we are missing something in our design, or how should we fix this issue we have.
    Hope I was more or less clear with the description.
    ´d really appreciatted your feedback.
    Thanks!!
    Gustavo

    Hi Gustavo
    Two things I need to know.
    1. Do you have any End Routine in your DSO? If yes, what is the setting under "Update behavior of End Routine Display"....Option available right side of Delete Button ater End Rouine.
    2. Did you try with Full Load from DSO1 and DSO2 to DSO3? Do you face the same problem?
    Regards
    Anindya

Maybe you are looking for

  • Home Sharing with multiple libraries on same computer?

    I'm a total Apple noob, but I couldn't find the answer through search so here goes: Setup: 1 Desktop PC with XP running iTunes 10.2 1 user account, but two libraries - 1 for my wife and 1 for me (maybe more later) 1 iPod Classic for wife 1 iPad2 for

  • Your opinion - why should we (or should we not) use flash as our primary platform for video delivery?

    Hi, I work at a college that is delivering courses online at a distance. Currently, we are using a Windows Media Streaming server as our main platform for video. We definitely want to be able to stream, as our students are from all over the world and

  • CRM 4.0 and Partner Functions?

    As I understand it, they believe that there is a limitation on the number of partner functions that can be replicated between CRM 4.0 and ERP? And the limitation is a total of 999? But what if more than 999 are needed? I guess that these are created

  • OBIEE currency conversion

    Hi, I have something i don't really understand in OBIEE 10g, I have done a full financial ETL load, I went to see my values in predefined financial dasboard , but all my values are in dollars $ for example if locally i have 7200 in the dashdoard i ha

  • JBuilder 8 and J2EE, what adjustments do I make?

    I have JBuilder 8 SE and I am trying to dabble in Servlets and eventually EJB. I was told that I need to add the location of the servlet.jar to my CLASSPATH environment variable to allow JBuilder to compile Servlets, is this correct and do I have to