Function of 'Declare' in Stored Procedure statements
Dear Readers,
Can someone tell me what is the difference when we use Declare and don't use declare in the create stored procedure statement. Please see below:
Create proc education
AS
Declare @name varchar(20)
Select @name='John'
GO
When I run this store procedure nothing is happening, I don't know why?
BUT
When I run the same procedure without Declare it runs. see e.g. below:
Create Proc learn
@name varchar(20)
AS
Select @name
GO
It runs successfully. What is the difference between Declare and when I don't use Declare?
Try:
Create proc education
AS
Declare @name varchar(20)
Select @name='John'
Select @name
GO
exec education;
-- John
The first SELECT is only an assignment statement. You can use SET as well.
Create proc education1
AS
Declare @name varchar(20)
SET @name='John'
Select @name
GO
exec education1;
-- John
In the parameterized sp, the @name is set when the sp is called (exec).
Example for stored procedure with parameters:
http://www.sqlusa.com/bestpractices2008/stored-procedure-parameters/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
Similar Messages
-
Exponent Function on a Stored Procedure
I am using an exponent function in an Oracle Stored Procedure (Oracle 7.3.4). the exponent function is causing the stored procedure to run a long time. If I take the exponent function out the procedure runs in 2 minutes to process 289000 records, when I put the statement back in the procedure runs in 17 minutes. We are running oracle in HP Unix.
The format of the statemenT is
VARIABLE = EXP((VAR1 - VAR2)/VAR3)
Does anyone have any reason why the EXP function causes the procedure to run longer?Hello,
I think that my question was not clear enough. I did not got any reply to my question.
But after several hours of investigation (ASI: Apex Scene Investigation) I discovered a good way to the solution.
And that is: Collections!!
I will close this thread as answered.
Greetings
Carlos
Edited by: IsolraC on Jan 14, 2009 11:24 AM -
Using writetext function in a stored procedure for Sybase 11.5
Hello,
I need to execute the writetext function inside a Sybase stored procedure to insert varchar data of approximately 4k size.
how to specify data parameter in writetext fot that?The split function Scott used is some variant on one of the solutions posted in the Ask Tom link I posted. More specifically, it is probably a variant on either one of the pipelined function solutions, or one based on splitting the string into a SQL table of objects.
Look at Tom's original response to the question for a working solution. If you have a reasonably new version of Oracle, then you may also want to look at the modificataion/modernization later in the thread which can be found here
HTH
John -
Function calling stored procedure that returns a cursor into a LOV
Hello,
Is it possible in HTML DB to implement a process that has a function that calls a stored procedure that returns a cursor, used to then populate a select list?
Or can I do a function call to a stored procedure in the 'List of values definition' box for the item itself that returns a cursor to populate the item's select list?Hi Vikas,
Actually, I just found another posting that shows how to do what I'm looking for:
Re: Filling a LOV with a cursor
Check it out. I posted another question in response to that discussion...maybe you could answer that? Thanks!
Laura -
Error - remote stored procedure includes in a function
Hi,
I have a stored procedure, it runs properly
ecos.GetCustTier@BSCSDEV in PL/SQL
But after included into function F_GETCUSTTIER, it comes error.
SQL> select f_getcusttier(585510,'20020808') from dual
ORA-06571: Function F_GETCUSTTIER does not guarantee not to update database
[Function F_GETCUSTTIER]
create or replace FUNCTION f_getcusttier(
Begin
ecos.GetCustTier@BSCSDEV(i_customer_id, i_at_date, o_seqno, o_custcode, o_tier_id, o_tier_des, o_join_date, o_join_reason,
o_renewal_date, o_next_review_date, o_last_review_amt_no, o_exit_date, o_exit_reason,
o_input_by, o_input_date, o_update_by, o_update_date, o_expiry_date, o_next_job_review_date,
o_status_id, o_return_code);
RETURN o_tier_id;
I also try to create a package for this function
CREATE OR REPLACE PACKAGE abc AS
FUNCTION f_getcusttier(i_customer_id number, i_at_date varchar2) RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES(f_getcusttier, WNDS);
END abc;
CREATE OR REPLACE PACKAGE BODY bwan AS
FUNCTION f_getcusttier(
i_customer_id in number,
i_at_date in varchar2
Begin
ecos.GetCustTier@BSCSDEV(i_customer_id, i_at_date, o_seqno, o_custcode, o_tier_id, o_tier_des, o_join_date, o_join_reason,
o_renewal_date, o_next_review_date, o_last_review_amt_no, o_exit_date, o_exit_reason,
o_input_by, o_input_date, o_update_by, o_update_date, o_expiry_date, o_next_job_review_date,
o_status_id, o_return_code);
RETURN o_tier_id;
But with Warning: Package Body created with compilation errors.
2/1 PLS-00452: Subprogram 'F_GETCUSTTIER' violates its associated
pragma
How can I fixed it? Can function pack with remote stored procedure?
DB version: 8.0.4.4.0
I know that this problem is resolved in Release 8.1, is it no solution for release 8.0.4.4.0?First of all, please do not post three separate threads for the one problem. It simply clutters up the forum for the rest of us.
Prior to 8i you need to explicitly guarantee that your function does not write to the database. You do this with the RESTRICT_REFERENCES pragma:
CREATE PACKAGE yr_package AS -- package specification
FUNCTION whatever
(pn IN NUMBER) RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (whatever, WNDS);
END yr_package;The following link goes to a page of helpful stuff assembeled by some of use regulars:Re: How to attach a java bean in forms6i
It includes jumps to the Oracle online documentation. You may find the Application Developer's Guide - Fundamentals an instructive read.
Regards, APC -
OCI8: returning cursors from stored procedures
The short version of my question is:
In OCI8, how do open a cursor from the database stored procedure, return it to my C++ program and fetch from it, given that in OCI8 cursors and cursor functions are becoming obsoleted?
The long version of the same question is:
I am converting my C++ code from the Oracle 7.3 OCI driver to the Oracle8 OCI driver. One thing I did very frequently in Oracle 7.3 OCI code is open a multi-row select cursor within a stored procedure and return that cursor to my program. In the program, I would then do the fetching with the returned cursor. This was very useful, as it allows me to change the queries in the stored procedure (for example, to append information to certain columns or make some data in all uppercase) without recompiling the application due to a changed SQL string.
My 7.3 psuedocode is as follows:
stored procedure def:
TYPE refCurTyp IS REF CURSOR;
FUNCTION LoadEmployeeData RETURN refCurTyp;
stored procedure body:
FUNCTION LoadEmployeeData RETURN refCurTyp IS
aCur refCurTyp;
BEGIN
OPEN aCur FOR
SELECT emp_id, emp_name
FROM employee_table
ORDER BY emp_name;
return aCur;
END;
OCI code: // all functions are simplified, not actual parameter listing
// declare main cursor variable #1 and return cursor variable #2
Cda_Def m_CDAstmt, m_CDAfunction;
// open both cursors
oopen(m_CDAstmt, ...);
oopen(m_CDAfunction, ...);
// bind cursor variable to cursor #2
oparse(&m_CDAstmt, "BEGIN :CUR := MYPACKAGE.LoadEmployeeData; END;");
obindps(&m_CDAstmt, SQLT_CUR, ":CUR", &m_CDAfunction);
// run cursor #1
oexn(&m_CDAstmt);
// bind variables from cursor #2, and fetch
odefineps(&m_CDAfunction, 1, SQLT_INT, &m_iEmpId);
odefineps(&m_CDAfunction, 2, SQLT_CHAR, &m_pEmpName);
while (!ofen(&m_CDAfunction))
// loop: do something with fetch
// values placed in m_iEmpID and m_pEmpName
This works perfectly, and has really helped to make my code more maintainable. Problem is, in Oracle 8 OCI both cursors and the cursor functions (such as oopen()) are becoming obsoleted. Now it uses statement and environment handles. I know I can still use Cda_Def and cursors--for a while--within OCI8, but I need to know the official up-to-date method of returning a cursor from the database and fetching within my C++ code. Any code fragment, or explanation of what I need to do in OCI8 would be appreciated (perhaps I need to bind to a statement handle instead? But the stored procedure still returns a cursor.)
The Oracle8 OCI has a new SQLT_ type, SQLT_RSET, which the header file defines as "result set type". Unfortunately, it's almost completely undocumented in the official documentation. Am I supposed to use this instead of the obsolete SQLT_CUR?
Thanks,
Glen MazzaEmail me diorectly and I will get you some code that might help. I fail to see the relevance of posting this type of information in the JDeveloper forum.
-
Call to Oracle stored procedure that returns ref cursor doesn't work
I'm trying to use an OData service operation with Entity Framework to call an Oracle stored procedure that takes an number as an input parameter and returns a ref cursor. The client is javascript so I'm using the rest console to test my endpoints. I have been able to successful call a regular Oracle stored procedure that takes a number parameter but doesn't return anything so I think I have the different component interactions correct. When I try calling the proc that has an ref cursor for the output I get the following an error "Invalid number or type of parameters". Here are my specifics:
App.config
<oracle.dataaccess.client>
<settings>
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.0" value="implicitRefCursor metadata='ColumnName=WINDFARM_ID;BaseColumnName=WINDFARM_ID;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Number;ProviderType=Int32'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.1" value="implicitRefCursor metadata='ColumnName=STARTTIME;BaseColumnName=STARTTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.2" value="implicitRefCursor metadata='ColumnName=ENDTIME;BaseColumnName=ENDTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.3" value="implicitRefCursor metadata='ColumnName=TURBINE_NUMBER;BaseColumnName=TURBINE_NUMBER;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.4" value="implicitRefCursor metadata='ColumnName=NOTES;BaseColumnName=NOTES;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.5" value="implicitRefCursor metadata='ColumnName=TECHNICIAN_NAME;BaseColumnName=TECHNICIAN_NAME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
</settings>
OData Service Operation:
public class OracleODataService : DataService<OracleEntities>
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("GetWorkOrdersByWindfarmId", ServiceOperationRights.All);
config.SetServiceOperationAccessRule("CreateWorkOrder", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
[WebGet]
public IQueryable<GetWorkOrdersByWindfarmId_Result> GetWorkOrdersByWindfarmId(int WindfarmId)
return this.CurrentDataSource.GetWorkOrdersByWindfarmId(WindfarmId).AsQueryable();
[WebGet]
public void CreateWorkOrder(int WindfarmId)
this.CurrentDataSource.CreateWorkOrder(WindfarmId);
Here is the stored procedure:
procedure GetWorkOrdersByWindFarmId(WINDFARMID IN NUMBER,
P_RESULTS OUT REF_CUR) is
begin
OPEN P_RESULTS FOR
select WINDFARM_ID,
STARTTIME,
ENDTIME,
TURBINE_NUMBER,
NOTES,
TECHNICIAN_NAME
from WORKORDERS
where WINDFARM_ID = WINDFARMID;
end GetWorkOrdersByWindFarmId;
I defined a function import for the stored procedure using the directions I found online by creating a new complex type. I don't know if I should be defining the input parameter, WindfarmId, in my app.config? If I should what would that format look like? I also don't know if I'm invoking the stored procedure correctly in my service operation? I'm testing everything through the rest console because the client consuming this information is written in javascript and expecting a json format. Any help is appreciated!
Edited by: 1001323 on Apr 20, 2013 8:04 AM
Edited by: jennyh on Apr 22, 2013 9:00 AMMaking the change you suggested still resulted in the same Oracle.DataAccess.Client.OracleException {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETWORKORDERSBYWINDFARMID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"} System.Exception {Oracle.DataAccess.Client.OracleException}
I keep thinking it has to do with my oracle.dataaccess.client settings in App.Config because I don't actually put the WindfarmId and an input parameter. I tried a few different ways to do this but can't find the correct format. -
JDBC - how to call Stored Procedure
Hi! My problem is that I can't call a procedure created at my DB through JDBD. I have a similar stored function working fine (code->
String query = "begin :1 := funcStored; end;";
CallableStatement cstmt = connection.prepareCall(query);
cstmt.registerOutParameter(1,OracleTypes.CURSOR);
cstmt.execute();
ResultSet rset = (ResultSet)cstmt.getObject(1);
But I don't want a Stored Function, I want a Stored Procedure that is getting hard making it to work (to call more precisely).
Here is the wrong code where I need help ->
String query = "{call ? := procedureStored(P_CURSOR)}";
That gives a error saying P_CURSOR is not declared but how I declare through Java and call the SP??
Thanks a lot for helping!
//The code of SP
create or replace package types
as
type cursorType is ref cursor;
end;
create or replace procedure procedureStored( p_cursor out types.cursorType )
as
begin
open p_cursor for SELECT ..........
end;
//------------- ENDProblem solved !!
String query = "{call procedureStored(?)}"; !!!
and not what i was doing...
String query = "{call ? := procedureStored(P_CURSOR)}"; -
Error calling Java in Oracle Stored Procedure
I can call a java function inside my Oracle Stored Procedure, but if I reference a class that uses JNI, I get problems. I don't know what forum to post this under. This seems the closest match.
Here is my error:
java.lang.NoClassDefFoundError
at AcmeComp.ec.Motor.<init>(Motor.java:35)
at BBOra.runBB(BBOra:13)
Here is my java class, BBOra.java:
import AcmeComp.ec.*;
class BBOra {
static String strCnt;
BBOra() {}
public static void runBB() {
try {
//Motor class is in AcmeComp.ec package
Motor eng = new Motor();
} catch(Exception e) {
System.out.println("Error: " + e);
public static void runNonBB() {
System.out.println("runNonBB works ok.");
From DOS prompt, I loaded ac222ec.jar (has the AcmeComp.ec package) and BBOra.java files into Oracle:
loadjava -u system/manager -resolve -verbose ac222ec.jar.java
loadjava -u system/manager -resolve -verbose BBOra.java
From SQL Plus, I created 2 stored sprocedures:
CREATE OR REPLACE PROCEDURE runBB
AS LANGUAGE JAVA
NAME 'BBOra.runBB()';
CREATE OR REPLACE PROCEDURE runNonBB
AS LANGUAGE JAVA
NAME 'BBOra.runNonBB()';
From SQL Plus, I gave myself permissions to load libraries, so I can load ac222ecjni.dll, which has all the Native (C++) code I use:
BEGIN
DBMS_JAVA.GRANT_PERMISSION('SYSTEM',
'java.lang.RuntimePermission',
'loadLibrary.*');
END;
From SQL Plus, I set up my output:
set SERVEROUTPUT ON;
CALL dbms_java.set_output(3000);
From SQL Plus, I called my Stored Procedures:
CALL runNonBB();
CALL runBB();
runNonBB() works great, but runBB() gives me the error I listed above. The Motor class that BBOra calls, itself calls a class NMotor, which has a call:
static {
System.loadLibrary("ac222ecjni");
Unfortunately, I don't know the inner workings of the native code. Does "at AcmeComp.ec.Motor.<init>(Motor.java:35)"? mean JServer was able to see the class "Motor", but not instatiate it? Or did it error trying to create the class "NMotor"?
Here's a snippet of Motor:
package AcmeComp.ec;
public class Motor implements IMotor {
public Motor() {
motor = new NMotor();
some functions
private NMotor motor;
Here's a snippet of NMotor:
package AcmeComp.ec;
class NMotor {
NMotor() {
sunjdk = true;
some native method declarations
private boolean sunjdk;
static {
//ac222ecjni.dll has all the Native (C++) code
System.loadLibrary("ac222ecjni");
PLEASE HELP ME FIGURE THIS OUT. IT IS KILLING ME. I can even look into the USER_OBJECTS view in Oracle and see that ALL of the classes from the ac222ec.jar are present and accounted for.Man, I guess I figured it out myself. Ten Duke dollars to myself. But, for the sake of anyone who may want to know the answer, here it is:
JServer (or Oracle9i JVM in Oracle 9i) does not support JNI. Here is their (weak) reasoning, taken from "Oracle9i Java Developer's Guide" as found in http://www.csis.gvsu.edu/GeneralInfo/Oracle/java.920/a96656/invokeap.htm#1007948
"Oracle does not support the use of JNI in Oracle9i Java applications. If you use JNI, your application is not 100% pure Java, and the native methods require porting between platforms. Native methods have the potential for crashing the server, violating security, and corrupting data."
Sounds like a fancy way to say they have a limitation--their JVM isn't up to par all the way. If JNI is a feature in Java, why should Oracle decide for me if I should use it? Don't Java methods also have the potential for crashing the server, violating security, and corrupting data? I think they should just provide the functionality you would expect from a VM and let the user decide which functionality to use. In my case, I HAVE to use JNI, so I'd have to use RMI so that a different VM can do the JNI part.
Sounds pretty lame of Oracle, but oh well. -
How to write stored procedures
hi
how you will write stored procedures in jdbc .could u pls tell me the procedure?what is key in jdbc where you will use that in which situation?could ugive me the answer briefly
thanks
nagHi
A stored procedure is a subroutine available to applications accessing a relational database system. Stored procedures (sometimes called a sproc or SP) are actually stored in the database.
Stored procedures are similar to user-defined functions (UDFs).
A stored procedure is a group of SQL statements that form a logical unit and perform a particular task, and they are used to encapsulate a set of operations or queries to execute on a database server
Use this
http://www.ics.com/support/docs/dx/1.5/tut6.html
http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
http://www.sqlteam.com/article/stored-procedures-an-overview
Thanks -
Ampersand substitution in create or replace procedure statement
Hi Guys,
I wonder why my ampersand substitution does not work in a create or replace stored procedure statement.
CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS
UNDEFINE DimSales;
UNDEFINE FactTable;
DEFINE DimSales = 'TESTTAB';
DEFINE FactTable = myfact;
BEGIN
Error(5,20): PLS-00103: Encountered the symbol "=" when expecting one of the following: := . ( @ % ; not null range default character
If I then assign the value with := I get the error "invalid table" later on for the INSERT statemnt:
CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS
UNDEFINE DimSales;
UNDEFINE FactTable;
DEFINE DimSales := 'x2';
DEFINE FactTable := 'x1';
BEGIN
INSERT INTO &DimSales (column1, column2,...)
Why does ampersand substitution not work within a stored procedure?Hi,
Thanks for the suggestion.
The IF---ELSE Logic I have to write is quite complex.
I dont think joins will not do the trick and limiting the collection size to smaller than 4000 seems not very practical. there
is no poin using a collection if I have to use X amout of them.
UNDEFINE DimSALES;
UNDEFINE FactTable;
DEFINE DimSALES = 'TESTTAB';
DEFINE FactTable = 'testfact';
--Collect all distinct SELLERNr into materialized views
CREATE MATERIALIZED VIEW v1 AS select distinct SELLERnr from &FactTable;
CREATE MATERIALIZED VIEW v2 AS select distinct SELLER_ID from &DimSALES;
DECLARE
v_SELLERNr VarChar(9);
CURSOR v1_cursor IS Select * from v1;
l_exists INTEGER;
BEGIN
OPEN v1_cursor;
LOOP
FETCH v1_cursor INTO v_SELLERNr;
EXIT WHEN v1_cursor%NOTFOUND;
SELECT COUNT(*) INTO l_exists FROM v2 WHERE SELLER_id =v_SELLERNr AND ROWNUM = 1;
IF l_exists <> 1 THEN
INSERT INTO &DimSALES (K_SALES,REG,BVL,DS, VS,RS,SELLER_ID,VK,VALID_FROM)
(SELECT SEQ_DIM_SALES.NEXTVAL ,REG, BVL,DS, VS,RS,SELLERNR,VK,sysdate from &FactTable where SELLERNR =v_SELLERNr);
commit;
ELSE
--Update old combination(s), invalidate (DATE)
UPDATE &DimSALES SET VALID_TO = SYSDATE -1 WHERE REG||BVL||DS||VS||RS||SELLERNR||VK IN(
--In case the SELLER and combinations exists and differs from what is in the dimension then invalidate old combinations and insert new ones
SELECT * FROM(
SELECT REG||BVL||DS||VS||RS||SELLERNR||VK WHERE SELLERNR = v_SELLERNr FROM &FactTable;
MINUS
SELECT REG||BVL||DS||VS||RS||SELLERNR||VK WHERE SELLERNR = v_SELLERNr FROM &DimSALES;)
commit;
--Insert new combination
INSERT INTO &DimSALES (K_SALES,REG,BVL,DS, VS,RS,SELLER_ID,VK,VALID_FROM)
(SELECT SEQ_DIM_SALES.NEXTVAL ,REG, BVL,DS, VS,RS,SELLERNR,VK,sysdate from &FactTable where SELLERNR =v_SELLERNr) subselect;
WHERE &DimSALES.SELLER_Id=v_SELLERNr AND subselect.REG||BVL||DS||VS||RS||SELLERNR||VK NOT IN &DimSALES.REG||BVL||DS||VS||RS||SELLERNR||VK
commit;
END IF;
END LOOP;
CLOSE v1_cursor;
END;
DROP MATERIALIZED VIEW v1;
DROP MATERIALIZED VIEW v2;
----------------- -
Stored Procedure Command issues in CS3
I've been having a problem using some stored procedures in
CS3 which had previously worked with no issue in 8.0.2. I'm running
CS3 on a Mac for ASP & SQL Server 2000.
The input parameters for the stored procedure are...
Fieldname: CategoryID (int) length: 4
Fieldname: Men (bit) length: 1
Fieldname: Women(bit) length:1
I have no problem using the Command function to call this
stored procedure in DW 8.0.2, but in CS3, while I am able to TEST
the recordset successfully within the Command dialog, when I press
OK and then attempt to view the field list in the Bindings panel, I
get this error...
[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure
'spCategoryProduct' expects parameter '@Men', which was not
supplied.
When I open up the command settings dialog again, Default
Values and the Runtime Values I entered for the Men and Women bit
parameter are blank. The only Default Value and Runtime Value
retained is for the field CategoryID.
CS3 is able to call other stored procedures which do not
contain a Bit field type without issue, so I'm curious if this is
the culprit.
I have DW8.0.2 still installed on the same system, and have
been able to call this stored procedure in this older version,
without any problems.
Please help!Holy thread-resurrection Batman!
Please open a new dicussion after reading the bi4.0 data access guide: http://help.sap.com/businessobject/product_guides/boexir4/en/xi4sp5_data_acs_en.pdf
Also, please specify which SP and Patch you are using.
Regards,
H -
Using a stored procedure for a sender jdbc adapter
Hi all,
The requirement is to use a stored procedure, for extracting data from a oracle database.
Is it possible to do this.
If yes, what should be the source structure in this case.
Please help with the exact soln.
Thanks!!
YounusHi,
Did you check the blog pointed by Aamir?
/people/jegathees.waran/blog/2007/03/02/oracle-table-functions-and-jdbc-sender-adapter
You will need to use Oracle Functions instead of Oracle Stored Procedures. Read thru the blog and the note pointed in the blog . Think it is quite a good example.
Regards
Bhavesh -
C code in stored procedure ?
Is it possible to invoke a C function/ program in a stored procedure? How?
Read these lines. If you needs more: [email protected]
=======================================================================
Bookmark Fixed font Go to End
Doc ID: Note:99136.1 Content Type: TEXT/PLAIN
Subject: Calling Operating System Commands from PL/SQL using External Procedures Creation Date: 15-FEB-2000
Type: BULLETIN Last Revision Date: 27-NOV-2001
Status: PUBLISHED
Overview
The ability to call operating system commands from PL/SQL is a feature that
is easily implemented in Oracle8 using External Procedures. This article
contains a simple example of implementing this functionality.
Note: The example in this article was created on Solaris and tested with
Oracle 8.0.4 and 8.0.5.
Listener Configuration
The following represents a typical listener.ora configuration. Details
for your particular installation may vary.
LISTENER_PROC =
(ADDRESS_LIST =
(ADDRESS= (PROTOCOL= IPC)(KEY=external))
(ADDRESS= (PROTOCOL= TCP)(HOST=otcsol1)(PORT=23000))
SID_LIST_LISTENER_PROC =
(SID_LIST =
(SID_DESC =
(SID_NAME = L804)
(ORACLE_HOME = /u11/app/oracle/product/8.0.4)
(SID_DESC =
(SID_NAME = external)
(ORACLE_HOME = /u11/app/oracle/product/8.0.4)
(PROGRAM = /u11/app/oracle/product/8.0.4/bin/extproc)
(ENVS='PATH=/bin:/usr/bin:/usr/ccs/bin:/usr/ucb')
# The ENVS is used to define any environment variables that will
# be used by the external procedure.
STARTUP_WAIT_TIME_LISTENER_PROC = 0
CONNECT_TIMEOUT_LISTENER_PROC = 10
TRACE_LEVEL_LISTENER_PROC = OFF
TNSNAMES.ORA Configuration
The following represents a typical tnsnames.ora configuration. Details
for your particular installation may vary:
extproc_connection_data =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = external))
(CONNECT_DATA = (SID = external)(SERVER=DEDICATED))
L804=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(Host = otcsol1)(Port = 23000))
(CONNECT_DATA = (SID = L804))
External Procedure Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void sh(char *);
void sh( char *cmd )
int num;
num = system(cmd);
Issue the following commands to compile the code and generate the shared
object in Solaris:
cc -G -c shell.c
ld -r -o shell.so shell.o
You can also use the demo_rdbms.mk makefile to build shared libraries
for use in external procedures. Using this method insulates you from
any Operating System specific dependencies (e.g., which flags to use
for ld).
For example:
In 8.0.X,
$ make -f demo_rdbms.mk extproc_nocallback \
SHARED_LIBNAME=shell.so OBJS=shell.o
In 8.1.X,
$ make -f demo_rdbms.mk extproc_no_context \
SHARED_LIBNAME=shell.so OBJS=shell.o
Library Definition
CREATE LIBRARY shell_lib is '/u11/home/lsupport/proc/shell.so';
Note: The directory in quotes is the current of location of the library that
was created in the steps above.
PL/SQL Wrapper Procedure
create or replace procedure shell(cmd IN char)
as external
name "sh"
library shell_lib
language C
parameters (cmd string);
Execution
SQL> exec shell('ls');
cli.trc exe_prba.sql prueba.mk shell.c.old
core listener.old prueba.o shell.o
dec2bin.c listener.ora prueba.so shell.so
dec2bin.c.old nena.lst prueba.sql shell.sql
dec2bin.o p.sql sal.1 shell.sql.old
dec2bin.so pepito.lst sal.2 sqlnet.log
dec2bin.sql prb sal.3 tnsnames.ora
dec2bin.sql.old prb.c salida.lst tnsnames.ora.old
envoltorio.sql prueba.c shell.c uno.sql
PL/SQL procedure successfully completed.
The output produced by the executed command is not viewable in general since
it is directed to the controlling terminal for the extproc process. The
extproc process inherits its controlling terminal from the listener, which in
turn inherits its terminal from the shell used to start the listener. If this
shell is no longer visible, the output is never displayed.
To see the output returned from the system command, redirect the output to a
file and then view/process the output file. This can be done simply on UNIX
platforms by appending "> myoutput.txt" to the command being executed.
Standard error can be redirected similarly.
The executed commands only see the directory pointed by the TNS_ADMIN
environment variable defined in the server, therefore, when specifying a file,
be sure to include the path of its desired location.
References
[NOTE:14082.1] Dynamic SQL and System Commands Using DBMS_PIPE
[NOTE:74159.1] External Procedures Using Pro*C
[NOTE:68061.1] Creating External Procedures on Windows NT
"PL/SQL User's Guide and Reference, Release 8.0"
"Oracle8i Application Developer's Guide - Fundamentals"
====================================================================
CREATE OR REPLACE procedure up_sim_exec_shell(p_comand IN VARCHAR2)
as external
name "sh"
library shell_lib
language C
parameters (p_comand string); -
How to display stored procedure results in SJSC table?
I have been able to create a cached rowset and debug/watch the results, but do not understand how to transfer those results to a Table component. Can anyone point me in the right direction?
Details:
In SessionBean1.java, I declared the stored procedure and rowset along with get/set and update procedures:
// SLS trying stored procedure 20060412
private java.sql.CallableStatement spFXRatesStatement;
private CachedRowSetXImpl spFXRatesRowSet = new CachedRowSetXImpl();
public CachedRowSetXImpl getSpFXRatesRowSet() {
return spFXRatesRowSet;
public void setSpFXRatesRowSet(CachedRowSetXImpl crsxi) {
this.spFXRatesRowSet = crsxi;
public void updateSpFXRatesRowSet(String inDate, String inCcy) {
try {
spFXRatesStatement.setString(1, inDate);
spFXRatesStatement.setString(2, inCcy);
spFXRatesRowSet.populate(spFXRatesStatement.executeQuery(), 1);
catch (Exception e) {
// TODO - write exception code
// SLS trying stored procedure 20060412I then �prepared� the stored procedure within SessionBean1�s init() procedure:
// SLS trying a stored proc 20060412
try {
javax.naming.Context ctx = new javax.naming.InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/bmo_fp");
java.sql.Connection conn = ds.getConnection();
// spGetFXRates
spFXRatesStatement = conn.prepareCall("{call GetFXRates(?, ?)}",
java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
// next sp...
// clean up
ctx.close();
conn.close();
catch (Exception e) {
// TODO - add exception code
// SLS 20060412 I can see the results in a web page procedure with a �getSessionBean1().getSpFXRatesRowSet().getString(i)� watch.
try {
getSessionBean1().updateSpFXRatesRowSet("9/30/2005","EUR");
getSessionBean1().getSpFXRatesRowSet().first();
while (getSessionBean1().getSpFXRatesRowSet().isLast() != true) {
getSessionBean1().getSpFXRatesRowSet().next();
catch (Exception e) {
// TODO - specify error detail
}Now, how do I transfer these results to a table?I think you have to add a CachedRowSetDataProvider to you page been.
Then initalize it with your getSpFXRatesRowSet() in the init() method.
Then link you table to the CachedRowSetDataProvider.
Maybe you are looking for
-
What is the most cost efficient way to transfer 35mm slide images to my iMac hard drive?
-
I deleted the iPhone and I can not knock it
How do I run the iPhone 5 is stuck on the Apple ID mode and I can not remember the Apple ID and password, I do remember what do i need help please Thanks
-
Problem installing Reader 9.4 when Acrobat Pro is installed.
When I try to install the new 9.4 Reader the installer tell me that I have a more functional product installed and terminates. There is nothing in the customization tool that allows me to install both, only to determine which is primary if both are
-
Iphoto 11 + pse 9 editing
I have iphoto 11 pse 9 ,when I edit using pse as external editor and save simply clicking save ( not save as) when I try to reopen the photo a big black exclamtion mark appears. What's happening?
-
I need your help more than ever
Hello guys My macbook pro completely crashed today. As I did not have a space on my HDD to reinstall osx I was forced to archive my HDD on external disk, and then make a clean install. I wrote a post what happened http://discussions.apple.com/message