Oracle SID from within a stored proc

Sorry - probably a no-brainer, but can't find it anywhere in the doc. Can anyone tell me how to query the current session identifier in pl/sql. (ie. the SID I can use to find an entry in v$$session.
Thanks,Tim

http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:114412348062

Similar Messages

  • Creating a table/view or temporary table from within a stored procedure

    Hi Gurus,
    Can someone tell me if it is possible to create a table (or view) from within a stored procedure.
    PROBLEM:
    In fact I need to create a report at back end (without using oracle developer forms or reports). This report requires creating several tables to hold temporary report data. If I create a sql*plus script for this, i works fine, because it can run DDL and other sql or pl/sql statements sequencialy. But this sql*plus script cannot be called from application. So, application needs an stored procedure to do this task and then application call that procedure. But within stored procedure, i am unable to create table (or run any ddl statement). Can somebody help me in this?
    Thanks in Advance.

    Denis,
    The problem with Nicholas' suggestion isrelated to the fact that now you have two components
    (a table and a stored procedure)
    I don't see any problem to have "two
    components" here. After all, what about all others
    tabes ? This is only one more, but I don't understand
    why want manage less objects, that implies more code,
    more maintenance, and more difficulties to debug.
    Needless to say about performance...
    Nicolas.The same reasons apply if you were forced to declare all PL/SQL variables publicly (outside the stored proc.) rather than privately (from inside the stored proc). Naming conflicts for one. If the name that you want to use for the GTT already exists, you need to find a new name. With the SQL Server type local/private declarations, you wouldn't have that problem.
    I can see how performance would be the same or better using GTTs. If the number of records involved is low, this is likely negligable.

  • How to call a Oracle Form from within the APEX

    Hi,
    I have a requirment where need to call a oracle form from within the Oracle APEX application?
    I will appriciate if can someone help me out.
    Thanks

    Hi,
    are you working with Forms 6i or 10g?
    If you want to call a forms 10g page. Just use a button with javascript:
    - Target type: URL
    - URL Target: javascript:window.open ('http://<server>:<port>/forms/frmservlet?config=<conf>','Forms window');
    With Forms 6i you can open the directory where your forms file is inside (works just with IE):
    <script type="text/javascript">
    function fnc_window()  {w = open('C:\\FormsFiles', "winLov","scrollbars=yes,resizable=no,width=600,height=400");
    if (w.opener == null)
    w.opener = self;
    </script>Or execute the forms file with vbscript (IE only):
    <script language = "vbscript">
    sub fnc_forms()
    dim progName
    progName = "c:\FormsFiles\myForm.exe"
    set oShell = createobject("wscript.shell") 'create a shell
    '***use the line below to call your app, defined above with the "progName" variable:
    oShell.run(progName)
    end sub
    </script>

  • Passing a long string from Vb to stored proc

    Hi,
    I am passing a long string from Vb to this stored proc ..
    defn:
    Create Or Replace Procedure saveTaxFormInDB(intFormUID IN number,
    intCLUID IN number,
    PDFdata IN varchar2,
    Status IN OUT Varchar2) AS
    Problem lies with the string pdfdata. I am sending it from VB as:
    Set cmdParamStr = cmdAdoCmd.CreateParameter("Data", adVarChar,
    adParamInput, 32767, strData)
    I have checked the parameters in VB while sending and I have the
    correct string argument to be passed to "PDFData", But i am not
    sure if it is getting the value correctly.
    Because I know that the code is raising exception while
    accessing PDFData. (eg. in places like insert ..(pdfdata) and
    length(pdfdata)...)
    Please advise how i can solve this problem.
    Please Note that the string is not VERY large. I do not need to
    use LOBS in any way. the string is definitely within the limits
    of varchar2(which i think is 4000 chars.. correct me if i am
    wrong).
    Many thanks

    what is the backend MS SQl server or Oracle.??
    If it is MS SQLSERVER, then
    1.Create a SqlCommand object with the parameters as the name of the stored procedure that is to be executed and the connection object con to which the command is to be sent for execution.
    SqlCommand command = new SqlCommand("Name of StoredProcedure",con);
    2.Change the command objects CommandType property to stored procedure.
    command.CommandType = CommandType.StoredProcedure;
    3.Add the parameters to the command object using the Parameters collection and the SqlParameter class.
    command.Parameters.Add(new SqlParameter("@parametername",SqlDbType.Int,0,"Filedname"));
    4.Specify the values of the parameters using the Value property of the parameters
    command.Parameters[0].Value=4;
    command.Parameters[1].Value="ABC";
    If it is oracle,
    OracleConnection con = new OracleConnection("uid=;pwd=");
    try
    con.Open();
    OracleCommand spcmd = new OracleCommand("Name of StoredProcedure");
    spcmd.CommandType = CommandType.StoredProcedure;
    spcmd.Connection = con;
    spcmd.Parameters.Add("empid", OracleType.Number, 5).Value = txtEmpid.Text;
    spcmd.Parameters.Add("sal", OracleType.Number, 5).Value = txtSal.Text;
    spcmd.ExecuteNonQuery();
    }

  • Clearing Oracle Parameters to call diferent stored procs

    Sub Main
    Do While i < 3
    make_excel(i)
    i = i + 1
    Loop
    end Sub
    Sub make_excel(ByVal array As Integer)
    objCmd.Parameters.Add(New OracleParameter("p_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
    end Sub
    objCmd.Parameters.Clear()
    objCmd.Parameters.Remove("p_cursor")

    I agree with you. I was looking into mod_plsql, but it turns out that their development standards include not using Oracle HTTP server. The whole reason why they want to be able to execute a stored proc based on what is specified in an XML doc is that they want to avoid having to change their middle-tier configurations anytime a new stored proc or a change in stored proc parameters is made. I'm not familiar with what all is involved with .NET and the middle-tier, but supposedly this way, they can specify any stored procedure name and its parameters in an XML file. The XML is then suppose to be passed on to an Oracle stored procedure which will parse the XML and dynamically execute the stored procedure that was specified in the XML.
    Here is an example of the XML:
    '<Root>
      <PackageName>TEST_PKG</PackageName>
      <ProcedureName>TEST_PROC</ProcedureName>
        <Parameters> 
        <Parameter>
            <Name>EmpID</Name>
            <Value>12345</Value>
        </Parameter>
        <Parameter>
            <Name>Org</Name>
            <Value>ABC</Value>
        </Parameter>
        </Parameters>
    </Root>I basically need to parse out the pkg/proc names:
      SELECT t.COLUMN_VALUE.extract('//PackageName/text()').getstringval() PkgName,
             t.COLUMN_VALUE.extract('//ProcedureName/text()').getstringval() ProcName
         INTO v_pkg_name, v_proc_name
         FROM TABLE(xmlsequence(XMLTYPE(v_XML_input) .extract('/Root'))) t;...and then execute the procedure:
        EXECUTE IMMEDIATE 'BEGIN '||v_pkg_name||'.'||v_proc_name||'(:a, :b, :c); END;'
          using in v_in_param1, v_in_param2, out v_XML_output;The problem is that this approach is very complicated since there can be any number of IN/OUT parameters and of various datatypes. I would have to create all kinds of possible bind variables!

  • Using Java within a stored proc to access multiple database connections

    Hi List;
    We have an environment where we have needs to provide cross database visibility between Oracle, Sql Server and PostgreSQL. So we need the capability for Oracle to query PostgreSQL and Sql Server tables, PostgreSQL must be able to query Oracle and Sql Server tables and Sql Server must be able to query Oracle and PostgreSQL tables.
    I'm thinking that we can implement stored procs which are either written in java or call a java process . The java code in turn should be able to connect to any DBMS desired via JDBC query the tables in question and return the result set to the calling database.
    Any thoughts on how feasable this is would be appreciated. Does this seem like a solid solution? Any initial concerns or red flags? what about performance via JDBC?
    Thanks in advance for your help.

    John,
    from your description I understand that you essentially program the VO yourself. So I suggest that you read chapter 35.9 of the 'Fusion Developer’s Guide for Oracle Application Development Framework' (I guess you know where to find it). Since you still call the actual SQL not all of the chapter apply, but you get the idea how it works.
    And yes you analyzed the behavior correct. executeQueryForCollection() is allways called bevore getQueryHitCount().
    Timo

  • JNDI lookup from a Java stored proc?

    Anybody know if a JNDI lookup, or accessing an EJB from a Java stored procedure is possible? I looked through all the docs and it says it is possible but doesn't specify how. In the java class thats resolved through the stored proc, how are the server generated classes and interfaces made available? Normally setting the classpath for the client app that does the lookup accomplishes this, but what if its called through the stored proc?

    check the rdbms platform's "javavm" folder for a "readme.txt" file ...
    In section 3.16.9, it discusses how to do this ...

  • SELECT query from within a stored procedure

    DB Version:10gR2
    For auditing purpose, i just want to execute the query within the IF condition, and get the results for spooling. But i am getting PLS-00428 error. Can't i just execute a SELECT query and get its results displayed in SQLPLUS so that i can spool them?
    SQL&gt; create or replace procedure ship_dtl_aud
      2  is
      3  v_exists number;
      4 
      5  begin
      6  
      7  Select count(1) into v_exists
      8  From ship_dtl
      9  WHERE track_code = 10
    10  AND mod_date_time &lt; SYSDATE - 1/(24*60);
    11 
    12   if v_exists&gt;0
    13   then
    14            select s.username,s.sid, s.serial#, s.terminal,p.spid
    15   from v$session s, v$process p
    16   where s.paddr = p.addr and s.sid in (select SESSION_ID from V$LOCKED_OBJECT);
    17 
    18          end if; 
    19  end;
    20  /
    Warning: Procedure created with compilation errors.
    SQL&gt; show errors
    Errors for PROCEDURE ship_dtl_aud:
    LINE/COL ERROR
    14/11    PLS-00428: an INTO clause is expected in this SELECT statement

    Within PL/SQL code, the results of a query have to be returned from the SQL engine to the PL/SQL engine, hence why it is asking you to include an INTO within your query. Note that the PL/SQL engine is running on the database server so it has no interface to display output to. To output from within PL/SQL you would have to write the data out yourself to whatever output you want e.g. use DBMS_OUTPUT to put the data to the standard output buffer (which can then be read by SQL*Plus if serveroutput is set to "on") or written out to a file on the server, or written out to a table.
    You are assuming that because you can execute SQL from SQL*Plus and spool the output, you can do the same within PL/SQL. This is not the case. When SQL*Plus issues a SQL statement, it goes to the SQL engine and the results of that cursor (as an SQL query is a cursor) are collected by SQL*Plus and it displays them itself. When PL/SQL issues a SQL statement, it goes to the SQL engine and the results of that cursor come back to PL/SQL. PL/SQL doesn't have a display mechanism, so the results have to be collected INTO something.
    Hope that's clear.

  • Call Developer 2000 Reports/Forms from PL/SQL stored proc.

    Hello all,
    I am searching for a method for a stored procedure on Oracle 8.0 to call a Oracle Developer 2000 Report or Form.
    Any suggestions,
    Thanks,
    Julian

    No offense,
    Do you mean calling a trigger in a Form or Report to fire off another of the same? Or do you mean how do I fire Forms from a Database stored procedure?
    Please I don't mean any offense, it is just hard, sometimes to say simple concepts and not sound, well, bad.
    Otherwise think about it. A Stored procedure is run inside the database, it has no idea where you client is, and doesn't know which type of client you have (X-Windows, Microsuck), and doesn't know how to fire off an app on the client.
    One concept that is hard, sometimes, to get is where things are run. Forms runs on an Apps Server (Java screens), or a client, like on a PC. Stored procedures run, usually, on a whole different box, a database server. The database server is not that well connected that it can fire off a app on a client. Try to go to a Unix database server and run a command to fire off Internet Explorer on your client!? Not real easy to do.

  • Calling ORACLE Functions from within CF Builder report

    Hi, I have an ORACLE function that I would like to call from within my CF REPORT.
    I know there is a section in the report builder where you can write coldfusion code to perform tasks, but I would rather simply call the ORACLE function for each detail row in the report
    I do not want to call this function from within my main ORACLE query that I use for the report, so please don't suggest that.
    Thanks so much.
    -Jim

    6.0.5 is not certified against 10g database, so I suggest to upgrade to 6.0.8.26 (6i patch 17) first to see if the problem is gone.

  • How to call a Oracle Form from within the oracle APEX application

    Hi,
    I am new for Oracle APEX. I have a requirment where need to call a Oracle form (.fmx file) from within the Oracle APEX application.
    Can someone help me out ?
    it would be a great help.
    Thanks

    This might help you...
    http://roelhartman.blogspot.com/2008/11/integrate-oracle-forms-with-apex.html

  • Sending email from within a stored procedure

    Is it possible to send and email within a stored procedure written in PL/SQL. I have searched this site and the web for an Oracle package which simulates a mail agent written in PL/SQL, but I have not had any success.
    null

    Well, on NT one way we did it was to link to kernel32.dll so we could execute OS commands (WinExec), and did the email that way.
    Here's a bit of script to try:
    connect sys/@db;
    drop library kernellib;
    CREATE LIBRARY kernellib as 'c:\winnt\system32\kernel32.dll';
    show errors
    CREATE OR REPLACE PACKAGE UTIL IS
    function run(lpCmdLine IN varchar2, nCmdShow IN binary_integer) return binary_integer;
    end;
    show errors
    CREATE OR REPLACE PACKAGE BODY UTIL IS
    function run(lpCmdLine IN varchar2, nCmdShow IN binary_integer) return binary_integer
    AS EXTERNAL
    NAME "WinExec"
    LIBRARY kernellib
    parameters (lpCmdLine STRING, nCmdShow long);
    end;
    show errors
    Then you just call util.run() with an appropriate command line to send email. Bit of a hack, but it depends on what you want to do with it. Another hack would be to use the UTL_HTTP package to submit a form to your web server and use a CGI program to send the email.

  • Executing a stored proc from inside a stored proc

    Hi,
    I'm trying to execute a stored procedure from inside another stored procedure, and I can't seem to work out the correct syntax to use, could someone please give me a pointer, it's starting to drive me insane :]
    CREATE OR REPLACE PROCEDURE foo (blah in type) AS
    BEGIN
    EXEC OTHER_STORED_PROC();
    END;
    Thank you kindly,
    Anthony...

    EXEC is a SQL*Plus command, not PL/SQL syntax. In SQL*Plus, EXEC <<procedure name>> is just shorthand for
    BEGIN
      <<procedure name>>
    END;Calling a stored procedure from another stored procedure (or any PL/SQL block), can bypass the extra begin/end pair because it's already inside a PL/SQL block. Thus, the syntax you need is just
    CREATE OR REPLACE PROCEDURE foo (bar IN type)
    AS
    BEGIN
      other_stored_procedure();
    END;Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • Running "Host" From Within a Stored Procedure

    Hellow
    Wanna Run a "Host" Command from Within A SP
    or DB Trigger
    Any Help is Appreciated !!
    Regards
    Tariq

    the only way to run an OS command from within the database is through extproc
    (works from 8.x onwards).
    Essentially, you have to:
    - modify the database listener to support external procedure calls
    - create a library object
    - create a C - program and compile it as a shared library
    - write a wrapper function in PL/SQL that calls the shared library
    I can send you an example, if you want.
    Regards
    Anton Weindl

  • Pro Oracle App Express issue : Running stored proc from link in e-mail..

    Just ran into an issue and need some help with it. A person I work with was using code from John Scott's book (Great Book for APEX!!) and was using the verification e-mail link code, when it started acting up.
    The e-mail that is sent is to call a procedure in a database package (pkg_auth) procedure is called send_verification_email. We moved his code up to my hosted area on Oracle's site so I could help further.
    The e-mail is sent properly, but when the link is clicked through, the following error is returned from the server:
    Bad Request
    Your browser sent a request that this server could not understand.
    mod_plsql: /pls/otn/f HTTP-400 Missing '=' in query string or post form
    The link that is being clicked is:
    [http://apex.oracle.com/pls/otn/ACT_SOFTWARE.pkg_auth.verify_user?p_user=becky&p_code=D62B94845A5E8A5149CCB391CE53D31B]
    Two parameters being passed are user name and a verification key.
    I am stumped since we compared his code to what John has in his book and except for changes in e-mail addresses and server information (don't visit apexdemo.com, its a company in Washington state..)
    Thank you,
    Tony Miller
    Webster, TX

    Only tested on Oracle's site right now. He was working on local machine with code, thus we moved to hosted site so we could work together..
    Execute rights granted to PUBLIC for named package.
    WWV_FLOW_EPG_INCLUDE_MOD_LOCAL: Since this is on Oracle's hosted site, can't really change this setting..
    Funny thing is, I believe before the 3.2.1 update, I had a version of this working in a demo for someone (deleted it since then...) now it seems to be having issues..
    Strange, the url is being re-written as : [http://apex.oracle.com/pls/otn/f?p=&APP_ID.:101:&APP_SESSION.] after the error is displayed. Also that the url seems to long for the address bar and I need to scroll right..
    Thank you,
    Tony Miller
    Webster, TX
    Edited by: Tony Miller on Oct 14, 2009 1:51 PM

Maybe you are looking for

  • Problem in the code while fetching records and displaying in the screen

    Hi,    I have developed a screen which is having various fields, all the records are stored in a ztable,when i enter the records into various i/o fields and press submit pushbutton they are stored in the table now, what i wont is when i enter one rec

  • Xorg.conf ... alternative ?

    May be this sounds weird but,... is there any alternative to using xorg.conf ? Why I'm asking this is that I examined my fedora 9 ( I have dual boot machine) xorg.conf, wich has nothing about the screen or modes and resolutions... same is ubuntu ...

  • Cardbus PCMCIA adaptor on Solaris 2.5.1

    I've tried to install a PCMCIA adaptor, CardBus type and from SCM Microsystem, on a E-250 running Solaris 2.5.1 but failed. The OS can just recognize there is a cardbus device and does not attach the correct PCMCIA driver 'spcic'. Can anyone give som

  • Constant writing to disk - how can I stop it?

    According to Activity Monitor it might be something called "nsurlstoraged" - which I never installed.  This only just started happening when I went from Mavericks to Yosemite. I can hear the HDD writing stuff constantly even when the computer is idle

  • Cannot add a device to Firefox Sync using passcode.

    I am running Firefox/3.6.15 on a MacBook Pro, Mac OS 10.6.6. Each time I click Add a device in the Sync Preferences window, I am taken to the How do I add a device to Firefox Sync web page. It does not display the window where I can enter a passcode