I am using oracle and I get a Associative Array from C#. The code in my pl/sql package is:
PROCEDURE SG_DATA_ARRAY (PROVA IN T_ASSOCIATIVE_ARRAY, P_RESULT OUT VARCHAR2) AS
BEGIN
SAVEPOINT SP1;
FOR indx IN 1..PROVA.count
LOOP
TA_DATA.TA_TABLE_INS (PROVA(indx), INDX);
END LOOP;
P_RESULT:='SUCCESS INS';
EXCEPTION
WHEN OTHERS THEN
ROLLBACK TO SAVEPOINT SP1;
P_RESULT:='ERROR INS';
END SG_DATA_ARRAY;
I am doing a loop of associative array and then I call my stored procedure TA_TABLE_INS from the package TA_DATA. In the procedure I call, I save into several variables the data from associative array:
PROCEDURE TA_TABLE_INS (PROVA IN T_ASSOCIATIVE_ARRAY, P_DESCR IN NUMBER) AS
P_ID_TMS NUMBER;
D1 NVARCHAR2 (20);
DESCRIPTION NVARCHAR2 (255);
D3 NVARCHAR2(20);
D4 NVARCHAR2 (255);
D5 NVARCHAR2(1000);
D6_REV_N NUMBER;
D7_REV_N NUMBER;
D8 NVARCHAR2(20);
D9 NVARCHAR2(1000);
D10 NUMBER;
INSERT INTO TA_TABLE1
VALUES (D1, D2, D3, D4, D5, D6, D7, D8, D9, D10);
Is that the right way to save data?
TA_TABLE_INSpasses an element of the collection and an index. The procedure is defined to take at_associative_arrayas the first parameter, not an element of that collection. Your procedure doesn't appear to do anything with the input parameters, it just inserts 10 NULL values into the table. You haven't posted the definition of your collection. If it is an associative array, your code assumes that it is indexed by an integer and dense. That is possible but would be unlikely in an associative array. - Justin Cavevarchar(4000)to theTA_TABLE_INSprocedure. That procedure expects at_associative_array. That won't compile. Your collection has a single string. Your table has 10 columns with a number of different data types. How would you want to take a single string and insert it into a table with 10 columns? - Justin Cave