Insert table with stored procedure
Hellois it possible to use bind insert table in odp.net that calls a stored procedure, or who loses the point of contact of the table?
I need to do at once two insertions in a parent table and the child table (get the primary key generated by a sequence in the first table.). Don't know if this can be done without storing seq.next_val somehow?
Edit: I will extend the question and ask if the table bind sql text can be a block anonymous plsql
Edited by: KarlTrumstedt 16-jun-2010 02:49
You can do both. You can table insert a stored procedure and an anonymous block.
Here's how (these are based on the ArrayBind example provided with the installation of ODP.net/ODT.
Installation program:
create table zdept (deptno number, deptname varchar2(50), loc varchar2(50));
CREATE OR REPLACE PROCEDURE ZZZ (p_deptno in number, p_deptname in varchar2, p_loc in varchar2) AS
begin
insert into zdept values(p_deptno , p_deptname || ' ' || p_deptname, p_loc );
end zzz;
/**
drop table zdept ;
drop procedure ZZZ ;
**/
table and link it to the stored procedure call:
static void Main(string[] args)
{
// Connect
string connectStr = "User Id=;Password=;Data Source=";
// Setup the Tables for sample
Setup(connectStr);
// Initialize array of data
int[] myArrayDeptNo = new int[3]{1, 2, 3};
String[] myArrayDeptName = {"Dev", "QA", "Facility"};
String[] myArrayDeptLoc = {"New York", "Maryland", "Texas"};
OracleConnection connection = new OracleConnection(connectStr);
OracleCommand command = new OracleCommand (
"zzz", connection);
command.CommandType = CommandType.StoredProcedure;
// Set the Array Size to 3. This applied to all the parameter in
// associated with this command
command.ArrayBindCount = 3;
command.BindByName = true;
// deptno parameter
OracleParameter deptNoParam = new OracleParameter("p_deptno",OracleDbType.Int32);
deptNoParam.Direction = ParameterDirection.Input;
deptNoParam.Value = myArrayDeptNo;
command.Parameters.Add(deptNoParam);
// deptname parameter
OracleParameter deptNameParam = new OracleParameter("p_deptname", OracleDbType.Varchar2);
deptNameParam.Direction = ParameterDirection.Input;
deptNameParam.Value = myArrayDeptName;
command.Parameters.Add(deptNameParam);
// loc parameter
OracleParameter deptLocParam = new OracleParameter("p_loc", OracleDbType.Varchar2);
deptLocParam.Direction = ParameterDirection.Input;
deptLocParam.Value = myArrayDeptLoc;
command.Parameters.Add(deptLocParam);
try
{
connection.Open();
command.ExecuteNonQuery ();
Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
}
catch (Exception e)
{
Console.WriteLine("Execution Failed:" + e.Message);
}
finally
{
// connection, command used server side resource, dispose them
// asap to conserve resource
connection.Close();
command.Dispose();
connection.Dispose();
}
}
"anonymous plsql block.
Well Yes
static void Main(string[] args)
{
// Connect
string connectStr = "User Id=;Password=;Data Source=";
// Setup the Tables for sample
Setup(connectStr);
// Initialize array of data
int[] myArrayDeptNo = new int[3]{1, 2, 3};
String[] myArrayDeptName = {"Dev", "QA", "Facility"};
String[] myArrayDeptLoc = {"New York", "Maryland", "Texas"};
OracleConnection connection = new OracleConnection(connectStr);
OracleCommand command = new OracleCommand (
"declare dnumber number; dname varchar2(50) ; begin dnumber := :deptno;dname := :deptname;insert into zdept values (:deptno, :deptname, :loc); update zdept set deptname=dname || :loc where deptno = :deptno; end;", connection);
// Set the Array Size to 3. This applied to all the parameter in
// associated with this command
command.ArrayBindCount = 3;
command.BindByName = true;
// deptno parameter
OracleParameter deptNoParam = new OracleParameter("deptno",OracleDbType.Int32);
deptNoParam.Direction = ParameterDirection.Input;
deptNoParam.Value = myArrayDeptNo;
command.Parameters.Add(deptNoParam);
// deptname parameter
OracleParameter deptNameParam = new OracleParameter("deptname", OracleDbType.Varchar2);
deptNameParam.Direction = ParameterDirection.Input;
deptNameParam.Value = myArrayDeptName;
command.Parameters.Add(deptNameParam);
// loc parameter
OracleParameter deptLocParam = new OracleParameter("loc", OracleDbType.Varchar2);
deptLocParam.Direction = ParameterDirection.Input;
deptLocParam.Value = myArrayDeptLoc;
command.Parameters.Add(deptLocParam);
try
{
connection.Open();
command.ExecuteNonQuery();
Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
}
catch (Exception e)
{
Console.WriteLine("Execution Failed:" + e.Message);
}
finally
{
// connection, command used server side resource, dispose them
// asap to conserve resource
connection.Close();
command.Dispose();
connection.Dispose();
}
}
Tags: Database
Similar Questions
-
Dynamic temporary Table in stored procedure
Dear expert,
I'm trying to convert a database from MSSQL to Oracle 11 g. But I'm a little stuck on dynamic temporary tables in stored procedures.
MS is normalize the data out dynamic SQL statements. In TSQL so I've created a Temp table with the number of columns that the SQL statement has, that I executed the SQL statement in the temporary table and then I was going to all the columns with the prompting separate command standard. Finally, I wrote the key table.
If I want to do this process with only on SP, dynamic, rather than to define for each normalization process its own SP, so this possiple in Oracle?
For example. "INSERT INTO Temp (PartNo, Descr, Type, price) SELECT PartNo, Descr, price from parts.
PartNo. Descr | Type | Price
AB00 | AKER GD245 | Monitor | 200.00
AB01 | Samir QQ22 | Monitor | 120.00
AQ05 | HB 5500DN | Printer | 550.00
SELECT @R = Max (PartKey) of N_Parts
INSERT INTO N_Parts (PartKey, PartNo) SELECT RowNum + @R, PartNo FROM (SELECT DISTINCT PartNo FROM Temp INCLUDING PartNo NOT IN (SELECT PartNo of N_Parts));
SELECT @R = Max (PartDKey) of N_PartsDescr
INSERT INTO N_PartsDescr (PartDKey, Descr) SELECT RowNum + @R, Descr FROM (SELECT DISTINCT Descr FROM Temp WHICH Desrc NOT IN (SELECT Desrc from N_Parts));
...
Insert into Part_Data (PartKey, PartDKey, PartTKey, PartPKey)
SELECT T0. PartKey, T1. PartDKey, T2. PartTKey, T3. Temp PartPKey T
INNER JOIN N_Parts T0 to T0. PartNo = T.PartNo
JOIN IN-HOUSE...
So what is the best way, do not generate this dynamic Table Temp?
Published by: 926165 on 08.04.2012 08:26926165 wrote:
I'm trying to convert a database from MSSQL to Oracle 11 g. But I'm a little stuck on dynamic temporary tables in stored procedures.Just my 2 cents here.
Conversion of database provider A to B of database provider is never really a great idea. The products are fundamentally different in many ways. Analysis of demand that needs to be ported from database at database B and then its implementation in a specific way to take advantage of the features of your new environment, accounting for all the differences between the implementations of provider will be your best bet.
I say this because, for me at least, a conversion means that you take what you have and it in slam in what you need. The better approach is to analyse, design (to explain the differences in behavior between vendor implementations, such as mechanisms for read consistency) and proceed from there. This way, you have a solid base on which to start, instead of a skyscraper built out of toothpicks.
See you soon,.
-
I use 10g, I have a 'PACK_SP' package with stored procedures, one of them is the following:
As you can see, I have marked the statement with the error according to the OEM error message. The error text is: "Error Text = PL/SQL: ORA-00942: table or view does not exist. My goal is to store in the output parameter 'v_namePrimaryKey' the primary key column of a tablename. This query only works in more SQL query editor. Could someone help me?PROCEDURE USP_ROWLARGESIZE(tablename VARCHAR2, cur_Types OUT CLOB, v_namePrimaryKey OUT CLOB, cur_Result OUT CLOB) IS v_sql_str VARCHAR2(1000); v_ctx VARCHAR2(100); v_rowlength pls_integer; qryCtx DBMS_XMLGEN.ctxHandle; BEGIN -- Begin error stmt SELECT SYS.COL$.NAME INTO v_namePrimaryKey FROM SYS.COL$ INNER JOIN SYS.OBJ$ ON SYS.COL$.OBJ# = SYS.OBJ$.OBJ# INNER JOIN SYS.CCOL$ ON SYS.COL$.OBJ# = SYS.CCOL$.OBJ# INNER JOIN SYS.CDEF$ ON SYS.CCOL$.CON# = SYS.CDEF$.CON# WHERE SYS.OBJ$.NAME = tablename AND SYS.CDEF$.TYPE# = 2 AND SYS.COL$.COL# = SYS.CCOL$.COL#; -- End error stmt (...) END USP_ROWLARGESIZE;
Thank you very much in advance!
Published by: user9112176 on February 10, 2010 18:30
Published by: user9112176 on February 10, 2010 18:31
Published by: user9112176 on February 10, 2010 18:32
Published by: user9112176 on February 10, 2010 18:33
Published by: user9112176 on February 10, 2010 19:22System objects are accessible in SQL because they are visible through roles (DBA or SELECT_CATALOG_ROLE for example).
However, the roles are disabled in PLSQL. You must have explicit privileges.
That said, I would strongly advice you against writing code that references the SYS objects directly. You should use the USER_ or ALL_ % (or, if you really really must) the DBA_ % views.Hemant K Collette
http://hemantoracledba.blogspot.com -
dbms_job. Submit insertion values in a table using stored procedure
values are inserted into a table by using the stored procedure by using the sequence and creating a job to trigger after every 10 seconds...
create table test (collar number);
table created.
create sequences seq_test
start with 1
Increment 1;
order of creation.
create or replace procedure sp_test is
Start
loop
Insert into test values (seq_test.nextval);
end loop;
commit;
end;
created stored procedure
Report the number of jobno;
BEGIN
DBMS_JOB. SUBMIT)
jobs = >: jobno.
This = > 'sp_test;',
next_date = > TRUNC (SYSDATE + 1/1440).
interval = > 'SYSDATE + 10/86400',.
no_parse = > TRUE
);
COMMIT;
END;
stored procedure created successfully
every thing is done, but why the feature is always wrong...
Please help meHello
Lucien wrote:
...
create or replace procedure sp_test is
Start
loop
Insert into test values (seq_test.nextval);
end loop;
commit;
end; ...Have you tested this procedure first? It has an infinite loop. If this is the case, it's inserting row after row in the table, but never to commit, because he never leaves the loop.
It seems that what you posted is a much simplified version of what you really do. Simplify things for posting on this forum is a good idea, but this one is so simple that I don't see the point of it, so I can't offer a better way to do. Maybe you shouldn't have a loop in the process. Whatever you do, test it before you submit it as a job.
-
Logic of tip insert - using a stored procedure?
Here's my use case:
- I have a table called TAGS that has two columns: id (number key, primary) and text (string)
- the table has a constraint of database set that each text must be unique
- the table also has a fixed sequence back next id available
- I created an entity of the DB object and its default View object
- I also created a page where I display a table read-only based on the View object
- Finally, I added a text field and a button to the page
- What I want to achieve is to insert all tags entered in the entry in the table fields, when the button is clicked. Note, however, that the entry field is a comma-separated list of tags, moreover, I have to insert only those tags that are new (to respect the constraint of database), and finally, I would like to use the sequence in insert or orders. Once completed, the page should also be updated.
My first question is whether a stored procedure is the right way to perform such a step insert logical. If not, what other means must be used in the ADF.
My second question is to know how to call the stored procedure and pass it the value of the input as a parameter field. I found this article http://andrejusb.blogspot.cz/2011/04/invoking-stored-procedures-and.html, but miss me a few transition points:
- How the callGreetingsFunction method call (I just get it that it's a method of the EO generated Java class?) after that the button is clicked?
- How to pass the value of the input field in this method as a parameter?
Thanks in advance for your help.
Now, what happens if I run it like this:
A. the procedure is executed after a click on the button
(B) the page is not updated (I had to do the research to get the new lines are visible in the table)
C. the constraint is ignored (after discounting there were several lines with unique identification number, but pr is - empty)
D. nothing has been committed to the database - if I closed the application window and it start again, the lines have disappeared from the table, but addition of new lines used number of increased seq
E. Similarly, if I did directly inserts into the database, these lines did not appear until I transferred the application
B. told it page to refresh. And that's usually enough to refresh your ViewObject with: viewObject.executeQuery)
C. Si the constraint is not enforced for null values. And this has nothing to do with the adf, this is related to oracle db.
D. you're calling commit.
E. you must re-run your view object (viewObject.executeQuery ())
Nevertheless, here is my rookie questions:
There there a simple way to refresh the page (or just the table containing the data)?
-How to validate changes (immediately after execution of the procedure)?
-How is the constraint has been ignored? I am sure it would fail on validation, but I thought that it will be considered even for adding data to the table.
-Are there a way to update the original Version of the database every time that the page is opened or refreshed?
-Drag and drop operation Execute like button on your page (or call vo.executeQuery () by program)
-Drag and drop the operation of posting as a button on your page (or invoke it by programming on the DBTransaction object)
-ignored for what values? for null values? It is expected, because each null is "unique."
-Yes, but you probably shouldn't do that for performance reasons, see this: Andrejus Baranovskis Blog: Cache results for ADF iterator property
Read also this: Andrejus Baranovskis Blog: job ADF and PL/SQL Invocation changes side effect
Dario
-
How to create temporary tables in stored procedures.
Hello
I am new to oracle, I have a requirement where I need to run a query in a loop for different values of where condition. Here, I need to record the results of the query on each iteration. After the end of the loop, I need to send the results to the front end. I did a lot of research for the concept of the temporary table in oracle, but I found myself unresolved except headaches. Everyone is showing how to create temporary tables in general but not in stored procedure.
Bad, I need the concept of temporary tables, or is there an alternative way to store temporary results. My procedure looks like this.
create or replace
procedure uspMatchCode (parWord varchar2, p_recorderSet to types.cursor_type)
as
smallint parCnt;
Start
parcnt: = 0;
Select count (1) in parCnt of...;
If parcnt > 0 then
Open for P_recorderSet
Select field1, field2, field3,... of table1, table2, table2 where < < condition > >
on the other
-Here, I want to create a temporary table and store the result for the loop shape into the temporary table.
CREATE TEMPORARY TABLE global my_temp_table (NUMBER of Column1, Column2) ON COMMIT DELETE ROWS.
FOR parCnt in 0.3
loop
INSERT into my_temp_table select Field1, Field2, field3,... from table1, table2, table2 where < < condition > >
end loop;
Open for P_recorderSet
Select * from < < temporary table > >
end if;
end;
Any help would be great to check me on the problem.
Thank you
Kiran.This is a change to the query Kiss has posted:
with data_text like)
Select regexp_substr (' sales financing marketing ',' [^] +', 1, level ") val
of tconnect by level<= length('sales="" finance="" marketing')-="" length(replace('sales="" finance="" marketing','="">=>
)
Select * from t, data_text, where t.colname like '% "| data_text. Val |' %'This will help you. Please change the column names and the name of the table as a result
-
Temporary tables in stored procedure
Hello
I write a stored procedure that will get data from different sources and generates a spreadsheet finally. Initial selection gets the basic data and chooses then merges the data.
To do this, I created a table in the database, I'm filling in data in this table by using the same procedure and finally selection of data in this table to generate the worksheet.
Now, I plan to use the TEMPORARY table instead of create database table. Can someone tell me where I can watch examples for temporary tables?
What is the best option in performance wise?
or
I can handle the whole scenario with slider? examples?Hello
Why you cannot use an ordinary table?
Search for [Global Temporary | http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#sthref7247] in the diocumentation, including SQL * manual language, an alternative.
'Temporary' applies only to the data. A global temporary Table is created once and remains until you DROP, the same as any other table.
The data in the table are temporary. If you create the table by saying "ON COMMIT PRESERVE ROWS" (which seems appropriate, according to your description) the data will be automatically deleted when you end the session database.All global data in temporary Tables are specific to the session. If two (or more) people use the same table at the same time, each one will see data that they inserted themselves; they'll never see rows inserted by the other session.
Almost everything you can do with an ordinary table, you can do with a global temporary Table. In particular, DML (such as FUSION) and cursors work exactly as they do on other tables.
-
Problem with stored procedure and validation
I have the following stored procedure:
create or replace PROCEDURE SOME_PROC)
/*
Some settings
*/
) AS
NUMBER of errors
BEGIN
errors: = FN_CHECK_BUSINESS_RULE_1 (/ * some args * /);
if(Errors > 0) then
raise_application_error (ERR_CONSTANTS. SOME_ERROR_NUMBER, ERR_CONSTANTS. SOME_ERROR_MESSAGE);
end if;
INSERT INTO une_table (/ * columns * /) VALUES (/ * values * /);
END SOME_PROC;
Because the business rule 1 is placed inside the stored procedure I can't check it out without calling the stored procedure.
I need to call the stored procedure 10 times with a different set of parameters and validation of the changes only after all calls to the stored procedure
are successful. I want to show the user all the errors that occurred during the stored procedure calls. If for a first example of stored procedure call
succeeds and a second failure no data has to be stored in a database.
How to prevent the stored procedure for insert lines until I call the method commit of ApplicationModule?
Thanks in advance.
No, other users only see the lines until you commit. The search term is the transaction isolation level. Tom Kite write a paper on this here ask Tom: on transaction isolation levels. This article gives some samples, according to theory, and you should read it.
Timo
-
Error PLS-00306 with stored procedure
I am trying to create a simple package and store the procedure to remove the date of treatment for Crystal Reports can read all data. I used an example on the web site for Crystal report as reference in SAP: link: [http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1084c536-711e-2b10-e48a-924a60745253;jsessionid= (J2EE3417200) ID0966300750DB00193623365600119940End]
I ran the following and receive PLS-00306: wrong number or type of argument on the stored procedure. I am also pulling data with a databaselink to another data base given that our third-party vendor will not connect directly to the main database.
I am new to PL/SQL, so I don't know what else to solve problems. Thank you for taking the time to review this.
-1. Create a temporary table
CREATE TEMPORARY TABLE global test_temp
(processdate DATE NOT NULL);
-2.Create package w / require REF CURSOR for Crystal reports
CREATE or REPLACE PACKAGE test_package
IN the TYPE processdate_TYPE IS REF CURSOR
RETURN test_temp % ROWTYPE;
END test_package;
/
-3. Stored procedure
CREATE OR REPLACE PROCEDURE test_Procedure
(processdate_cursor IN OUT test_Package.processdate_TYPE,
processdate_parameter IN test_temp.processdate%TYPE)
AS
processdate DATE;
BEGIN
OPEN FOR Processdate_cursor
SELECT processdate
OF processlog@WEATEST
WHERE processname = "F_ExecuteScheduleProcess" and processtype = ';
END test_Procedure;
/You say that you do not understand where there is a wrong number or type?
This error occurs because there is an incorrect number of parameters passed. Your procedure
Test_SP expects 3 parameters as defined by you as follows
(p_ID in number,
p_firstname OUT varchar2,
p_lastname OUT varchar2)But when you run, you're not not p_id, has not managed to p_firstname, has failed to p_lastname. So there are number of parameters and that's what suggests the error.
To run your test_sp
Declare
sFirstName Test_Table.FirstName%Type;
sLastName Test_Table.Lastname%Type;
Nest Test_Table.ID%Type: = 1;
Begin
Test_SP(1,sFirstName,sLastName);
End;I hope this helps.
-
Called Java overloaded with stored procedures
I have two stored procedures with the same name and the same number of parameters. They are overworked because the two procedures differ in the data type of their parameters. In addition, there are 2 2 parameters and the other has 3 in and 1 OUT parameter.
But Java has problem describing as Java is unable to distinguish that they are two different procedures. How Java should treat calling them? I don't want to change their name.
Thank youuser5406804 wrote:
Is not in Java, no way to achieve
nom_de_variable-online valueWhat you are referring is named notation, a way to specify an argument name with its value instead of associating the argument which the variable position value in the call. Given that the appeal should be processed through SQL and just be text to Java try to use named notation in the appeal of Java like you did in Oracle directly and see if it works. If it does not try to use the wrapper procedure I described.
-
How to extract data from the APEX report with stored procedure?
Hi all
I am doing a report at the APEX. the user selects two dates and click on the GO button - I have a stored procedure linked to this region of outcome for the stored procedure is called.
my stored procedure does the following-
using dates specified (IN) I do question and put data in a table (this painting was created only for this report).
I want to show all the data that I entered in the table on my APEX report the same procedure call. can I use Ref cursor return? How to do this?
Currently, I use another button in the APEX that basically retrieves all the data from table. Basically, the user clicks a button to generate the report and then another button for the report. which is not desirable at all :(
I m using APEX 3.1.2.00.02 and Oracle 10 database.
pls let me know if you need more clarification of the problem. Thanks in advance.
Kind regards
Probashi
Published by: porobashi on May 19, 2009 14:53APEX to base a report out of a function that returns the sql code... Your current code goes against a Ref cursor returns the values...
See this thread regarding taking a ref cursor and wrapping it in a function to channel out as a 'table' (use a cast to cast tabular function vale)...
(VERY COOL STUFF HERE!)
Re: Tyring to dynamically create the SQL statement for a calendar of SQL
Thank you
Tony Miller
Webster, TX -
HOW CAN I CRETE TABLE WITH STORED LIKE HER PROCEDURE?
CREATE OR REPLACE PROCEDURE CREATE_TABLE
(P_1 VARCHAR2, VARCHAR2, P_3 P_2) AS
V_TABLE VARCHAR2 (100);
BEGIN
IF P_1 = 'C' THEN V_TABLE: = ' CREATE TABLE AS SELECT P_2 * OF P_3';
ELSIF P_1 = A ' THEN V_TABLE: = 'DELETE TABLE P_2 ";
END IF;
IMMEDIATELY RUN V_TABLE;
END;
/
RUN
BEGIN
Create_Table ("C", "DEPT_EMPS", "EMPLOYEES");
END;
/
VIEW THE ERROR
So, here's what you're trying to do...
SQL > create or replace procedure create_table (create_or_delete varchar2
2, table_name varchar2
3, source_table_name varchar2
4 ) as
VARCHAR2 (32767) dyn_sql 5.
6 start
7 if upper (create_or_delete) = 'C' then
8 dyn_sql: = 'create table' | table_name |' in select * from '. source_table_name;
9 upper (create_or_delete) elsif = ' then
10 dyn_sql: = 'truncate table' | table_name;
11 end if;
12 immediately execute dyn_sql;
13 end;
14.Created procedure.
And here is what one of the more fundamental reasons that you should not...
SQL > declare
2 cnt number;
3. start
CREATE_TABLE 4 (' this, 'dept_emps', 'emp');
5. select count (*)
6 in the NTC
7 of dept_emps;
8 dbms_output.put_line (' count on my new table: ' |) CNT);
9 end;
10.
of dept_emps;
*
ERROR on line 7:
ORA-06550: line 7, column 10:
PL/SQL: ORA-00942: table or view does not exist
ORA-06550: line 5, column 3:
PL/SQL: SQL statement ignoredYou cannot use the table in the static SQL/DML instructions until it is created. The code compiles even because the table does not exist.
The only way to use this table would be to write more dynamic SQL. And you're just stupid!
If you write your code like this, you are creating an absolute mess. You need to learn that this is NOT the right way to create tables or write code.
It is also likely to be victims of violence for the injection of SQL code. If you are unsure what is SQL Injection, it is a major security vulnerability in your code that can allow people to steal data or remove data or otherwise damage to your database.
-
Error when inserting Blob by stored procedure
Hi there and thank you for your time,.
I am running a console application in .NET which resembles a particular file on my hard drive, runs through all files, captures the content via a FileStream, the type (by checking the registry), the name and a foreign key which he rises before insertion. This is my code:
public void Insert (MyFileModel file) information gathered by the System.IO.FileInfo object //contains
{
Con OracleConnection = new OracleConnection (System.Configuration.ConfigurationManager.ConnectionStrings ["Oracle"]. ConnectionString);
con. Open();
OracleCommand cmd = new OracleCommand();
cmd.CommandText = INSERT_FILE;
cmd.CommandType = CommandType.StoredProcedure;
cmd. Connection = con;
cmd. Parameters.Add (": p_in_file_contents", OracleDbType.Blob);
cmd. Parameters.Add (": p_in_filename", OracleDbType.Varchar2);
cmd. Parameters.Add (": p_in_item_num", OracleDbType.Int32);
cmd. Parameters.Add (": p_in_file_content_type", OracleDbType.Varchar2);
cmd parameters [0]. Value = file. FileContents; Byte [], populated from a file stream
cmd parameters [1]. Value = file. File name; string
cmd parameters [2]. Value = file. ItemNum; int?
cmd parameters [3]. Value = file. FileContentType; string
cmd ExecuteNonQuery());
con. Close();
con. Dispose();
}
INSERT_FILE (part of a set with the other working procedures) are:
PROCEDURE INSERT_FILE (p_in_file_contents IN p_in_file_content_type IN varchar2, p_in_item_num in numbers, p_in_filename IN varchar2, blob)
IS
BEGIN
INSERT INTO mytable
(FILE_CONTENTS, FILENAME, CREATE_DATE, ITEM_NUM, IS_DELETED, FILE_CONTENT_TYPE)
VALUES
(p_in_file_contents, p_in_filename, SYSDATE, p_in_item_num, 0, p_in_file_content_type);
END INSERT_FILE;
Here's the code LOB on the table. I do not change no matter what this code, is any of the default:
(STORE AS) LOB (FILE_CONTENTS)
TABLESPACE RECENTES5
ALLOW ONLINE STORAGE
CHUNK 32768
RETENTION
NOCACHE
NOLOGGING
INDEX)
TABLESPACE RECENTES5
STORAGE)
INITIAL OF 160K
ACCORDING TO 1 M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
DEFAULT USER_TABLES
))
STORAGE)
INITIAL OF 160K
ACCORDING TO 1 M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
DEFAULT USER_TABLES
))
TABLESPACE RECENTES5
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE)
INITIAL OF 160K
ACCORDING TO 1 M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
DEFAULT USER_TABLES
)
NOLOGGING
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING;
This code works fine for all the files and all types (stores and retrieves the document in my web application), with the exception of files whose size is between 32768 and 65535 (2 ^ 15 and 2 ^ 16). On the files that are the size, this error is returned to the insertion:
ORA-01460: dead letter or unreasonable conversion requested
My version 11.1.0.6.0 Oracle Client is installed and the version of the Oracle.DataAccess.dll is 2.111.6.0. I know that this is not the latest version of the software, but software installation is difficult in my organization that we do not have admin privlidges. The .NET web application and this particular application is a 4.0 application web.
I use a similar code of an MVC web application that sees the same results when the files came from an object HttpFileCollectionBase (Request.Files).
What Miss me the code ODP.NET? My table should setting?
Thank you very much for your time and help me with this!
-SeanSuggestions for your ODP.NET code.
1.
using Oracle.DataAccess.Types;
...
OracleBlob myBlob = new OracleBlob (con);
myBlob.Write (Mon_tableau_octets, 0, count); where Mon_tableau_octets is filled by a file stream and count is the number of bytes to write to myBlob
cmd parameters [0]. Value = myBlob;
...2. don't check that when he is not null, then have blob object, command object and a connection object. (No need to close the connection before eliminating)
It is not relevant to the question.Edited by: shsu January 12, 2012 16:16
-
Compile with stored procedure errors
Hi guys, I just start SQL so forgive me if I ask stupid questions real. That's the problem I have right now, as I said in my title.
It's my procedure.sql
CREATE OR REPLACE PROCEDURE check IS
no_of_duplicates NUMBER: = 0;
BEGIN
SELECT COUNT (*) IN no_of_duplicates
THE EMPLOYEE
WHERE E # =.
(select E # PILOT)
WHERE THERE ARE
(SELECT E # MECHANIC)
WHERE DRIVER. L # = MECHANIC. L#));
IF no_of_duplicates: = 0 THEN dbms_output.put_line ('OK');
ON THE OTHER
SELECT E #, NAME OF THE EMPLOYEE
WHERE E # =.
(SELECT E # PILOT)
WHERE THERE ARE
(SELECT E # MECHANIC)
WHERE DRIVER. L # = MECHANIC. L#));
END IF;
END check;
/
While trying to create the procedure, it gives me compilation errors. I took with this for hours and can't seem to find anything wrong with it. Can someone point me in the right direction? Thank you!
Hello
Once again, your postal code. The error occurs when you call the procedure, but you have not posted the code that calls the procedure and causes the error.
When I do this in SQL * more:
SET SERVEROUTPUT ON ENCAPSULATED FORMAT
EXEC check;The procedure that you have posted works perfectly (i.e., displayed the e # is, exactly as it was designed to do).
Display the e # and the name consists of BULK COLLECT both the e # name in separate collections, like this:
CREATE OR REPLACE PROCEDURE check IS
TYPE e #_table IS the TABLE OF THE employee.e#%TYPE;
e # e _list #_table;TYPE name_table IS TABLE OF THE employee.name%TYPE;
name_list name_table;
BEGIN
SELECT e #, name
E LOOSE COLLECTION #_list, name_list
The EMPLOYEE
WHERE e # (IN)
SELECT d.e #.
DRIVER d
JOIN m mechanic ON d.e # m.e = #.
);
E IF #_list. COUNT = 0
THEN
dbms_output.put_line ('OK, there without duplicate of illict");
ELSE - that is to say, e #_list. COUNTY <> 0
dbms_output.put_line (' the following employees are drivers and mechanics :');)
J IN 1.e #_list. COUNTY LOOP - I displays parentheses sometimes hard on the OTN site
dbms_output.put (TO_CHAR (e #_list (j)))
'999999999999'
)
);
dbms_output.put (' ');
dbms_output.put_line (name_list (j));
END LOOP;
END IF;
END check;
/
DISPLAY ERRORSThis is the result I get when I run the procedure above with your sample data:
The following employees are drivers and mechanics:
1 John Smith
You will notice I did several other changes in your code, sometimes because they are much more practical and sometimes just to show you different ways to do the same thing, that you may or may not want to use in this problem.
For example, you were doing the same query (with only very slight differences) 2 times: once to get the no_of_duplicates and then a second time to get the actual data. I don't know if it's the most effective way to do what you need. Say that there are 1000 rows in the result. You get all the 1000 once just to get the total number (that you do not need, if all you worry at this point is if there is), then to get the data. When you make a COLLECTION in BULK, you get automatically the COUNTY anyway, so why not not COLLECTING in BULK, and then use this count to see what to do next. If the NUMBER is greater than 0, then you already have the data, and you do not need to fetch it again. In addition, repeating (essentially) the same code is a maintenance problem. If you need to make a change, you must make the same change to several places. At best, it's a pain; but it is the exactly the kind of mistake that is easy to miss in trials, and you could have the code that runs for weeks in Production before you notice that it sometimes gives false results.
Another example: e # is a NUMBER. If it is possible to convert numbers in VARCHAR2s and save these VARCHAR2s in a VARCHAR2 collection, would be unwise more just to store them in a collection of NUMBER?
-
public String submit() {}
BindingContext bindingContext = BindingContext.getCurrent ();
DC DCDataControl = bindingContext.findDataControl("AppModuleDataControl");
AppM AppModuleImpl = (AppModuleImpl) dc.getDataProvider ();
BindingContainer links = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("getCAL");
Object result = operationBinding.execute ();
String dte = result.toString ();
Model CollectionModel = (CollectionModel) classHeldTbl.getValue ();
ROWCOUNT int = model.getRowCount ();
for (int i = 0; i < rowcount; i ++) {}
JUCtrlHierNodeBinding = (JUCtrlHierNodeBinding) model.getRowData (i) rowData;
If (rowData.getAttribute (8)! = null) {}
int slotId = Integer.parseInt (rowData.getAttribute (5) m:System.NET.SocketAddress.ToString ());
int sectionId = Integer.parseInt (rowData.getAttribute (6) m:System.NET.SocketAddress.ToString ());
int teacherId = Integer.parseInt (rowData.getAttribute (7) m:System.NET.SocketAddress.ToString ());
String rowData.getAttribute = chk (8) m:System.NET.SocketAddress.ToString ();
If (chk.equals ("true")) {}
try {}
System.out.println ("dateee:" + result + "id Teachr" + teacherId + ETD + "" + slotId + "" + sectionId);
appM.submitClassHeld (teacherId, dte, IDEmplacement, sectionId);
System.out.println ("After proc");
} catch (NullPointerException e) {}
System.out.println ("-Execption" + e.getMessage ());
}
}
}
}
Returns a null value.
}
There are no issues with values... This function works only once. When we submit the values on the selection box it works once, but when press us the button submit again select different box it inserts the value in the database, but on the page shows null pointer exception.
RowData are so is equal to null.
Change this line in the following way:
System.out.println ("rowData =" + rowData);
If (rowData! = null & rowData.getAttribute (8)! = null)
and lat me know what happens
JohnMackanzi wrote:
Number of line 58
If (rowData.getAttribute (8)! = null) {}
Maybe you are looking for
-
The fake Flash Update malware removal
Over the weekend, my iMac received the fake local saying Adobe Flash needs an update. I checked that I was indeed the last version for OS X. Now I get the pop up every hour or so and I want to get rid of. I have never clicked on the download button.
-
Analysis over the HDMI interface incorrectly detected as digital television
It is a question of reagrding the Toshiba Satellite Pro T130-15F. When I connect the laptop to my HP2159m monitor with a HDMI cable, the laptop detects the monitor as a digital tv. Accordingly he send a wrong signal, which translates into a bad image
-
Format of paper detected error is not supported on 3210 all-in-One Printer
Msg of error about the size of the paper when opening lid to print a paper copy, an office document that is on 81/2 x 11. Error says 'paper size is not supported has detected", gushes out a blank page and cancels. I went to default settings on a Wo
-
Need help to get back to the way it was when I got it
My computer is a DellXPS400, age of 4 years. XP operating system. Please tell me how to recover my computer to the way it was when I bought it. I particularlty don't care if I lose the software. It's far too slow. It will only allow me to take it bac
-
I can't connect to the Instant Messaging