Mapping display only item to three output parameters from a procedure?
Hi all
I have a procedure with three output parameters, which I would like to map the three output parameters to three display only items on the page.
there is a page process called the procedure, which output statement1,statement2,statement3 parameters.
I have three items on the page which I would like to map them to the three parameters respectively,
how can I achieve this?
thanks
Rajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael
Similar Messages
-
Returning Oracle Output Parameters from Stored Procedures
Hi,
Please forgive my ignorance of Oracle and PL/SQL. I'm trying to get a value out of a stored proc which I've written. The proc takes a username input parameter and returns a user guid through an output parameter. I'm able to print the output parameter to the DBMS Output but can't figure out how to return the thing in a record when calling the proc through a normal sql prompt!
My call is like so:
DECLARE
nGUID NVARCHAR2(255);
BEGIN
GETUSER(nGUID, 'WHY-DEV-QSYS-Tim Watson');
DBMS_OUTPUT.PUT_LINE (nGUID);
Would like to return the value here; what's the syntax?
END;
The signature of the proc is
CREATE OR REPLACE PROCEDURE GETUSER
USERGUID OUT NVARCHAR2,
UNAME IN NVARCHAR2
IS
Can anyone assist?
Thanks in advance!
TimThe easiest way, in my opinion, is to not write a procedure, but a function for this porpose. You would not have to declare an out parameter, but a return value:
CREATE OR REPLACE FUNCTION GETUSER
UNAME IN NVARCHAR2
return nvarchar2
IS
From SQL prompt, you can then do
SQL> select getuser(<input_string>) from dual;
and get the returnvalue.
Best regards,
Gerd -
Displaying diff dates using PL/SQL expression for 'display only' item ?
Hi ,
I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
E.g: Today is Friday and the last Monday was on 18th .
So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
I tried it doing under 'Source ' of item using PL/SQL expression and PL/SQL function body. Not working
Can someone help ?
Thanks & Regards
UmerNice1 wrote:
declare
lv_date number;
begin
select to_char(sysdate,'D') into lv_date from dual;
if lv_date=2 then
:P2_FROM_DATE := to_char(sysdate-1);
end if;
end;I tried this under " PL/SQL function body " in "Source " tab of the item P2_FROM_DATE
When I run this , nothing is displayed corresponding to the item P2_FROM_DATEExactly as expected. This code will only set a value for <tt>P2_FROM_DATE</tt> when run on Mondays in territories where the first day of the week is Sunday, and when run on Tuesdays where Monday is the first day of of the week:
SQL> var P2_FROM_DATE varchar2(30)
SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
Session altered.
SQL> select sysdate from dual
SYSDATE
Mon 25-JUN-2012
SQL> alter session set nls_territory='AMERICA';
Session altered.
SQL> declare
2 lv_date number;
3 begin
4 select to_char(sysdate,'D') into lv_date from dual;
5 if lv_date=2 then
6 :P2_FROM_DATE := to_char(sysdate-1);
7 end if;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> print p2_from_date
P2_FROM_DATE
Sun 24-JUN-2012
SQL> alter session set nls_territory='UNITED KINGDOM';
Session altered.
SQL> exec :p2_from_date := null
SQL> declare
2 lv_date number;
3 begin
4 select to_char(sysdate,'D') into lv_date from dual;
5 if lv_date=2 then
6 :P2_FROM_DATE := to_char(sysdate-1);
7 end if;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> print p2_from_date
P2_FROM_DATE
SQL>Hence the questions about language above.
>
I am having a display only item -- :P2_FROM_Date . If its Thu,Fri,Sat or Sun I want to set the date as the last Monday's date . If its Mon,Tue or Wed then it should be the present Monday's date .
E.g: Today is Friday and the last Monday was on 18th .
So for yesterday , today,tomorrow and Sunday , the date should be displayed as 18-JUN-2012.
From the coming Monday to Wednesday , the date should of be the coming Monday i.e , 24-JUN-2012
>
The coming Monday is 25-JUN-2012.
Aren't these rules equivalent to "Monday this week, where Monday is the first day of the week"? In which case the PL/SQL Expression you require is:
trunc(sysdate, 'iw')For example:
SQL> with t as (
2 select date '2012-06-21' + level d from dual connect by level <= 17)
3 select
4 d
5 , trunc(d, 'iw') monday
6 from
7 t;
D MONDAY
Fri 22-JUN-2012 Mon 18-JUN-2012
Sat 23-JUN-2012 Mon 18-JUN-2012
Sun 24-JUN-2012 Mon 18-JUN-2012
Mon 25-JUN-2012 Mon 25-JUN-2012
Tue 26-JUN-2012 Mon 25-JUN-2012
Wed 27-JUN-2012 Mon 25-JUN-2012
Thu 28-JUN-2012 Mon 25-JUN-2012
Fri 29-JUN-2012 Mon 25-JUN-2012
Sat 30-JUN-2012 Mon 25-JUN-2012
Sun 01-JUL-2012 Mon 25-JUN-2012
Mon 02-JUL-2012 Mon 02-JUL-2012
Tue 03-JUL-2012 Mon 02-JUL-2012
Wed 04-JUL-2012 Mon 02-JUL-2012
Thu 05-JUL-2012 Mon 02-JUL-2012
Fri 06-JUL-2012 Mon 02-JUL-2012
Sat 07-JUL-2012 Mon 02-JUL-2012
Sun 08-JUL-2012 Mon 02-JUL-2012
17 rows selected.
SQL> alter session set nls_territory='AMERICA';
Session altered.
SQL> alter session set nls_date_format='Dy DD-MON-YYYY';
Session altered.
SQL> with t as (
2 select date '2012-06-21' + level d from dual connect by level <= 17)
3 select
4 d
5 , trunc(d, 'iw') monday
6 from
7 t;
D MONDAY
Fri 22-JUN-2012 Mon 18-JUN-2012
Sat 23-JUN-2012 Mon 18-JUN-2012
Sun 24-JUN-2012 Mon 18-JUN-2012
Mon 25-JUN-2012 Mon 25-JUN-2012
Tue 26-JUN-2012 Mon 25-JUN-2012
Wed 27-JUN-2012 Mon 25-JUN-2012
Thu 28-JUN-2012 Mon 25-JUN-2012
Fri 29-JUN-2012 Mon 25-JUN-2012
Sat 30-JUN-2012 Mon 25-JUN-2012
Sun 01-JUL-2012 Mon 25-JUN-2012
Mon 02-JUL-2012 Mon 02-JUL-2012
Tue 03-JUL-2012 Mon 02-JUL-2012
Wed 04-JUL-2012 Mon 02-JUL-2012
Thu 05-JUL-2012 Mon 02-JUL-2012
Fri 06-JUL-2012 Mon 02-JUL-2012
Sat 07-JUL-2012 Mon 02-JUL-2012
Sun 08-JUL-2012 Mon 02-JUL-2012
17 rows selected.Also note that using the item source properties will only set the <tt>P2_FROM_DATE</tt> in the rendered page, not in session state. -
Char displaying only the first three characters in the cube
Hi Experts
I have a char with lenth 60 and it's active.I am updating this char via the update routine whereby i am reading data from an active table of an ODS as i update in the update rules.
But surprisingly,once the load is succesful and complete,upon checking the data in the active table it's displayin the way it should be the problem comes in when I view the data on the cube which displays only the first three chars even if the descriptionis a 60 character field.
Please helpHi Herbert,
Have you checked in the infosource or transfer rules, what is the length of the infoobject, if you are loading the data to PSA, please check there it self, whether it is displaying 60 characters or only 3 characters.
Thanks
Sat -
Set value of a display only item using javascript
I was trying to find an answer in the forum but my searches gave me no results. How do
I set a value of a display only item using javascript (ajax)?
Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
-------------------------------------------------------------------Vikas,
Thanks for a fast responding. The type is Saves State. However, I tried to set the value
of a display only item using:
<script>
function f_setDisplayOnly ()
{$x('P80_X').parentNode.childNodes[4].nodeValue = 1;
</script>without a result (or error). What am I doing wrong?
Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Why cannot I use hidden or display only item to store value for insert?
hi, Gurus:
I have a question:
I implemented a form with report region in a page, the update works OK, but the add function has a problem:
There is a column, offender_ID, which is a foreign key for another table, it should not be null during insert. However, even I pass the offender ID from master page when user click the create button, and it did shows in the form, it must be a text filed to insert successfully, why cannot I use hidden or display only item to store this value for insert? (If I use hidden or display only item, insert won't be successful, apex reports I tried to insert a null value to offender_ID column.)
Many Thanks in advance.
SamHi,
There is a column, offender_ID, which is a foreign key for another table, it should not be null during insert. However, even I pass the offender ID from master page when user click the create button, and it did shows in the form, it must be a text filed to insert successfully, why cannot I use hidden or display only item to store this value for insert? (If I use hidden or display only item, insert won't be successful, apex reports I tried to insert a null value to offender_ID column.)I think both hidden and display items have attributes that can cause problems because of different ways these items function than non-hidden and non-display-only items function. Display Only items have a "Setting" of "Save Session State" Yes/No? That can be a problem.
Would you do this? Make these items regular items instead and see if you can get those working. Then, we will try to change the fields back to hidden or display only.
Howard
Congratulations. Glad you found the solution.
Edited by: Howard (... in Training) on Apr 11, 2013 10:26 AM -
How to force carraige return in display-only item
Can I somehow force a carraige return in the text for a display only item? Aesthetically, I'd would like to have strategically-placed line breaks.
Thanks,
CScott -- Sorry, I posted the wrong example entirely. Here's the assignment statement. If it isn't clear I'll try to put an example on apex.oracle.com... which I've not done before, so would be another learning experience :)
:P1_MESSAGE_1 := 'my display text line1< br>my display text line2';
My assignment statement is exactly the same format as what you posted on
Jul 29, 2008 2:51 PM, with the space after the opening bracket removed, as you
indicated it should be.
:P1_MESSAGE_1 is a display only, saves state item. After the assignment
statement (and submit), what is displayed is exactly what's in the single quotes, including the brackets and the "br" -- the html doesn't appear to be recognized as such:
Item display is: my display text line1< br>my display text line2
Does this clarify what I'm doing?
Thanks,
C -
Dynamic hyperlinks as Display Only item?
Hi, I need to add a hyperlink on a page, and the hyperlink will partially be derived from a page item on that page.
When I put a Display Only item on that page, with the source type as Static Assignment and set to something like:
<a href="http://webserver/page.html?number=:P2_NUMBER">blah</a>It displays exactly that, ignoring the HTML, and doesn't display it as a link.
Simple I'm sure, but what am I doing wrong?What you set for the item would be its value (of an input HTML item)
Try adding it to post or pre-element text of the item as
<a href="http://webserver/page.html?number=&P2_NUMBER.">blah</a> -
Setting values to Display Only item during AJAX request
Hello,
Good Morning!
In a master-detail form, in the detail report, I am populating two columns SERVICE_TAX_PCT and SERVICE_TAX_AMOUNT by making an AJAX request after selection of ACCOUNT_CODE. Values are populated with out any issue.
However, as soon as I make those two fields as Display Only, the values are not getting set. Is there a way to set the values to a field in the same time it should be restricted for user to change it?
(APEX 4.2.6)
Thanks,
-AnandHi Anand,
anand_gp wrote:
Hello,
Good Morning!
In a master-detail form, in the detail report, I am populating two columns SERVICE_TAX_PCT and SERVICE_TAX_AMOUNT by making an AJAX request after selection of ACCOUNT_CODE. Values are populated with out any issue.
However, as soon as I make those two fields as Display Only, the values are not getting set. Is there a way to set the values to a field in the same time it should be restricted for user to change it?
(APEX 4.2.6)
check the example
Step 1: Edit your page
under CSS->Inline put the code given below
.row_item_disabled {
cursor: default;
opacity: 0.5;
filter: alpha(opacity=50);
pointer-events: none;
Step 2 : I guess you have Javascript function similar like given below
you have to extract rowid first, for which you want to set the percentage , see line 6
and see line 18, for disabling the column of that row.
<script type="text/javascript">
function f_fetch_tax_percentage(pThis) {
var ajaxRequest;
var ajaxResult;
var row_id = pThis.id.substr(4);
var percentage = 'f05_' + row_id; // replace f05 with the rowid of percentage column
ajaxRequest = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=TAX_DTLS',0);
ajaxRequest.addParam('x01',$v(pThis));
ajaxResult = ajaxRequest.get();
if ( ajaxResult.length > 0 ) {
// set percentage
$('#'+percentage).val(parseFloat(ajaxResult));
// disable percentage column
$("#f05_" + row_id).attr("readonly", true).addClass('row_item_disabled');
</script>
Hope this helps you,
Regards,
Jitendra -
Calling a Stored Procedure with output parameters from Query Templates
This is same problem which Shalaka Khandekar logged earlier. This new thread gives the complete description about our problem. Please go through this problem and suggest us a feasible solution.
We encountered a problem while calling a stored procedure from MII Query Template as follows-
1. Stored Procedure is defined in a package. Procedure takes the below inputs and outputs.
a) Input1 - CLOB
b) Input2 - CLOB
c) Input3 - CLOB
d) Output1 - CLOB
e) Output2 - CLOB
f) Output3 - Varchar2
2. There are two ways to get the output back.
a) Using a Stored Procedure by declaring necessary OUT parameters.
b) Using a Function which returns a single value.
3. Consider we are using method 2-a. To call a Stored Procedure with OUT parameters from the Query Template we need to declare variables of
corresponding types and pass them to the Stored Procedure along with the necessary input parameters.
4. This method is not a solution to get output because we cannot declare variables of some type(CLOB, Varchar2) in Query Template.
5. Even though we are successful (step 4) in declaring the OUT variables in Query Template and passed it successfully to the procedure, but our procedure contains outputs which are of type CLOB. It means we are going to get data which is more than VARCHAR2 length which query template cannot return(Limit is 32767
characters)
6. So the method 2-a is ruled out.
7. Now consider method 2-b. Function returns only one value, but we have 3 different OUT values. Assume that we have appended them using a separator. This value is going to be more than 32767 characters which is again a problem with the query template(refer to point 5). So option 2-b is also ruled out.
Apart from above mentioned methods there is a work around. It is to create a temporary table in the database with above 3 OUT parameters along with a session specific column. We insert the output which we got from the procedure to the temporary table and use it further. As soon the usage of the data is completed we delete the current session specific data. So indirectly we call the table as a Session Table. This solution increases unnecessary load on the database.
Thanks in Advance.
RajeshRajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael -
How to view multiple output parameters from web services
I have used the Labview tool to create a .NET assembly from a WSDL file.
In the WSDL file the service has been defined to return 2 output parameters.
In Labview, when I invoke the method for this service the first output parameter ends up as the return value of the method. I can create an indicator for this and it gets updated properly when I run the VIS to use the web service.. The indicator is an integer value but recognizes the type defined within the WSDL file.
The second output parameter shows up as an output value. When I right click on it and create an indicator for it I get a .NET icon on the front panel rather than an integer value.
How can I view the value for this second output parameter after running the web service?
Is there a difference in how multiple output parameters handled in newer versions of Labview (I am using verison 7.1)?scrooge wrote:
You can try this link .
the link is dead... or i dont have access.. -
SECATT, use output parameters from a recorded transaction
Hi everybody,
I'm testing the functionality of the SECATT transaction. I have a question about the folllowing case:
someone has recorded mutliple transactions and wants them to be executed one after the other. But, 1 of these recorded transactions needs data that is generated by a previous transaction. Is this in some way possible (do these transactions generate some output parameters and can you capture them in your local parameters).
thank you in advance,
TomRajesh,
please check if this following proposal could serve you.
Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
Here is an example how this could be defined.
Package:
type return_cur IS ref CURSOR;
Procedure:
PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
OPEN myReturnCur FOR SELECT val1, val2, val3 FROM dual;
Query:
DECLARE
MYRETURNCUR myPackage.return_cur;
BEGIN
myPackage.myProc(
MYRETURNCUR => ?
END;
Good luck.
Michael -
Search help - Display only 500 entries at one time from Internal Table
Hi,
I have an internal table with 1000000 entries. And when I use F4IF_INT_TABLE_VALUE_REQUEST function module to display the search help with internal table, it gives me dump. Can somebody help me - how to display limited values when we process search help?
Thanks,
SheelHi Sheel
u have a variable callcontrol-maxrecords in search help exit to limit the number of records.. check my weblog for more help: https://wiki.sdn.sap.com/wiki/x/du0 -
How to retrieve Table of Records output param from stored procedure ?
Hi,
I'm trying to retrieve data from a PL/SQL stored proc. It seems I can't modify this procedure (I'm not allowed to and I don't know PL/SQL :)).
My only documentation is the PL/SQL code and its comments. And that's the first I have to deal with output of a defined complex PL/SQL type
So the signature of the procedure is :
FUNCTION FUN_AFF_EVELEG_IHM (
pEntumTyp IN NUMBER,
pEntnum IN VARCHAR2,
pEveListSize IN OUT NUMBER,
pEveList IN OUT pkg_funaff_eveleg.TableRecordEVL,
pErrCode IN OUT VARCHAR2,
pMessage IN OUT VARCHAR2)
RETURN NUMBER;pkg_funaff_eveleg.TableRecordEVL type is defined as "TABLE of RecordEVL"
pkg_funaff_eveleg.RecordEVL type is defined as "RECORD" (struct of 12 different fields : NUMBER or VARCHAR2)
What is the correct syntax to call the stored procedure then ? I don't find how to manage the pEveList output param. Is it a Cursor ? An ARRAY ? And how to register it ?
My code so far :
public static void callFunaffEVL(Connection con, String rcs) {
// CallableStatement procCstmt=null;
OracleCallableStatement oraCstmt = null;
try {
// Identifiy the Stored procedure
// package synonyme : pkg_aff_EVELEG_IHM
// stored procedure name : FUN_AFF_EVELEG_IHM
String command = new StringBuilder("{? = call pkg_aff_EVELEG_IHM.FUN_AFF_EVELEG_IHM(?,?,?,?,?,?");
// 1 RETURN
// 2 pEntumTyp IN NUMBER
// 3 pEntnum IN VARCHAR2
// 4 pEveListSize IN OUT NUMBER,
// 5 pEveList IN OUT pkg_funaff_eveleg.TableauRecordEVL,
// 6 pErrCpde IN OUT VARCHAR2,
// 7 pMessage IN OUT VARCHAR2)
// Create a Callable Statement Object:
oraCstmt = (OracleCallableStatement) con.prepareCall(command);
// Assign IN and OUT parameters
oraCstmt.registerOutParameter(1, OracleTypes.NUMBER); // RET
oraCstmt.setInt(2, 0); // ENTNUMTYP
oraCstmt.setString(3, rcs); // ENTNUM
oraCstmt.registerOutParameter(4, OracleTypes.NUMBER); // pEveListSize
oraCstmt.registerOutParameter(5, OracleTypes.ARRAY); // pEveList
oraCstmt.registerOutParameter(6, OracleTypes.VARCHAR); // pErrCode
oraCstmt.registerOutParameter(7, OracleTypes.VARCHAR); // pMessage
// Execute the Procedure or Function Call:
oraCstmt.execute();
// Process the OUT Placeholders:
int ret = oraCstmt.getInt(1);
String errCode = oraCstmt.getString(6);
String message = oraCstmt.getString(7);
System.out.println("RCS : " + rcs);
System.out.println("ret : " + ret);
System.out.println("errCode : " + errCode );
System.out.println("message : " + message);
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
// Close the CallableStatement Object:
try {
oraCstmt.close();
} catch (SQLException e) {
e.printStackTrace();
Return : java.sql.SQLException: Parameter type Conflict: sqlType=2003
Any help ? I found several examples that might refer to this case, but everything I tried end by a SQL exception of one type or another...
(and sorry for my poor english :))
CyAs I said, "pkg_funaff_eveleg.TableRecordEVL" is TABLE of RecordEVL.
i.e : I can find 2 defined types under the package pkg_funaff_eveleg :
TYPE TableRecordEVL is TABLE of RecordEVL INDEX BY BINARY_INTEGER;
TYPE RecordEVL is RECORD (
EVLENTNUM_PK EVENEMENTS_LEGAUX.EVLENTNUM_PK%TYPE,
EVLENTNUMTYP_PK EVENEMENTS_LEGAUX.EVLENTNUMTYP_PK%TYPE,
EVLSEQ_PK EVENEMENTS_LEGAUX.EVLSEQ_PK%TYPE,
EVLTYPSRC EVENEMENTS_LEGAUX.EVLTYPSRC%TYPE,
EVLPK1 EVENEMENTS_LEGAUX.EVLPK1%TYPE,
EVLPK2 EVENEMENTS_LEGAUX.EVLPK2%TYPE,
EVLPK3 EVENEMENTS_LEGAUX.EVLPK3%TYPE,
EVLPK4 EVENEMENTS_LEGAUX.EVLPK4%TYPE,
EVLPK5 EVENEMENTS_LEGAUX.EVLPK5%TYPE,
EVLPK6 EVENEMENTS_LEGAUX.EVLPK6%TYPE,
EVLCODEVTSRC EVENEMENTS_LEGAUX.EVLCODEVTSRC%TYPE,
EVLLEGEVECOD EVENEMENTS_LEGAUX.EVLLEGEVECOD%TYPE,
EVLSEQREF_FK EVENEMENTS_LEGAUX.EVLSEQREF_FK%TYPE,
EVLCOMMENT EVENEMENTS_LEGAUX.EVLCOMMENT%TYPE,
EVLETATCOD EVENEMENTS_LEGAUX.EVLETATCOD%TYPE,
EVLHISDATPUB EVENEMENTS_LEGAUX.EVLHISDATPUB%TYPE,
EVLHISPUBPRE EVENEMENTS_LEGAUX.EVLHISPUBPRE%TYPE,
EVLHISDATEFF EVENEMENTS_LEGAUX.EVLHISDATEFF%TYPE,
EVLHISEFFPRE EVENEMENTS_LEGAUX.EVLHISEFFPRE%TYPE,
EVLHISPOIDATEFF EVENEMENTS_LEGAUX.EVLHISPOIDATEFF%TYPE,
EVLHISORICOD EVENEMENTS_LEGAUX.EVLHISORICOD%TYPE,
EVLHISSUPPORTCOD EVENEMENTS_LEGAUX.EVLHISSUPPORTCOD%TYPE,
EVLHISNUMSUPPORT EVENEMENTS_LEGAUX.EVLHISNUMSUPPORT%TYPE,
EVLHISNUMINF EVENEMENTS_LEGAUX.EVLHISNUMINF%TYPE,
ANNNUMBODPCL CBODACCPROD.CODANN2.ANNNUMBOD%TYPE
);If needed, I can translate each "EVENEMENTS_LEGAUX.EVLENTNUM_PK%TYPE", but they must be VARCHAR2 or NUMBER
Do I answer your question ? -
How to output value from stored procedure
Hi folks, I need to output the OrderFK from a stored procedure not really sure how to achieve this any help or tips much appreciated.
Sql code below
USE [TyreSanner]
GO
/****** Object: StoredProcedure [dbo].[AddCustomerDetails] Script Date: 11/12/2014 20:56:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
/***********************Declare variables ***********************/
/******tblCustomer******/
@Forename nvarchar(50),
@Surname nvarchar(50),
@HouseNo nvarchar(50),
@CustAddress nvarchar(50),
@Town nvarchar(50),
@Postcode nvarchar(50),
@ContactNo nvarchar(50),
@EmailAddress nvarchar(50),
/******tblLink_OrderProduct******/
@ProductQuantity int,
@TotalProductSaleCost decimal,
@ProductFK int,
@FittingDate date,
@FittingTime Time
As
DECLARE @CustomerFK int;
DECLARE @OrderFK int;
Begin TRANSACTION
SET NOCOUNT ON
INSERT INTO [TyreSanner].[dbo].[Customer](Forename, Surname, HouseNo, CustAddress, Town, Postcode, ContactNo, EmailAddress)
VALUES (@Forename,@Surname,@HouseNo,@CustAddress,@Town,@Postcode,@ContactNo,@EmailAddress)
Set @CustomerFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Order] (CustomerFK)
VALUES (@CustomerFK)
SET @OrderFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
VALUES
(@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime)
COMMIT TRANSACTIONHi brucey54,
There’re several ways to capture the value from a Stored Procedure. In you scenario, I would suggest 2 options, by an output parameter or by a table variable.
By an output Parameter, you need to make a little bit modification on your code as below:
USE [TyreSanner]
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
@Forename nvarchar(50),
@FittingDate date,
@FittingTime Time,
@OrderFK int output
As
DECLARE @CustomerFK int;
--DECLARE @OrderFK int;
Run the following code, Then @OrderFKvalue holds the value you’d like.
DECLARE @OrderFKvalue int;
EXEC AddCustomerDetails(your parameters,@OrderFKvalue output)
Anyway if you don’t like to add one more parameter, you can get the value by a table variable as well. Please append “SELECT @OrderFK;” to your Procedure as below:
USE [TyreSanner]
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
SET @OrderFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
VALUES
(@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime);
SELECT @OrderFK;
Then you can call the Stored Procedure as below:
DECLARE @T TABLE (OrderFK INT);
INSERT @T EXEC AddCustomerDetails(your parameters) ;
SELECT OrderFK FROM @T;
There’re more options to achieve your requirement, please see the below link:
How to Share Data between Stored Procedures
If you have any question, feel free to let me know.
Best Regards,
Eric Zhang
Maybe you are looking for
-
Replacing text in Text File in a perticuler line number
Hi, I have a text file where values will be stored like user=alex;checkout=no;checkin=yes; user=rexy;checkout=yes;checkin=yes; user=nik;checkout=no;checkin=no; user=philip;checkout=yes;checkin=no; user=nex;checkout=yes;checkin=no; I know the line num
-
DreamweaverCS4 on IE browsers-1000x700website won't fit 1024x768 screen Res
Having a problem with IE web browsers. I have a work website designed on DreamWeaverCS4. It is sized at 1000x700. So I thought it would all fit into any PC screen with a resolution of 1024x768. But for some reason it is a shy big and you have to scro
-
Is there any support for avery labels in Pages? Or 3rd party support?
-
New at this but was hoping there was a way to remove the scroll bars from your end product?? Any help would be appreciated. Val
-
How to Create CFL to user defined table
Hi all, I have a user table with four fields. How to create a CFL for these fields? Regards, Fabio Ferreira.