Returning 2D array from a stored procedure
hi,
i'm trying to return a nested table from a procedure.can any one help me out i'm getting the fallowing error.
SQL> ed
Wrote file afiedt.buf
1 declare
2 TYPE data_t IS TABLE OF NUMBER
3 INDEX BY PLS_INTEGER;
4 TYPE array_t IS TABLE OF data_t
5 INDEX BY PLS_INTEGER;
6 array array_t;
7 begin
8 Sp_test(123,'12-jan-08',array);
9 dbms_output.put_line(array (10) (1));
10* end;
11 /
Sp_test(123,'12-jan-08',array);
ERROR at line 8:
ORA-06550: line 8, column 1:
PLS-00306: wrong number or types of arguments in call to
'SP_TEST
ORA-06550: line 8, column 1:
PL/SQL: Statement ignored
The procedure is
CREATE OR REPLACE PROCEDURE Sp_test(S_KEY NUMBER,V_DATE DATE, array_out OUT array_t) as....
Below is the error i got when using the above suggestion.
SQL> ED
Wrote file afiedt.buf
1 DECLARE
2 TYPE data_t IS TABLE OF NUMBER
3 INDEX BY PLS_INTEGER;
4 TYPE array_t IS TABLE OF data_t
5 INDEX BY PLS_INTEGER;
6 begin
7 Sp_test(123,'12-jan-08',array REPORT.ARRAY_T);
8 dbms_output.put_line(array (10) (1));
9* end;
10 /
Sp_test(123,'12-jan-08',array REPORT.ARRAY_T);
ERROR at line 7:
ORA-06550: line 7, column 32:
PLS-00103: Encountered the symbol "REPORT" when expecting one of the
following:
. ( ) , * @ % & | = - + < / > at in is mod not range rem =>
.. <an exponent (**)> <> or != or ~= >= <= <> and or like
between ||
The symbol "." was substituted for "REPORT" to continue.
Similar Messages
-
Returning a table from a stored procedure
hi, i need to return a table from a stored procedure and show it, and come to this, but a don't know hoy to run it, so i don't know if it is right, can anyone help me?
uTable out objects_uptime%rowtype
as
begin
select * into uTable from objects_uptime;
end;well, i finally discovered how to do the trick
this is the code for the function:
CREATE OR REPLACE FUNCTION FN_GET_RECORDS RETURN UPTIME PIPELINED IS
CURSOR cUptime is select * from objects_uptime;
p refcur.refcur_t;
temp p%ROWTYPE;
temp2 OUPTIME := OUPTIME(null, null, null, null, null, null, null, null, null);
BEGIN
OPEN cUptime;
LOOP
FETCH cUptime into temp;
temp2.OBJ_NAME := temp.OBJ_NAME;
temp2.IP := temp.IP;
temp2.STATUS := temp.STATUS;
temp2.DOE := temp.DOE;
temp2.ENABLED := temp.ENABLED;
temp2.COMMENT00000 := temp.COMMENT00000;
temp2.USERID := temp.USERID;
temp2.OBJECTID := temp.OBJECTID;
temp2.MNTID := temp.MNTID;
pipe row(temp2);
EXIT WHEN cUptime%NOTFOUND;
END LOOP;
RETURN;
END FN_GET_RECORDS;
and this for the auxiliar package, object and table:
CREATE OR REPLACE PACKAGE REFCUR
as
TYPE refcur_t IS REF CURSOR RETURN objects_uptime%ROWTYPE;
end REFCUR;
CREATE OR REPLACE TYPE OUPTIME AS OBJECT ( "OBJ_NAME"
VARCHAR2(255), "IP" VARCHAR2(20), "STATUS" VARCHAR2(10),
"DOE" DATE, "ENABLED" NUMBER(10, 1), "COMMENT00000"
VARCHAR2(1000), "USERID" VARCHAR2(50), "OBJECTID" NUMBER(10,
1), "MNTID" NUMBER(10, 1) )
CREATE TYPE TUPTIME AS
TABLE OF OUPTIME
i call it this way:
select * from table(FN_GET_RECORDS ())
if anyone knows how to do the same in a shorter manner, tell me please.
thanks to everybody for the help. -
Hi,
How do I return two values from a
stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
Something like ?
CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
@intPeriod INT,
@strPeriod_Length NVARCHAR(1),
@dtStart NVARCHAR(8) OUTPUT,
@dtEnd NVARCHAR(8) OUTPUT
AS
then within the SSIS component; -
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
Add a script task to check ssis variables values using,
Msgbox(Dts.Variables("User::strExtractStartDate").Value)
Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
Regards, RSingh -
Passing array from java stored procedure to plsql
I have a java store procedure that is parsing an xml document and returning element values to my plsql application(8.1.7). I'm mapping a java.lang.String return type to VARCHAR2. However I'm running into the 4k limit when trying to return a string from java that is over 4k. Truncation of varchar returning over 4k is a known issue in 8i.
So my next idea was to split that value of the element into 2000char and put in an array then pass that back to the plsql procedure. I know that oracle.sql.ARRAY can be converted into a plsql TABLE. But I believe you can only use the oracle.sql.ARRAY type when you are doing jdbc programming and are working with a connection.
SO FINALLY MY QUESTION IS...
Can anyone think of a solution that will allow me to pass over 4k of character data from my java stored procedure (not jdbc), back to my plsql app?
Thanks.My understanding is that oracle 8 has a 4k limitation on any plsql function return data. A varchar can hold 32k within a function/package, but it cannot return more than 4k outside it's scope.
Do you have an example you could share where you use the clob as a return type?
Thanks! -
Newbie question on how to return java objects from java stored procedures
Hi,
As you may guess, i'm new to this.
I have a stored procedure that does some calculations and creates a list of java objects as the result of the query.
How would I return the list from the database to the client application?
Would I have to create an Oracle type that maps to the java object?
Please help.
JagHi Jag,
Your question is very vague (to me). Perhaps you could post what you have done so far? Have you tried looking through the Sample Code page of the Technet Web site, or tried searching the Ask tom Web site, or MetaLink?
Good Luck,
Avi. -
RETURN RESULT SET FROM JAVA STORED PROCEDURE
I'm calling a Oracle 8.1.5 java stored proc from PL/SQL and I
would like to send a Java result set to the calling function.
I havent found anyway to do this currently. Anyone else doing
anything like this and have a work around or know when/if it has
been fixed?
Mark
[email protected]
nullThis is not possible in Oracle 8i, will have to wait till Oracle 9i
-
Retruring Multiple rows from a Stored Procedure
The Oracle JDBC documentation shows how to return a cursor pointer through the parameter list of a stored procedure allowing a Java program to use the cursor like a normal result set. I've tried it (using the thin driver) and it works fine - however, I'm having trouble getting this to work running the program under a Weblogic server (using their own JDBC implementation). So, I have two questions:
1) Has anyone had this problem before and solved it ??
2) Are there any other techniques for getting multiple rows back from the database without having to fire "raw" sql at it ?Hi
You could return not resultset but array, for example:
PACKAGE TEST:
type string_table is table of varchar2(80)
index by binary_integer;
function get_something (
something1 out string_table,
arraylength in number
) return number;
PACKAGE'S BODY:
function get_something (
something1 out string_table,
arraylength in number /** length of the array **/
) return number as
cursor C is
select something1, ...
from test_table;
pos number := 1;
begin
for position in C loop
exit when (pos > arraylength);
something1(pos) := position.something1;
pos := pos + 1;
end loop;
return (pos - 1);
end;
Of course in this example you need to know length of your array
(arraylength parameter), but you can avoid such problem, for
example, by using DBMS_SQL package (or dynamic SQL feature in
the Oracle8i).
Andrew
Mladen Gogala (guest) wrote:
: Phil Hildebrand (guest) wrote:
: : Is there a way that I can return multiple rows from a stored
: : procedure for function ?
: : Something like:
: : CREATE FUNCTION sp_get_children (my_nip IN port.nip_num%
TYPE)
: : RETURN my_nip
: : IS
: : CURSOR child_cur IS
: : SELECT nip_num
: : FROM logical_port
: : WHERE port_num = my_nip;
: : child_rec child_cur%rowtype;
: : BEGIN
: : FOR child_rec IN child_cur
: : LOOP
: : RETURN my_nip;
: : END LOOP;
: : END tmp_sp_get_children;
: : I know how to do it in Informix ( RETURN WITH RESUME ), but
: I'm
: : not running Informix ;)
: : Thanks,
: : Phil
: In contrast with Informix, SQL Server and Sybase, Oracle
: can not return a result set. the only workaround is to
: return the cursor variable as such.
null -
Resultset from a Stored Procedure
Hello Everyone,
Is it possible to return a resultset from a stored procedure? I need to do display set of rows which are resulted by joining few tables.
Is it possible?
Please help..
TIA
Regards,
Rao Santapur.
null<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Raymond Tang ([email protected]):
You can use 'REF CURSOR'<HR></BLOCKQUOTE>
I have created a stored procedure with a ref cursor- what parameters do i need to pass via Sql*Plus to get results?
[email protected]
null -
Get a return value from a stored procedure.
hi all ,
i need to know where i am going wrong with the below code. I am trying to get a value from a stored procedure. the return type is int. The stored procedure works fine as i've debugged it. The variable have been declared correctly.
int n = 0;
proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
proc.registerOutParameter(1, java.sql.Types.INTEGER);
proc.setString(1, locationCode);
proc.setString(2, itemCode);
proc.execute();
n = proc.getInt(1);thanksHi ayub_a,
According the [ *setString*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html#setString(java.lang.String,%20java.lang.String)] method of the [*CallableStatement*|http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html] interface, the first parameter must be a parameter name and not an ordinal position index !!!
Edit : I've just found out the solution, it must be :
int n = 0;
proc = conn.prepareCall("{ ? = call SP_GETITEMCURRENTSOH(?,?) }");
proc.registerOutParameter(1, java.sql.Types.INTEGER);
proc.setString(2, locationCode);
proc.setString(3, itemCode);
proc.execute();
n = proc.getInt(1);Edited by: Chicon on Jul 5, 2009 7:48 PM -
How do I get return parameters from a stored procedure call?
The Open SQL Statement has an option on the Advanced tab to specify a command type of 'stored procedure'. In addition to returning a recordset, a stored procedure can also return parameters (see http://support.microsoft.com/support/kb/articles/Q185/1/25.ASP for info on doing this with ADO). Is it possible to get those return parameters with TestStand? In particular, I want to be able to get error codes back from the stored procedure in case it fails (maybe there is another way).
The Open SQL Statement step type does not fully support stored procedures. If the procedure returns a record set than you can fetch the values as you would a SELECT statement. Stored procedures require you to setup the parameters before the call and this is not yet supported. Bob, in his answer, made a reference to the Statements tab and I think that he was talking about the Database Logging feature in TS 2.0.
If the stored procedure is returning a return value, it may return as a single column, single row recordset which can be fetched as you normally do a record set.
Scott Richardson
National Instruments -
How can I return a big amount of data from a stored procedure?
How can I return a big amount of data from a stored procedure in a efficient way ?
For example not using a cursor for going through all the rows and then assign the values to variables.
thanks in advance!Let's see if I'm able to explain myself..
I have a SQL query with..about 190.000 (in the best fo the the options)
I have something like this in my stored procedure..
FOR REC IN trn_adj_no
LOOP
REC_PIPE.INSTANCE_ID:=REC.INSTANCE_ID;
REC_PIPE.PROCESS_ID:=REC.PROCESS_ID;
REC_PIPE.ENTITY_TYPE:='TRANSACTION';
REC_PIPE.CRES_FILENAME:=REC.CRES_FILENAME;
REC_PIPE.CHUNK_REVISION_SK:=P_CHUNK_REVISION_SK;
REC_PIPE.CHUNK_ID:=trim(p_chunk_id);
REC_PIPE.FCL_SK:=REC.FCL_SK;
REC_PIPE.FCL_TRADE_SK:=REC.FCL_TRADE_SK;
REC_PIPE.FCL_VALUATION_SK:=REC.FCL_VALUATION_SK;
REC_PIPE.FCL_BUSINESS_GROUP:=REC.FCL_BUSINESS_GROUP;
REC_PIPE.ABS_TRN_CD:=REC.ABS_TRN_CD;
REC_PIPE.ACC_INTEREST_IMP_LOAN_CCY_IFRS:=REC.ACC_INTEREST_IMP_LOAN_CCY_IFRS;
REC_PIPE.ACC_INTEREST_IMP_LOAN_IFRS:=REC.ACC_INTEREST_IMP_LOAN_IFRS;
REC_PIPE.ACCRUED_INT_AMT:=REC.ACCRUED_INT_AMT;
REC_PIPE.ACCRUED_INT_CCY_CD:=REC.ACCRUED_INT_CCY_CD;
REC_PIPE.AMORT_ID:=REC.AMORT_ID;
REC_PIPE.AMORT_IND:=REC.AMORT_IND;
REC_PIPE.ATI:=REC.ATI;
REC_PIPE.ATI_2:=REC.ATI_2;
REC_PIPE.ATI_2_AMT:=REC.ATI_2_AMT;
REC_PIPE.ATI_2_CCY_CD:=REC.ATI_2_CCY_CD;
REC_PIPE.ATI_AMT:=REC.ATI_AMT;
REC_PIPE.ATI_CCY_CD:=REC.ATI_CCY_CD;
REC_PIPE.AVG_MTH_DUE_AMT:=REC.AVG_MTH_DUE_AMT;
REC_PIPE.AVG_MTH_DUE_CCY_CD:=REC.AVG_MTH_DUE_CCY_CD;
REC_PIPE.AVG_YTD_DUE_AMT:=REC.AVG_YTD_DUE_AMT;
REC_PIPE.AVG_YTD_DUE_CCY_CD:=REC.AVG_YTD_DUE_CCY_CD;
REC_PIPE.BAL_SHEET_EXP_AMT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E.COB_DT:=REC.COB_DT;
REC_PIPE.COL_AGMENT_SRC_CD:=REC.COL_AGMENT_SRC_CD;
REC_PIPE.CONSOLIDATION_PCT:=REC.CONSOLIDATION_PCT;
REC_PIPE.CONTRACT_AMT:=REC.CONTRACT_AMT;
REC_PIPE.CONTRACT_COUNT:=REC.CONTRACT_COUNT;
REC_PIPE.COST_UNSEC_WORKOUT_AMT:=REC.COST_UNSEC_WORKOUT_AMT;
REC_PIPE.CPTY_CCDB_ID:=REC.CPTY_CCDB_ID;
REC_PIPE.CPTY_CD:=REC.CPTY_CD;
REC_PIPE.CPTY_LONG_NAME:=REC.CPTY_LONG_NAME;
REC_PIPE.CPTY_SRC_PROXY_UBR_ID:=REC.CPTY_SRC_PROXY_UBR_ID;
REC_PIPE.CPTY_TYPE_CD:=REC.CPTY_TYPE_CD;
REC_PIPE.CPTY_UBR_ID:=REC.CPTY_UBR_ID;
REC_PIPE.CREDIT_LINE_NET_IND:=REC.CREDIT_LINE_NET_IND;
REC_PIPE.CRES_SYS_ID:=REC.CRES_SYS_ID;
REC_PIPE.CTRY_RISK_PROVISION_BAL_AMT:=REC.CTRY_RISK_PROVISION_BAL_AMT;
REC_PIPE.CUR_NOTIONAL_AMT:=REC.CUR_NOTIONAL_AMT;
REC_PIPE.CUR_NOTIONAL_CCY_CD:=REC.CUR_NOTIONAL_CCY_CD;
REC_PIPE.CUR_NOTIONAL_CCY_CD_IFRS:=REC.CUR_NOTIONAL_CCY_CD_IFRS;
REC_PIPE.CUR_NOTIONAL_AMT_IFRS:=REC.CUR_NOTIONAL_AMT_IFRS;
REC_PIPE.DB_ENTITY_TRANSFER_ASSETS_CD:=REC.DB_ENTITY_TRANSFER_ASSETS_CD;
REC_PIPE.DEAL_TYPE_CD:=REC.DEAL_TYPE_CD;
REC_PIPE.DECOMPOSITION_IDENTIFIER:=REC.DECOMPOSITION_IDENTIFIER;
REC_PIPE.DEF_LOAN_FEE_IFRS:=REC.DEF_LOAN_FEE_IFRS;
REC_PIPE.DEF_LOAN_FEE_USGAAP:=REC.DEF_LOAN_FEE_USGAAP;
REC_PIPE.DELIVERY_DT:=REC.DELIVERY_DT;
REC_PIPE.DERIV_NOT_DT:=REC.DERIV_NOT_DT;
REC_PIPE.DERIV_NOT_IND:=REC.DERIV_NOT_IND;
REC_PIPE.DESK:=REC.DESK;
REC_PIPE.DIVISION_UBR_ID:=REC.DIVISION_UBR_ID;
REC_PIPE.ENTITY_CCDB_ID:=REC.ENTITY_CCDB_ID;
REC_PIPE.FAC_CD:=REC.FAC_CD;
REC_PIPE.FAC_LIMIT_CD:=REC.FAC_LIMIT_CD;
REC_PIPE.FAC_LIMIT_SRC_CD:=REC.FAC_LIMIT_SRC_CD;
REC_PIPE.FAC_SRC_CD:=REC.FAC_SRC_CD;
REC_PIPE.FAIR_VAL_CD_IFRS:=REC.FAIR_VAL_CD_IFRS;
REC_PIPE.FED_CLASS_CD:=REC.FED_CLASS_CD;
REC_PIPE.FIRST_RISK_PROVISION_DT:=REC.FIRST_RISK_PROVISION_DT;
REC_PIPE.FV_IMP_LOSS_CRED_CCY_IFRS:=REC.FV_IMP_LOSS_CRED_CCY_IFRS;
REC_PIPE.FV_IMP_LOSS_CRED_IFRS:=REC.FV_IMP_LOSS_CRED_IFRS;
REC_PIPE.FV_IMP_LOSS_CRED_YTD_CCY_IFRS:=REC.FV_IMP_LOSS_CRED_YTD_CCY_IFRS;
REC_PIPE.FV_IMP_LOSS_CRED_YTD_IFRS:=REC.FV_IMP_LOSS_CRED_YTD_IFRS;
REC_PIPE.GEN_RISK_PROVISION_BAL_AMT:=REC.GEN_RISK_PROVISION_BAL_AMT;
REC_PIPE.GL_PROFIT_CENTRE:=REC.GL_PROFIT_CENTRE;
REC_PIPE.GLOBAL_GL_CD:=REC.GLOBAL_GL_CD;
REC_PIPE.IFRS_POSITION:=REC.IFRS_POSITION;
REC_PIPE.IFRS_POSITION_AGGR:=REC.IFRS_POSITION_AGGR;
REC_PIPE.IMP_DT:=REC.IMP_DT;
REC_PIPE.IMP_METHOD_CD:=REC.IMP_METHOD_CD;
REC_PIPE.INT_COMPEN_CD:=REC.INT_COMPEN_CD;
REC_PIPE.INTER_IND:=REC.INTER_IND;
REC_PIPE.INTERCO_IND:=REC.INTERCO_IND;
REC_PIPE.INTERCO_IND_IFRS:=REC.INTERCO_IND_IFRS;
REC_PIPE.LOAN_PUR_FAIR_VAL_ADJ_AMT:=REC.LOAN_PUR_FAIR_VAL_ADJ_AMT;
REC_PIPE.LOCAL_GL_CD:=REC.LOCAL_GL_CD;
REC_PIPE.LOWEST_LEVEL_UBR_ID:=REC.LOWEST_LEVEL_UBR_ID;
REC_PIPE.LTD_FEES_TO_PRINCIPAL_AMT:=REC.LTD_FEES_TO_PRINCIPAL_AMT;
REC_PIPE.MA_CD:=REC.MA_CD;
REC_PIPE.MA_SPL_NOTE:=REC.MA_SPL_NOTE;
REC_PIPE.MA_SRC_CD:=REC.MA_SRC_CD;
REC_PIPE.MA_TYPE_CD:=REC.MA_TYPE_CD;
REC_PIPE.MAN_LINK_ID:=REC.MAN_LINK_ID;
REC_PIPE.MASTER_MA_CD:=REC.MASTER_MA_CD;
REC_PIPE.MATURITY_DT:=REC.MATURITY_DT;
REC_PIPE.MAX_OUT_AMT:=REC.MAX_OUT_AMT;
REC_PIPE.MAX_OUT_CCY_CD:=REC.MAX_OUT_CCY_CD;
REC_PIPE.MTM_AMT:=REC.MTM_AMT;
REC_PIPE.MTM_AMT_IFRS:=REC.MTM_AMT_IFRS;
REC_PIPE.MTM_CCY_CD:=REC.MTM_CCY_CD;
REC_PIPE.MTM_CCY_CD_IFRS:=REC.MTM_CCY_CD_IFRS;
REC_PIPE.NEW_RISK_PROVISION_AMT:=REC.NEW_RISK_PROVISION_AMT;
REC_PIPE.NON_PERF_IND:=REC.NON_PERF_IND;
REC_PIPE.NON_PERF_RCV_INT_AMT:=REC.NON_PERF_RCV_INT_AMT;
REC_PIPE.OPT_TYPE_CD:=REC.OPT_TYPE_CD;
REC_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REC_PIPE.REC_UNSEC_CCY_CD:=REC.REC_UNSEC_CCY_CD;
REC_PIPE.RECON_CD:=REC.RECON_CD;
REC_PIPE.RECON_SRC_CD:=REC.RECON_SRC_CD;
REC_PIPE.RECOV_AMT:=REC.RECOV_AMT;
REC_PIPE.RECOVERY_FLAG:=REC.RECOVERY_FLAG;
REC_PIPE.REGULATORY_NET_IND:=REC.REGULATORY_NET_IND;
REC_PIPE.REL_RISK_PROVISION_AMT:=REC.REL_RISK_PROVISION_AMT;
REC_PIPE.RESPONSIBLE_BRANCH_CCDB_ID:=REC.RESPONSIBLE_BRANCH_CCDB_ID;
REC_PIPE.RESPONSIBLE_BRANCH_ID:=REC.RESPONSIBLE_BRANCH_ID;
REC_PIPE.RESPONSIBLE_BRANCH_LOC_CD:=REC.RESPONSIBLE_BRANCH_LOC_CD;
REC_PIPE.RESTRUCT_IND:=REC.RESTRUCT_IND;
REC_PIPE.RISK_END_DT:=REC.RISK_END_DT;
REC_PIPE.RISK_ENGINES_METHOD_USED:=REC.RISK_ENGINES_METHOD_USED;
REC_PIPE.RISK_MITIGATING_PCT:=REC.RISK_MITIGATING_PCT;
REC_PIPE.RISK_PROVISION_BAL_AMT:=REC.RISK_PROVISION_BAL_AMT;
REC_PIPE.RISK_PROVISION_CCY_CD:=REC.RISK_PROVISION_CCY_CD;
REC_PIPE.RISK_WRITE_OFF_AMT:=REC.RISK_WRITE_OFF_AMT;
REC_PIPE.RISK_WRITE_OFF_LIFE_DT_AMT:=REC.RISK_WRITE_OFF_LIFE_DT_AMT;
REC_PIPE.RT_BUS_AREA_UBR_ID:=REC.RT_BUS_AREA_UBR_ID;
REC_PIPE.RT_CB_CCDB_ID:=REC.RT_CB_CCDB_ID;
REC_PIPE.RT_COV_CD:=REC.RT_COV_CD;
REC_PIPE.RT_COV_SRC_CD:=REC.RT_COV_SRC_CD;
REC_PIPE.RT_COV_TYPE_CD:=REC.RT_COV_TYPE_CD;
REC_PIPE.RT_COV_TYPE_CD_IFRS:=REC.RT_COV_TYPE_CD_IFRS;
REC_PIPE.RT_TYPE_CD:=REC.RT_TYPE_CD;
REC_PIPE.RT_TYPE_CD_IFRS:=REC.RT_TYPE_CD_IFRS;
REC_PIPE.SENIORITY:=REC.SENIORITY;
REC_PIPE.SETTLE_STATUS_ID:=REC.SETTLE_STATUS_ID;
REC_PIPE.SETTLEMENT_CD:=REC.SETTLEMENT_CD;
REC_PIPE.SETTLEMENT_DT:=REC.SETTLEMENT_DT;
REC_PIPE.SOX_REF:=REC.SOX_REF;
REC_PIPE.SPE_IND:=REC.SPE_IND;
REC_PIPE.SPL_TREAT_IND_IFRS:=REC.SPL_TREAT_IND_IFRS;
REC_PIPE.SRC_PROD_TYPE_CD:=REC.SRC_PROD_TYPE_CD;
REC_PIPE.SRC_PROD_TYPE_CD_IFRS:=REC.SRC_PROD_TYPE_CD_IFRS;
REC_PIPE.SRC_PROXY_UBR_CD:=REC.SRC_PROXY_UBR_CD;
REC_PIPE.START_DT:=REC.START_DT;
REC_PIPE.STRATEGIC_LEND_IND:=REC.STRATEGIC_LEND_IND;
REC_PIPE.STRIKE_FWD_FUT_PRICE_AMT:=REC.STRIKE_FWD_FUT_PRICE_AMT;
REC_PIPE.STRIKE_FWD_FUT_PRICE_CCY_CD:=REC.STRIKE_FWD_FUT_PRICE_CCY_CD;
REC_PIPE.TERMINATION_LOAN_DT:=REC.TERMINATION_LOAN_DT;
REC_PIPE.TRAD_ASSET_CD_IFRS:=REC.TRAD_ASSET_CD_IFRS;
REC_PIPE.TRADE_DT:=REC.TRADE_DT;
REC_PIPE.TRADE_ENTITY_CCDB_ID:=REC.TRADE_ENTITY_CCDB_ID;
REC_PIPE.TRADE_ENTITY_LOC_CD:=REC.TRADE_ENTITY_LOC_CD;
REC_PIPE.TRADE_RELATED_IND:=REC.TRADE_RELATED_IND;
REC_PIPE.TRADE_STATUS:=REC.TRADE_STATUS;
REC_PIPE.TRADING_ENTITY_LOC_CD:=REC.TRADING_ENTITY_LOC_CD;
REC_PIPE.TRAN_MATCH_CD:=REC.TRAN_MATCH_CD;
REC_PIPE.TRN_CD:=REC.TRN_CD;
REC_PIPE.TRN_LINK_CD:=REC.TRN_LINK_CD;
REC_PIPE.TRN_SRC_CD:=REC.TRN_SRC_CD;
REC_PIPE.TRN_TYPE_CD:=REC.TRN_TYPE_CD;
REC_PIPE.TRN_VERSION:=REC.TRN_VERSION;
REC_PIPE.UL_DELIVERY_DT:=REC.UL_DELIVERY_DT;
REC_PIPE.UL_MATURITY_DT:=REC.UL_MATURITY_DT;
REC_PIPE.UNDLY_ISS_NAME:=REC.UNDLY_ISS_NAME;
REC_PIPE.UNEARNED_INCOME_CCY_CD:=REC.UNEARNED_INCOME_CCY_CD;
REC_PIPE.UNEARNED_INCOME_DIS_LOAN_AMT:=REC.UNEARNED_INCOME_DIS_LOAN_AMT;
REC_PIPE.US_GAAP_POSITION_AGGR:=REC.US_GAAP_POSITION_AGGR;
REC_PIPE.VALUATION_DT:=REC.VALUATION_DT;
REC_PIPE.XCHG_CTRY_CD:=REC.XCHG_CTRY_CD;
REC_PIPE.YEAR01_NOTIONAL_AMT:=REC.YEAR01_NOTIONAL_AMT;
REC_PIPE.YEAR02_NOTIONAL_AMT:=REC.YEAR02_NOTIONAL_AMT;
REC_PIPE.YEAR03_NOTIONAL_AMT:=REC.YEAR03_NOTIONAL_AMT;
REC_PIPE.YEAR04_NOTIONAL_AMT:=REC.YEAR04_NOTIONAL_AMT;
REC_PIPE.YEAR05_NOTIONAL_AMT:=REC.YEAR05_NOTIONAL_AMT;
REC_PIPE.YEAR06_NOTIONAL_AMT:=REC.YEAR06_NOTIONAL_AMT;
REC_PIPE.YEAR07_NOTIONAL_AMT:=REC.YEAR07_NOTIONAL_AMT;
REC_PIPE.YEAR08_NOTIONAL_AMT:=REC.YEAR08_NOTIONAL_AMT;
REC_PIPE.YEAR09_NOTIONAL_AMT:=REC.YEAR09_NOTIONAL_AMT;
REC_PIPE.YEAR10_NOTIONAL_AMT:=REC.YEAR10_NOTIONAL_AMT;
REC_PIPE.YTD_PL_TRADE_AMT:=REC.YTD_PL_TRADE_AMT;
REC_PIPE.FCL_VALIDATED_IND:=REC.FCL_VALIDATED_IND;
REC_PIPE.FCL_EXCLUDED_IND:=REC.FCL_EXCLUDED_IND;
REC_PIPE.FCL_SOURCE_SYSTEM:=REC.FCL_SOURCE_SYSTEM;
REC_PIPE.FCL_CREATE_TIMESTAMP:=REC.FCL_CREATE_TIMESTAMP;
REC_PIPE.FCL_UPDATE_TIMESTAMP:=REC.FCL_UPDATE_TIMESTAMP;
REC_PIPE.FCL_TRADE_LOAD_DATE:=REC.FCL_TRADE_LOAD_DATE;
REC_PIPE.FCL_VALUATION_LOAD_DATE:=REC.FCL_VALUATION_LOAD_DATE;
REC_PIPE.FCL_MATRIX_TRADE_TYPE:=REC.FCL_MATRIX_TRADE_TYPE;
REC_PIPE.PCP_GCDS_REVISION:=REC.PCP_GCDS_REVISION;
REC_PIPE.FCL_UTP_BOOK_CD:=REC.FCL_UTP_BOOK_CD;
REC_PIPE.FCL_MIS_RISK_BOOK_CD:=REC.FCL_MIS_RISK_BOOK_CD;
REC_PIPE.ALD_STATUS:=REC.ALD_STATUS;
REC_PIPE.FCAT_OPERATION:=REC.FCAT_OPERATION;
REC_PIPE.INTERNAL_INTRA_IND_IFRS:=REC.INTERNAL_INTRA_IND_IFRS;
REC_PIPE.FCL_USAGE_IND:=REC.FCL_USAGE_IND;
REC_PIPE.QUICK:=REC.QUICK;
REC_PIPE.SEDOL:=REC.SEDOL;
REC_PIPE.CUSIP:=REC.CUSIP;
REC_PIPE.ISIN:=REC.ISIN;
REC_PIPE.QUANTITY:=REC.QUANTITY;
REC_PIPE.RIC:=REC.RIC;
REC_PIPE.DESCRIPTION:=REC.DESCRIPTION;
REC_PIPE.RESET_DATE:=REC.RESET_DATE;
REC_PIPE.PRICE:=REC.PRICE;
REC_PIPE.EXCHANGERATE:=REC.EXCHANGERATE;
REC_PIPE.PARA_PROD_TYPE_ID:=REC.PARA_PROD_TYPE_ID;
REC_PIPE.EFF_INT_RATE:=REC.EFF_INT_RATE;
REC_PIPE.ORIG_FEE_UNREALISED_AMT:=REC.ORIG_FEE_UNREALISED_AMT;
REC_PIPE.ASSET_TYPE:=REC.ASSET_TYPE;
REC_PIPE.IMP_IND_IFRS:=REC.IMP_IND_IFRS;
REC_PIPE.NOT_AMT_REDEMPTION_TO_1YR:=REC.NOT_AMT_REDEMPTION_TO_1YR;
REC_PIPE.NOT_AMT_REDEMPTION_TO_5YR:=REC.NOT_AMT_REDEMPTION_TO_5YR;
REC_PIPE.NOT_AMT_REDEMPTION_OVER_5YR:=REC.NOT_AMT_REDEMPTION_OVER_5YR;
REC_PIPE.CASH_LTD:=REC.CASH_LTD;
REC_PIPE.CASH_LTD_CCY:=REC.CASH_LTD_CCY;
REC_PIPE.FCL_FACILITY_SK:=REC.FCL_FACILITY_SK;
REC_PIPE.DILUTION_RISK_CRITERIA:=REC.DILUTION_RISK_CRITERIA;
REC_PIPE.FCL_RMS_RUNID:=REC.FCL_RMS_RUNID;
REC_PIPE.BSTYPE:=REC.BSTYPE;
REC_PIPE.YTD_ACCR_DIV:=REC.YTD_ACCR_DIV;
REC_PIPE.YTD_DIV:=REC.YTD_DIV;
REC_PIPE.ACC_ADJ_YTD:=REC.ACC_ADJ_YTD;
REC_PIPE.FV_RLZD_PL:=REC.FV_RLZD_PL;
REC_PIPE.ITD_PL:=REC.ITD_PL;
REC_PIPE.YTD_RLZD_PL:=REC.YTD_RLZD_PL;
REC_PIPE.YTD_UNRLZD_PL:=REC.YTD_UNRLZD_PL;
REC_PIPE.TRN_BAS_LGD:=REC.TRN_BAS_LGD;
REC_PIPE.TRAD_YTD_RLZD_PL:=REC.TRAD_YTD_RLZD_PL;
REC_PIPE.TRAD_YTD_UNRLZD_PL:=REC.TRAD_YTD_UNRLZD_PL;
REC_PIPE.UNADJUSTED_PV:=REC.UNADJUSTED_PV;
REC_PIPE.UNADJUSTED_REALISED_PL:=REC.UNADJUSTED_REALISED_PL;
REC_PIPE.UNADJUSTED_UNREALISED_PL:=REC.UNADJUSTED_UNREALISED_PL;
REC_PIPE.GRC_PROD_TYPE_ID:=REC.GRC_PROD_TYPE_ID;
REC_PIPE.GRC_PROD_TYPE_ID_IFRS:=REC.GRC_PROD_TYPE_ID_IFRS;
REC_PIPE.CUR_FEE:=REC.CUR_FEE;
REC_PIPE.SEC_IND:=REC.SEC_IND;
REC_PIPE.INVEST_ASSETS_PORT:=REC.INVEST_ASSETS_PORT;
REC_PIPE.RISK_PROVISION_START_BAL_AMT:=REC.RISK_PROVISION_START_BAL_AMT;
REC_PIPE.GEN_RISK_PRV_START_BAL_AMT:=REC.GEN_RISK_PRV_START_BAL_AMT;
REC_PIPE.GEN_RISK_PROVISION_NEW:=REC.GEN_RISK_PROVISION_NEW;
REC_PIPE.GEN_RISK_PROVISION_REL:=REC.GEN_RISK_PROVISION_REL;
REC_PIPE.ACQUIRED_IND:=REC.ACQUIRED_IND;
REC_PIPE.CRED_NET_MNA:=REC.CRED_NET_MNA;
REC_PIPE.SEC_IFRS_VUE_ADJ:=REC.SEC_IFRS_VUE_ADJ;
REC_PIPE.YEAR00_NOTIONAL_AMT:=REC.YEAR00_NOTIONAL_AMT;
REC_PIPE.MAX_OVERDUE_DAYS:=REC.MAX_OVERDUE_DAYS;
REC_PIPE.MIS_CD:=REC.MIS_CD;
REC_PIPE.MULTINAME_POOL_SK:=REC.MULTINAME_POOL_SK;
REC_PIPE.MULTINAME_CHUNK_REVISION_SK:=REC.MULTINAME_CHUNK_REVISION_SK;
REC_PIPE.MTRX_CALC_CNTRL_EPE:=REC.MTRX_CALC_CNTRL_EPE;
REC_PIPE.MTRX_CALC_CNTRL_PFE:=REC.MTRX_CALC_CNTRL_PFE;
REC_PIPE.FCL_TE_VALIDATED_IND:=REC.FCL_TE_VALIDATED_IND;
REC_PIPE.PCP_TE_DYNAMIC_KEY:=REC.PCP_TE_DYNAMIC_KEY;
REC_PIPE.AVG_COST:=REC.AVG_COST;
REC_PIPE.SEC_LONG_NAME:=REC.SEC_LONG_NAME;
REC_PIPE.ISS_CTRY_CD:=REC.ISS_CTRY_CD;
REC_PIPE.RISK_REPORTING_UBR:=REC.RISK_REPORTING_UBR;
REC_PIPE.RISK_COVERING_BRANCH_CCDB:=REC.RISK_COVERING_BRANCH_CCDB;
REC_PIPE.CLEARING_STATUS:=REC.CLEARING_STATUS;
REC_PIPE.FCL_CPTY_SK:=REC.FCL_CPTY_SK;
REC_PIPE.STRGRP:=REC.STRGRP;
REC_PIPE.OPEN_ENDED_FLAG:=REC.OPEN_ENDED_FLAG;
REC_PIPE.AVAILABILITY_IND:=REC.AVAILABILITY_IND;
REC_PIPE.ESCRW_FLG:=REC.ESCRW_FLG;
REC_PIPE.ESTABLISHED_RELP_FLG:=REC.ESTABLISHED_RELP_FLG;
REC_PIPE.GOV_GTY_AMT:=REC.GOV_GTY_AMT;
REC_PIPE.BUBA_CTRY_ID:=REC.BUBA_CTRY_ID;
REC_PIPE.GOV_GTY_CTRY_CD:=REC.GOV_GTY_CTRY_CD;
REC_PIPE.INTERNET_DPST_FLG:=REC.INTERNET_DPST_FLG;
REC_PIPE.LAST_ACTIVITY_DT:=REC.LAST_ACTIVITY_DT;
REC_PIPE.NOTICE_PERIOD_QTY:=REC.NOTICE_PERIOD_QTY;
REC_PIPE.OPR_RELP_FLG:=REC.OPR_RELP_FLG;
REC_PIPE.SIG_WD_PENALTY_FLG:=REC.SIG_WD_PENALTY_FLG;
REC_PIPE.TRN_ACT_FLG:=REC.TRN_ACT_FLG;
PIPE ROW(REC_PIPE);
END LOOP;
the Stored procedre returns REC_PIPE.
I thins this could be not efficient enough...
What do you think? -
Return national language strings from java stored procedures
Hi, all.
How does i can return String which contains national characters from java stored procedure? I.e. convert UTF java string to national language of database. It's does not processing automatically (why?).
declaration of procedure:
CREATE OR REPLACE FUNCTION TestNLSString RETURN VARCHAR2
AS
LANGUAGE JAVA
NAME 'test.SomeClass.getNLSString() return java.lang.String';
SELECT TestNLSString AS X FROM DUAL;
X
iiiii
OS: Windows 2000 Server
Oracle Server version: Oracle 8.1.7.1.4Ok. I had a specific problem.
I want to use java stored procedure (function) to make a connection to remote db using supplied connection parameters make some quieries there end return results in a form of structured data - object.
I have defined an object type in a database where the function will reside. I granted execute privilege to public user on this type, made public synonyms to both, the object type and the function, so anybody connected to the same database would have an access to this functionality.
I supposed that if I supply connection parameters for some other user but the same database when running the function, everything should go smooth. Yeah.
My java code executed ok: it made a connection to the db with some x user, it resolved object type descriptor given (oracle.sql.StructDescriptor), but pl/sql wrapper function reported the error I've mentioned. If I executed the function giving it the connection parameters for same account as where object type was declared, everything went fine.
My final solution is:
Make TWO! connection in java code: 1st for ("jdbc:default:connection:"), 2nd for remote database account.
Use first connection to construct oracle.sql.StructDescriptor
Use second connection to retreive data from remote db -
Table of records from a stored procedure
Hi
Where could I find an example or documentation about how to retrive a table of records from a Stored Procedure ??
ThanksTry:
CREATE OR REPLACE TYPE scott.MYRECORDTYPE as object
(a int, b varchar2(40), c date, d number(10));
CREATE OR REPLACE TYPE scott.MYTABLETYPE is table of myrecordtype;
CREATE OR REPLACE PACKAGE BODY scott.MYPACKAGE
as
type number_collection is table of number(38) index by binary_integer;
type varchar2_collection is table of varchar2(4000) index by binary_integer;
type date_collection is table of date index by binary_integer;
g_data myTableType;
empno_col number_collection;
ename_col varchar2_collection;
hiredate_col date_collection;
mgr_col number_collection;
function my_function return myTableType
is
begin
select empno, ename, hiredate, mgr
bulk collect into empno_col, ename_col, hiredate_col, mgr_col
from emp
order by empno; -- Get some data
g_data := myTableType(); -- Initialize
for i in empno_col.first .. empno_col.last loop
g_data.extend; -- Write something in the array
g_data(i) := myRecordtype(empno_col(i), ename_col(i), hiredate_col(i), mgr_col(i));
end loop;
return g_data;
end;
end;
-- Demonstration-View
CREATE OR REPLACE VIEW scott.myview
AS
select a,b,c,d
from table(cast(myPackage.my_function() as mytabletype)); -
ResultSet from Java Stored Procedures
Hi,
How do I obtain a resultset from a Java Stored Procedure?
My stored procedure, deployed in Oracle8i, has Database package as sample.Have published setConnection() and getDept() methods.
Code for Java Stored Procedure:
package SPPackage;
import java.sql.*;
public class StoredProcApplication {
protected static Connection connection = null;
protected static Statement stmt = null;
protected static ResultSet res = null;
public static void setConnection() throws SQLException {
connection = new oracle.jdbc.driver.OracleDriver().defaultConnection();
public static void getDept(Object[] obj) throws SQLException {
if (connection == null) {
setConnection();
if (stmt == null) {
stmt = connection.createStatement();
if (res == null) {
res = stmt.executeQuery("select * from DEPT");
obj[0] = res;
Code for TesterApplication :
package SPPackage;
import java.sql.*;
public class TesterApplication {
private static final String URL = "jdbc:oracle:thin:@sandeep:1521:oracle8i";
private static final String userId = "sandeep";
private static final String password = "sandeep";
private Connection connection;
private CallableStatement stmt;
private ResultSet res;
public void setConnection() throws ClassNotFoundException,SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection(URL,userId,password);
public void getResultFromSP() throws SQLException {
//prepare to call the stored procedure
stmt = connection.prepareCall("{call sample.getDept(?)}");
//register the OUT parameters
stmt.registerOutParameter(1,Types.OTHER);
//execute the query
stmt.execute();
ResultSet res = (ResultSet)stmt.getObject(1);
while (res.next()) {
System.out.print(res.getInt(1) + " | " );
System.out.print(res.getString(2) + " | " );
System.out.print(res.getString(3) + " \n " );
public TesterApplication() throws SQLException,ClassNotFoundException {
try {
setConnection();
getResultFromSP();
} finally {
if (res != null) { res.close(); res = null; }
if (stmt != null) { stmt.close(); stmt = null; }
if (connection != null) { connection.close(); connection = null; }
public static void main(String[] args) {
try {
TesterApplication ta = new TesterApplication();
} catch (Exception e) {
System.err.println("Error while executing stored procedure " + e.getMessage());
e.printStackTrace();
When I run the TesterApplication, I get the following exception :
java.sql.SQLException: Invalid column type: get_internal_type
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.get_internal_type(Compiled Code)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Compiled Code)
Also, if I want to execute the ResultSet in the stored proc itself, and return the values as Arrays of int[], and String[], how do I do it?By default the you can populate only int[0], String[0] , i.e. only one value!!!
if my statement is unknown, i.e, it might return a combination of updates and resultsets, how do I go about processing the result?
Please advise!!
TIA
Sandeep
nullHi kkirk,
I found the post you mentioned.Well it dates back to November 1999 - "Problem returning resultset or ARRAY from java stored proc" by Stuart Popejoy ([email protected]).Too bad, it is still not solved!!
I am not very good at PL/SQL.However, it would still be helpful, if you could post the code here, or at my email address.
Meanwhile, I was trying this during the week-end.There seems to be a glimmer of hope!!
Let me know, if this makes sense :
CallableStatement cs = connection.prepareCall("begin open ? for select * from dept; end");
try {
cs.registerOutParameter(1,OracleTypes.CURSOR);
ResultSet res = ((OracleCallableStatement)cs).getCursor(1);
while (res.next()) {
//get the values
} catch (Exception e) {
e.printStacktrace();
However, I am getting an exception trace
Error while executing stored procedure Invalid column type: getLong
java.sql.SQLException: Invalid column type: getLong
at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
at oracle.jdbc.driver.OracleStatement.getLongValue(Compiled Code)
Not quite sure why this is happening!!
TIA,
Sandeep
null -
Call a function inside a package from a stored procedure
Hello:
I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
can I do the following in proc_c:
my_cursor1 SYS_REFCURSOR;
begin
my_cursor1 := exec pack_a.func_b
end
It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.guys:
Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
DECLARE TEMP VARCHAR2(100);
BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
I tried to use 'set serveroutput on' and got the following error:
ERROR:
ORA-06502: PL/SQL: numeric or value error: host bind array too small
ORA-06512: at line 1
I am kind of confused now. thank you for your help.
Jack
Here is my procedure:
create or replace
PROCEDURE PROC_SEARCH
( AGENCY_ID IN VARCHAR2,
DEVICE_ID IN VARCHAR2,
L_NAME IN VARCHAR2,
F_NAME IN VARCHAR2,
SEX IN VARCHAR2,
DOB IN VARCHAR2,
CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
AS
v_agy_id varchar2(10);
v_device_id varchar2(20);
v_l_name varchar2(25);
v_f_name varchar2(15);
v_sex varchar2(1);
v_dob date;
-- this cursor is going to be used to store a list of warrant matching
-- name search criteria
cad_srch_cursor sys_refcursor;
objSrch SEARCH_RESULT_TEMP%ROWTYPE;
BEGIN
cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
LOOP
FETCH cad_srch_cursor INTO objSrch;
EXIT WHEN cad_srch_cursor%NOTFOUND;
--insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
end LOOP;
END PROC_LAWS_SEARCH;
-----------------------------------------
Maybe you are looking for
-
How do I save a PDF as non-editable?
I have a form that I filled out with Adobe Professional 7.0. What options do I select to make sure it saves as non-editable? Thanks for any help.
-
How to handle error from parlayx21/sms/SendSms service due high rate req?
Hi, I'm developing an integration with ALSB that call parlayx21/sms/SendSms for sending sms. It works properly if I send few sms but if I increase the rate sometimes it give me a fault with BEA-380000 Intenarnal Server Error. Calling from Business th
-
Unable to assign AUC as settlement type in settlement rule for FXA category
Dear Experts, One of my requirement is that one WBS has several actual posting for AUC of different types and settle through CJ88. Investment profile is not in scope. To run the above scenario, i created AUC manually via AS01 of different types. When
-
I-movie thumbnail images won't display only a gray box is present
I was working with my i-movie when every thumbnail image in both panes became gray as opposed to having images from the clip. The movies still play fine, but it is impossible to do any editing when you can't see what is in each frame. Any help would
-
CVE-2014-6271 and CVE-2014-7169 Patch Availability Document for Oracle Linux
Hi, Can you suggest from where we need to download bash rpm for OEL 6 :- bash-4.1.2-15.el6_5.2.x86_64.rpm bash-doc-4.1.2-15.el6_5.2.x86_64.rpm Thanks in Advance !! Mukesh