I'm working on adding a database project in VS2010. I created a SQL 2008 DB Project, pointed at the development server, and it seems to have generated all of the appropriate schema objects. However, all of the CREATE TRIGGER scripts have the following error:
SQL03120: Cannot find element referenced by the supporting statement
Googling that error message doesn't return much, and seems to point to scripts using ALTER instead of CREATE which isn't the case here. This is an example of one of the scripts:
CREATE TRIGGER [TR_t_TABLE_TRIGGERNAME] ON [content].[t_TABLE]
FOR INSERT
AS
BEGIN
IF ( SELECT COUNT(*) FROM inserted) > 0
BEGIN
DECLARE #columnBits VARBINARY(50)
SELECT #columnBits = COLUMNS_UPDATED() | CAST (0 AS BIGINT)
INSERT INTO [history].[t_TABLE]
(
....
)
SELECT
....
FROM inserted
END
END
GO
EXECUTE sp_settriggerorder #triggername = N'[Content].[TR_t_TABLE_TRIGGER]', #order = N'last', #stmttype = N'insert';
The line that Visual Studio is attributing the error to is the last line executing the system proc. What stands out to me is that none of the object exist in the dbo schema. The table is in the Content schema and it has a matching table in the History schema. It would seem like the [Content] and [History] qualifiers would be resolvable though. Can't figure this one out...
Since this post comes up when you search for the above error on Google: another reason for this error is if you've got a stored procedure in a database project which specifies ALTER PROCEDURE rather than CREATE PROCEDURE.
Related
I need to use the stored procedure stage.
Currently I'm making just for an example for how to use it right.
CREATE OR REPLACE PROCEDURE "STG"."TRUNC_TEST"
AS
BEGIN
execute immediate 'truncate table TESTSP';
END;
That's my example of simple stored procedure.
My job design probably seen like this
Oracle Connector 1=>Transformer=>Oracle Connector 2=>Stored Procedure Stage
Oracle Connector 1 do Select, Oracle Connector 2 do Insert to TESTSP
My settings in the stored procedure stage
General : I've already put all the credential , with Transaction ISO as None
Syntax
Procedure Name : TRUNC_TEST
Procedure Type : Transform (i've also tried to change it to Target)
Database Procedure Type : Stored Procedure
Generate procedure call (checked)
Parameters
Empty
Error Codes
Empty
NLS Map
Project Default UTF-8
Advanced
Execution mode :Default(Sequential)
Combinability : Default
Configuration file : default
In the Input tabs
General
Execute Procedure for each row (checked)
Transaction size : 0
Partitioning
Collector type Auto
Columns
Just brought all the columns from Oracle connector 2
Advanced
Default
The job showing green line and success, but the SP isn't working. It should've been truncate the TESTSP table, but when I do a select *, the data is still there.
Maybe my stored procedure is wrong since I'm still learning how to make it? Or maybe there is something wrong with my 'Settings' in the stored procedure stage?
Every time you are running your job, you are just creating or replacing the SP definition.
You will have to call the SP in order to execute it.
That is the reason you are able to execute it outside.
I suggest you to create a generic SP in your database which will accept table name as parameter.
Once this is created, use SP stage to invoke the SP with column you want to truncate.
You can also use after SQL option in oracle connector to avoid extra SP stage.
I have a script in PL/SQL , that drop some tables , sequences , triggers, and creating them again in the same script , I need this script in my website for deleting all data from database (and I want to acces this script pressing one button on website) so I tried to do a function / procedure in PL/SQL that read line by line from the script file and executing every line with dynamic sql , everything went ok till one error at:
CREATE OR REPLACE TRIGGER players_bir BEFORE INSERT ON players FOR EACH ROW BEGIN SELECT players_seq.NEXTVAL INTO :new.id FROM dual END
this gave me the error:
ORA-24344: success with compilation error
I searched for solutions, but I didn't find anything.
You are missing the semi-colon after dual on your SELECT statement. This ORA error generally means you compiled some code, but that is has some issue.
CREATE OR REPLACE TRIGGER players_bir
BEFORE INSERT ON players
FOR EACH ROW
BEGIN
SELECT players_seq.nextval
INTO :new.id
FROM dual;
END
Looking in all_errors will show you what the issue is or you could manually compile this trigger in some IDE (like SQL Developer) and that should also make it obvious.
SELECT *
FROM all_errors e
WHERE e.name = 'PLAYERS_BIR'
AND e.type = 'TRIGGER';
Additionally if all you are using your trigger for is to set some identity column and you are on Oracle 12c you can use some of the new features to accomplish this. Triggers are inherently slow and the new identity feature performs about as good as referencing the sequence directly in your INSERT.
I am doing data insert into a table in Oracle which is having a sequence set to it in one of the columns say Id column. I would like to know how to do data loads into such tables.
I followed the below link -
It's possible to use OleDbConnections with the Script Component?
and tried to create a function to get the .nextval from the Oracle table but I am getting the following error -
Error while trying to retrieve text for error ORA-01019
I realized that manually setting the value via the package i.e. by using the Script task to enumerate the values but is not incrementing the sequence and that is causing the problem. How do we deal with it? Any links that can help me solve it?
I am using SSIS-2014 but I am not able to tag it as I don't due to paucity of reputation points.
I created a workaround to cater to this problem. I have created staging tables of the destination without the column that takes the Sequence Id. After the data gets inserted, I am then calling SQL statement to get the data into the main tables from staging table and using the .nextval function. Finally truncating/dropping the table depending on the need. It would still be interesting to know how this same thing can be handled via script rather having this workaround.
For instance something like below -
insert into table_main
select table_main_sequence_name.nextval
,*
from (
select *
from table_stg
)
ORA-01019 may be related to fact you have multiple Oracle clients installed. Please check ORACLE_HOME variable if it contains only one client.
One workaround I'm thinking about is creating two procedures for handling sequence. One to get value you start with:
create or replace function get_first from seq as return number
seqid number;
begin
select seq_name.nexval into seqid from dual;
return seqid;
end;
/
Then do your incrementation in script. And after that call second procedure to increment sequence:
create or replace procedure setseq(val number) as
begin
execute immediate 'ALTER SEQUENCE seq_name INCREMENT BY ' || val;
end;
/
This is not good approach but maybe it will solve your problem
i have a problem - I want to use temp table in stored procedure is SQL Server, which will be executed from SSIS package.
I read some tips how to do it and I tried this one (first answer): Using Temp tables in SSIS
but it didn't work.
I have MS Visual Studio 2010, couldn't be problem with this version?
Here is my code in stored proc.:
CREATE PROCEDURE some_procedure
AS
SET NOCOUNT ON
IF 1 = 0
BEGIN
SELECT CAST(NULL AS int) as number
END
CREATE TABLE #some_table (number int)
INSERT INTO #some_table VALUES (250)
SELECT number FROM #some_table
Thanks for any advice or experience.
Here is error message from Visual Studio:
Error at Data Flow Task [OLE DB Source [1]]: SSIS Error Code
DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code:
0x80004005. An OLE DB record is available. Source: "Microsoft SQL
Server Native Client 11.0" Hresult: 0x80004005 Description: "The
metadata could not be determined because statement 'INSERT INTO
#some_table VALUES (250)' in procedure 'some_procedure' uses a temp table.".
Error at Data Flow Task [OLE DB Source [1]]: Unable to retrieve column
information from the data source. Make sure your target table in the
database is available.
In SQL Server 2012 if you use temporary tables you must specify a results set.
This is an issue with the sp_describe_first_result_set procedure that SSIS uses to returns the output metadata.
E.g.
EXEC dbo.RptResults_StoredProcedure
Becomes
EXEC dbo.RptResults_StoredProcedure
WITH RESULT SETS
((
Date NVARCHAR(10),
Location VARCHAR(12),
Department CHAR(1),
Shift CHAR(1),
ForecastSales DECIMAL(18,2),
ActualSales DECIMAL(18,2)
))
For more information view
http://blog.concentra.co.uk/2014/08/22/column-metadata-determined-correctly-ssis-data-flow-task-stored-procedure-inputs/
Instead of temp table you can use table variable or cte... these don't have the issue like temp table.
CREATE PROCEDURE some_procedure
AS
SET NOCOUNT ON
Declare #some_table TABLE (number int)
INSERT INTO #some_table VALUES (250)
SELECT number FROM #some_table
I am trying to insert data in an Oracle table by using ODP.NET from a C# application, but I am getting an ORA-01400 can't insert null value error for a column in which I am NOT inserting a null value.
This is the stripped down version of the parametrized SQL command I am trying to execute. It is wrapped in an OracleCommand and executed with an invokation of ExecuteNonQuery:
declare c int;
begin
select count(*) into c from "Entradas" where "Id" = :Id and nvl("AppId", 0) = nvl(:AppId, 0);
if c>0 then
update "Entradas" set
/*...a bunch of columns...*/,
"VisitaLaboral" = :VisitaLaboral,
/*...some more columns...*/
where "Id" = :Id and nvl("AppId",0) = nvl(:AppId, 0);
else
insert into "Entradas" (
/*... a bunch of columns...*/,
"VisitaLaboral",
/*...some more columns...*/
) values (
/*...a bunch of values...*/,
:VisitaLaboral,
/*...some more values...*/
);
end if;
end;
The row does not exist previously so it is the insert part of the command the one that is executed. Of course I have verified that all the column names and column value parameters are properly placed in the SQL text.
The problem is in the VisitaLaboral column. It is of type NUMBER(1,0), it does not accept NULLs, and I am trying to insert a value of 0. This is what Visual Studio displays about the associated OracleParameter immediately before the command execution:
However if I execute the command directly in Application Express (providing the values directly in the command text), it works fine and the row is inserted.
So, what is happening here? Is there a bug in the ODP.NET library, or am I doing something wrong?
Additional information:
Database is Oracle 10g Express Release 10.2.0.1.0
Oracle.DataAccess.dll version is 4.112.1.2
Using Visual Studio 2010, targeting .NET framework 4.0
Thank you in advance!
UPDATE:
Everything works fine if I use the (deprecated) System.Data.OracleClient classes instead of ODP.NET.
WTF, Oracle? No, really, WTF?
Your problem seems to be that you don't know what is actually happening in the database. The quickest solution will be to find out what happens and use that.
connect to the database
use dbms_session.set_sql_trace(true) to enable an sql trace
do your application action
disconnect from the database
find - or ask your dba - to send you the raw trace file
In the tracefile (a plain text file) find your code and see what happens when the error is raised.
It could be that a trigger fired ....
This is a DB level error message, you can be sure that the insert has null value. Is it possible to log out the sql statement generated by the ODP.NET?
Are you really really sure that you have the columns in the same order on both the insert clause and the values clause? Check your "bunch of columns" ...
Well I know nothing about ODP.net, but if there is a value in the parameter, should the precison, scale and size attributes all be zero (as they appear to be)?
We had the same problem. We solved the problem setting column property "IsNullable" to true.