Setting/using a variable in a package in SQL Developer

The 10g db I'm working with has a package that contains a variable and routines to set and get the value of the variable. The variable is used in a number of views to tailor data displayed according to the variable value. This all works well in applications, which set the variable after a connection is opened and then issue queries against the views, and then close the connection.
This also works well in Toad - I can open Toad, run a package routine to set the value and then open views (or run queries against views) in Toad to see how different variable values effect the data displayed. The package variable maintains its value so long as Toad is open, which seems to imply that Toad keeps a connection open.
But I can't use SQL Developer in the same way. I can run the SET routine, but it has no effect in on views subsequently run. When running the SET routine, setting the value to 1, the output is:
Connecting to the database HERC DB.
Process exited.
Disconnecting from the database HERC DB.
I can then run the GET routine, but the value of the variable is always zero:
Connecting to the database HERC DB.
v_Return = 0
Process exited.
Disconnecting from the database HERC DB.
The implication seems to be that a connection is made, the routine is run and then the connection is closed. The closing of the connection resets the variable. Is there some way I can have SQL Developer behave like Toad, such that the package variable value is maintained for my SQL Developer session? I've looked at connection roperties and application preferences, but I've not seen anything that seems to be related keeping a connection open.
BTW, I have tried the "connection startup script", but to no avail. Perhaps I've doen this improperly; the script simply attempts to invoke the package set routine, like so: myPkg.set_identity(1)
Thanks.
Edited by: user483973 on Oct 20, 2009 9:20 AM

When running stored PL/SQL through the IDE context node or editor, indeed a new session is opened and consequently closed on completion after committing. Although great for having the IDE free to continue working, it does have its drawbacks when you want variables to persist and changes to be visible in the IDE before committing.
To prevent the new session and the commit, just call the PL/SQL from a worksheet (in a call, query or anonymous block).
The startup script should work in that respect, but make sure to wrap your call in an anonymous block, else you'll get a syntax error.
Hope that helps,
K.

Similar Messages

  • ORA-01722 when opening a package in SQL Developer 1.2 with oracle 9iR1

    Hi,
    I use SQL Developer with Oracle Database 9i release 1.
    When I open a package in SQL Developer 1.2 (or 1.5) for editing, I receive the error ORA-01722. The package successfully opens but this message, which pops everytime, is really annoying.
    I monitored the requests sent by SQL Developer and it seems that the following request is responsible of the error :
    SELECT LINE,POSITION,TEXT,ATTRIBUTE FROM USER_ERRORS WHERE TYPE=:1AND NAME=:2
    Notice there are no spaces between ':1' and 'AND'. When executing 'by hand' the request with SQL Developer, it asks for the value of '1AND' bind variable and the value of '2'. Then, it fails to execute with... ORA-01722.
    Is it possible to avoid this bug ?
    Thank you for your help.

    We're doing rolling 2 week releases until production. Expect something new next week.

  • How to debug package in sql developer?

    Hi,
    I need to debug one of procedures in my package in sql developer version 1.5.5. In Debugging log, I got the following:
    Connecting to the database <databasename>.
    Executing PL/SQL: ALTER SESSION SET PLSQL_DEBUG=TRUE
    Executing PL/SQL: CALL DBMS_DEBUG_JDWP.CONNECT_TCP( '127.0.0.1', '2754' )
    ORA-01031: insufficient privileges
    ORA-06512: at "SYS.DBMS_DEBUG_JDWP", line 68
    ORA-06512: at line 1
    This session requires DEBUG CONNECT SESSION and DEBUG ANY PROCEDURE user privileges.
    Process exited.
    Disconnecting from the database <databasename>.
    I have granted both DEBUG CONNECT SESSION and DEBUG ANY PROCEDURE user privileges from SYS as the following:
    GRANT DEBUG ANY PROCEDURE TO ESM_OWNER;
    grant DEBUG CONNECT SESSION to ESM_OWNER;
    However, I still get the same error. What did I do wrong? I really appreciate any help to solve my problem.
    Thanks in advance!!!
    Cindy

    I logged in as ESM_Owner. Now I got the following errors:
    Connecting to the database <databasename>.
    Executing PL/SQL: ALTER SESSION SET PLSQL_DEBUG=TRUE
    Executing PL/SQL: CALL DBMS_DEBUG_JDWP.CONNECT_TCP( '127.0.0.1', '1131' )
    ORA-30683: failure establishing connection to debugger
    ORA-12541: TNS:no listener
    ORA-06512: at "SYS.DBMS_DEBUG_JDWP", line 68
    ORA-06512: at line 1
    Process exited.
    Disconnecting from the database <databasename>.
    Edited by: user13375135 on Sep 22, 2010 1:31 PM

  • Creating Data Mining PL/SQL Package in SQL Developer

    hi,
    i have built a model and want to create a PL/SQL package.
    in SQL developer, i launch a "New Gallery", select "All Items" from the drop-down menu, and click on "Database Objects". but in the right window pane, i am not able to see "Data Mining PL/SQL Package" in the options.
    can somebody please tell me how to fix this?
    thanks!

    To verify that Oracle Data Mining PL/SQL Package extension is properly installed, please do the following:
    Select Menu Help->About, click on "Extensions" tab. Look for "Oracle Data Mining PL/SQL Package" in the Name column ( you can sort it).
    If it is, please make a note of the version installed and post it here as well as the SQL Developer version.
    Just to clarify, you don't see "Data Mining PL/SQL Package" item in the "Database Objects" at all or is it grayed out?
    Thanks

  • Using bind variables (in & out) with dynamic sql

    I got a table that holds pl/sql code snippets to do validations on a set of data. what the code basically does is receiving a ID and returning a number of errors found.
    To execute the code I use dynamic sql with two bind variables.
    When the codes consists of a simpel query, it works like a charm, for example with this code:
    BEGIN
       SELECT COUNT (1)
       INTO :1
       FROM articles atl
       WHERE ATL.CSE_ID = :2 AND cgp_id IS NULL;
    END;however when I get to some more complex validations that need to do calculations or execute multiple queries, I'm running into trouble.
    I've boiled the problem down into this:
    DECLARE
       counter   NUMBER;
       my_id     NUMBER := 61;
    BEGIN
       EXECUTE IMMEDIATE ('
          declare
             some_var number;
          begin
          select 1 into some_var from dual
          where :2 = 61;
          :1 := :2;
          end;
          USING OUT counter, IN my_id;
       DBMS_OUTPUT.put_line (counter || '-' || my_id);
    END;this code doesn't really make any sense, but it's just to show you what the problem is. When I execute this code, I get the error
    ORA-6537 OUT bind variable bound to an IN position
    The error doesn't seem to make sense, :2 is the only IN bind variable, and it's only used in a where clause.
    As soon as I remove that where clause , the code will work again (giving me 61-61, in case you liked to know).
    Any idea whats going wrong? Am I just using the bind variables in a way you're not supposed to use them?
    I'm using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit

    Correction. With execute immediate binding is by position, but binds do not need to be repeated. So my statement above is incorrect..
    You need to bind it once only - but bind by position. And the bind must match how the bind variable is used.
    If the bind variable never assigns a value in the code, bind as IN.
    If the bind variable assigns a value in the code, bind as OUT.
    If the bind variable assigns a value and is used a variable in any other statement in the code, bind as IN OUT.
    E.g.
    SQL> create or replace procedure FooProc is
      2          cnt     number;
      3          id      number := 61;
      4  begin
      5          execute immediate
      6  'declare
      7          n       number;
      8  begin
      9          select
    10                  1 into n
    11          from dual
    12          where :var1 = 61;       --// var1 is used as IN
    13 
    14          :var2 := n * :var1;     --// var2 is used as OUT and var1 as IN
    15          :var2 := -1 * :var2;    --// var2 is used as OUT and IN
    16  end;
    17  '
    18          using
    19                  in out id, in out cnt;  --// must reflect usage above
    20 
    21          DBMS_OUTPUT.put_line ( 'cnt='||cnt || ' id=' || id);
    22  end;
    23  /
    Procedure created.
    SQL>
    SQL> exec FooProc
    cnt=-61 id=61
    PL/SQL procedure successfully completed.
    SQL>

  • Trying to use parameter variable as column identifier in SQL where clause

    Hey guys,
    Doing a college project... would really appreciate some help. I am trying to use a variable in the where clause of a select cursor in PL/SQL. The code is this:
    procedure results(p_search_entry varchar2, p_search_field varchar2) is
    cursor c_results is
    select * from physics_b where p_search_field = p_search_entry;
    begin
    for cv_results in c_results
    loop
    -- loop through actions
    end loop;
    The problem is that I don't know how to get the where clause to accept the variable passed into the procedure as the field name. Does anyone know the syntax for this?
    Thanks very much!

    To suit your requirement use ref cursor..
    If your database is 9i and upwards you can use sys_refcursor as I have used or else you can declare the cursor shown in the statement below
    type c_result is ref cursor;
    c_results c_result;
    Jus replace these two statement in the example if your oracle database is prior to 9i
    Eg:
    procedure results(p_search_entry varchar2, p_search_field varchar2) is
    qry_stmt VARCHAR2(1000) ;
    c_results sys_refcursor;
    begin
    qry_stmt := 'select * from physics_b where '||p_search_field|| '='|| p_search_entry
    open c_results for qry_stmt
    loop
    <fetch as like normal cursor>
    <ur normal cursor operation etc....>
    end loop;
    end results;
    Sorry I posted twice
    Message was edited by:
    Shasi

  • Variable value not showing in sql developer  tool

    HI,
    I am using sql developer tool. when i take mouse in variable name at debugging its not showing variable value and instead showing variable name data type and owner. but in past i have used sql developer tool where when i take mouse on variable at debugging mode it shows the varable value.  please tell me is there any issue in sql develper tool currently i am using.
    sql developer version 2.1.0.63

    Sorry - but I doubt if you will get much help for that ANCIENT version of Sql Developer.
    My best suggestion is to download the current version and see if you still have the problem. There have been HUNDREDS of bug fixes since that version you are using.
    Oracle SQL Developer Downloads
    Take note that the current version REQUIRES a much higher JDK version than what you may be using. And do NOT try to install the new version on top of the old one.
    Install the new version into a totally new folder. You will be ask if you want to import your settings from your current version.

  • Privileges to view packages in Sql Developer

    I'm sure this has been covered before, but I cannot view a package (spec or body) unless Execute has been granted.
    Create any procedure will allow spec/body to be displayed.
    Is this as intended?
    I searched the forum and elsewhere, and found comments and workarounds. What I am looking for is the actual rules that determine when a package can be viewed.

    You could probably connect to the database with toad, have the session traced, and click around and view some packages to see what sql was run, then do the same with sql developer. My guess would be the views that each tool is using by default, perhaps toad goes ofter dba_objects/source and maybe sql developer goes after all_objects/source, something like that. so with a permission like select any view or select any table, you might see different results depending on the tool, Purely speculation on my part.

  • Creating PL/SQL package in SQL Developer 4.0.0.12

    Hi,
    I have built a model in SQL Developer 4.0.0.12 and I want to create it's PL/SQL package.
    In ODMiner 11.1.0.4 from "Tools" > "Create pl/sql package" I can get a script for creating package and every thing is OK.
    but in SQL Developer I select "Deploy" from every node's context menu and it generates a folder containing some scripts related to every node. I don't see any relevant script for creating any package.
    How can I create relevant PL/SQL package from my workflow?
    Thank you for any help you can provide in this situation.

    Please refer to this White paper for how to generate PL/SQL package for workflow deployment:
    Oracle Data Miner (Extension of SQL Developer 4.0)
    Generate a PL/SQL script for workflow deployment
    http://www.oracle.com/technetwork/database/options/advanced-analytics/odmrcodegenwhitepaper-2042206.pdf

  • How can I use an existing local svn workspace with SQL Developer?

    I have a couple directories of files on my local drive that hold my current working files from the svn repository. I use both TortoiseSVN and Cygwin to keep the local files in sync with the repository, depending on my mood. I have created a connection to the repository in SQL Developer, and I can browse the repository just fine. My goal is to have SQL Developer play nice with the local files, just like the other two Subversion clients do. Is there a way I can inform SQL Developer of my local files without re-importing them through the Versioning -> Import... wizard, without changing anything (or putting anything at risk) in the local workspace?
    Thanks in advance for your help -
    Wally

    Then can her computer be authorized to both accounts?
    Absolutely. You can authorize any given computer to up to five iTunes Store accounts.
    If purchases are made on her account, to a computer authorized to my account, can I put those songs on my iPod?
    If you connect your iPod to her computer, yes. Tracks download only to the computer from which they're purchased, regardless of which iTunes Store account is used for the purchase. Or you could copy the tracks from her computer to yours and then authorize your computer to her iTunes Store account. But that's sort of defeating the original purpose, it would seem to me.
    is it better to buy music through Amazon downloads and/or actually purchasing CDs to avoid the security features iTunes puts on its music?
    That's certainly an option. If it's an entire album I want, I buy CDs. That way I can import them at the quality I want and to whichever of my systems I want. Amazon or one of the other download stores that offer tracks as MP3 are also an option, though for me download stores are best when you just want a couple of tracks off a given CD.

  • Unit testing packages in sql developer

    It appears that the specify parameters window is blank for packaged functions which means the test call fails when run. Is this a grant or synonym issue ( or something similar ) or is there an issue with testing packages via the unit test interface of sql developer. Thanks in advance.

    Seems that you cannot right click on the packaged schema object from the schema connection i.e. you have to create the test from the unit test tab and then choose the object type i.e select packages and then the packaged function or procedure. This method results in the Specify Parameters window having the correct signature displayed. Procedures or methods can be created via the unit test tab or the active connection tab.

  • Issue with viewing packages in SQL Developer EA2

    I posted a message when EA1 came out asking why I couldn't see the package's body in EA1.
    Now I couldn't see the any thing under '$schema/packages' in EA2.
    Does anybody know why?
    My OS: Windows XP Pro SP2
    Oracle: 9i
    SQL Developer version: EA2

    In version 9 a very simple sql is supposed to be executed:
    SELECT OBJECT_NAME, OBJECT_ID,
    DECODE(STATUS, 'INVALID', 'TRUE', 'FALSE') INVALID,
    'TRUE' runnable
    FROM SYS.ALL_OBJECTS a
    WHERE OWNER = :SCHEMA
    AND OBJECT_TYPE = 'PACKAGE'
    AND SUBOBJECT_NAME IS NULL
    -- for packages
    SELECT OBJECT_NAME, OBJECT_ID,
         DECODE(STATUS, 'INVALID', 'TRUE', 'FALSE') INVALID,
    'TRUE' runnable
    FROM SYS.ALL_OBJECTS o
    WHERE OWNER =:SCHEMA
    AND OBJECT_NAME = :PARENT_NAME
    AND OBJECT_TYPE = 'PACKAGE BODY'
    -- for package bodies
    If either of these doesn't return anything in worksheet, then the problem is right there. However, this part hasn't been changed since EA1 (The only change was adding SYS.DBA_PLSQL_OBJECT_SETTINGS requirement for version >=10). I can't reproduce the problem: in 9i scott sees any procedure/package I create.

  • Use of variable in a package execution

    Hi all,
    I've a procedure to call in this way
    exec schema.procedure('VAR').
    There's a really simple sql that asks the user to input the value and have to convert is using UPPER and pass to procedure.
    I've done as:
    exec :myvar := upper(&INPUT)
    exec schema.procedure(:myvar) ;
    I get the error that bind variable is not declared and my not sure that package is executed correcly...
    I've also tried to
    declare
    myvar varchar2(255) := upper(&INPUT)
    begin
    schema.procedure(:myvar) ;
    end;
    But is not working, I get PLS-00201 and PLS-00320 ...
    Any hint?
    Thanks
    Ste

    I've done as:
    exec :myvar := upper(&INPUT)
    exec schema.procedure(:myvar) ;If you take this approach then you must declare myvar. You can do it like this
    VAR myvar VARCHAR2(255)
    exec :myvar := upper(&INPUT)
    exec schema.procedure(:myvar)
    I've also tried to
    declare
    myvar varchar2(255) := upper(&INPUT)
    begin
    schema.procedure(:myvar) ;
    end;
    /If you want this then you need to pass the variable without the : symbol. In PL/SQL are variable are bind variable by itself. So you dont have to specify the :symbol.
    declare
    myvar varchar2(255) := upper(&INPUT)
    begin
    schema.procedure(myvar) ;
    end;
    /

  • Pass Variable to SSIS Package through SQL JOB -2012

    So here is what i am trying to do. 
    I have a EXECUTE SQL Task - that executes a Stored Procedure with a Parameter. EXEC dbo.Procedure @Variable
    I have deployed this SSIS on Server - Now i want to pass different values to this variable using SQL JOB at different times. 
    How can i achieve this in SQL 2012. 
    Thanks

    Hi there,
    MSDN is pretty clear on that:
    Map Query Parameters to Variables in an Execute SQL Task
    If not there are tons of blog posts: http://sqlage.blogspot.ca/2013/07/ssis-how-to-pass-parameter-value-to-ole.html
    Arthur
    MyBlog
    Twitter

  • Very new to this: Cannot see code for a package in SQL Developer

    I know I'm doing something wrong but I certainly don't know what. I'm looking for the code to go along with a package. I can see the procedures the package calls and I can see a list of procedures but I cannot see the code for those procedures. I have tried using describe on the pop up and I just don't see anything but a window showing me the parameters the procedure will use. I want to see the code it will use.
    Can someone walk me through this or point me in the right direction?
    TIA

    I can only assume you're on 2.1 or 2.1.1 since you don't even say. If you click on the tree showing the various objects after establishing your connection, when you get to packages and you click the package you want, you'll see the spec. Now click on the plus sign and there should be 'package name' body. If you click that body icon, you say you still can't see the code?
    Evita
    Edited by: Evita on Mar 30, 2010 2:59 PM

Maybe you are looking for

  • Screen on my ipod touch is flickering. won't respond to resetting. any suggestions?

    My daughter was playing on her ipod touch 4th gen. and all of a sudden the screen has lines across it and is flickering. Tried turning it off and wouldn't respond so I then tried holding down the power button and menu button for 10 sec. and still not

  • 3.0.9.8.3 Issues on Tru64

    Hey, I have just about managed to get the 30984 upgrade complete on a Tru64 instance of portal. However I do still have one invalid portal30 package. This package is causing any forms in portal to be unusable. The Package is wwa_api_module_event, whe

  • Service Battery Warning

    Hello,I have a 2011 MacBook Pro, it currently has 504 charge cycles and is giving me the service battery condition warning. However, I have not noticed any significant difference in battery life as the apple website said should occur as I reach the S

  • XI sending # chanracter in null IDOC segments

    Hi, We are doing a File to IDOC scenario. We are picking the file through FTP using  a file adapter. The File contains data in XML format of ORDERS.ORDERS05. On R/3 side it is received as an IDOC (type ORDERS.ORDERS05). However in R/3 we see that the

  • Signature no longer valid

    I can't upload a new app to the app store with Application loader. The message keeps telling me that "Application failed codesign verification. The signature was invalid, or it was not signed with an iPhone Distribution Certificate" I've never had th