Stored Procedure to INSERT VALUE to UDT
Hello Everyone,
I came across a situation that I have UDT "Temp", when I enter data in AP Invoice, is there any way to exactly replicate the detail line data in to UDT, Can it be done using Transaction Notification Stored Procedure?? the UDT "Temp" have same columns as of PCH1 with same data type.
Is it possible?? If so then please provide me the query to insert it in "Temp"..
Which SP I have to use then?? and please provide me query..
Thanks in advance
Hi Idrees,
if you Had made the UDT using SAP then please don't go for the Transaction Notification ... but if you have Created the table In Sql Server (Non-SAP Table ) the Go for The Transaction Notification
but if you use UDT then "SAPbobsCOM.oUserTable" Go for It make Insert /Update/Delete Through it.
Transaction Notification may be difficult to Handle.
Regards,
Mayank Shah.
Similar Messages
-
Stored Procedures - Basic Insert?
Trying to do a basic INSERT Store Procedure that isn't
working.
Created the SP in the database and went to Dreamweaver.
-----------------My Stored Procedure-----------------
CREATE PROCEDURE dbo.spAddShippingAddress (@OneA varchar(50))
AS
INSERT INTO aXOne (OneA)
VALUES (@OneA)
GO
-----------------My Stored Procedure-----------------
aXOne is the Table and OneA is the Column
So which do I use in Dreamweaver, "Stored Procedure" or
"INSERT"?
Also, since this is an insert, I have a form page that
submits to the
page with the Command on it.
Nothing seems to work. Any ideas welcome. ThanksProcedure is close. It will work as-is, but get in the habit
of adding
certain commands to every procedure; these will prevent
issues in certain
situations. Also, do not use "sp" as a prefix - that's
reserved for system
procedures and changes the way SQL Server looks up the
procedure name. The
"web-friendly" version:
CREATE PROCEDURE [dbo].[AddShippingAddress]
@OneA VARCHAR(50)
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO dbo.aXOne(OneA)
VALUES (@OneA)
END
GO
As for the rest of it:
- Use the "stored procedure" option in Dreamweaver. The
"insert" option is
what you would use if you were executing the actual insert
query without the
procedure as a wrapper (keep the procedure - it's just nicer
for everyone in
the end).
- There's nothing wrong with the form submitting to the page
with the
command on it. Make sure you've got the parameters set up
properly (form
method="post", then Request.Form; method="get" then
Request.QueryString) and
double-check your data types.
By "doesn't work", please be specific - is there an error, or
does the page
execute normally while not inserting the record or inserting
a blank record,
or...
"Lee" <[email protected]> wrote in message
news:eqvt5u$a0l$[email protected]..
> Trying to do a basic INSERT Store Procedure that isn't
working.
>
> Created the SP in the database and went to Dreamweaver.
> -----------------My Stored Procedure-----------------
> CREATE PROCEDURE dbo.spAddShippingAddress (@OneA
varchar(50))
> AS
> INSERT INTO aXOne (OneA)
> VALUES (@OneA)
> GO
>
> -----------------My Stored Procedure-----------------
>
> aXOne is the Table and OneA is the Column
>
> So which do I use in Dreamweaver, "Stored Procedure" or
"INSERT"?
>
> Also, since this is an insert, I have a form page that
submits to the page
> with the Command on it.
>
> Nothing seems to work. Any ideas welcome. Thanks -
Issue using SQL stored procedure to insert/update
With help I finally managed to execute the stored procedure to insert/ update the sql database with the below stored procedure
ALTER PROCEDURE [dbo].[uspInsertorUpdate]
@dp char(32),
@dv char(32),
@e_num char(12),
@mail varchar(50),
@emerg char(32),
@opt1 char(16),
@stat char(20),
@e_id char(35),
@e_tit varchar(64),
@e_date datetime
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS (SELECT 1 FROM [dbo].[sampleemployee] WHERE e_id= @e_id)
BEGIN
UPDATE [dbo].[sampleemployee]
SET dp = @dp,
dv = @dv,
e_num = @e_num,
mail = @mail,
emerg = @emerg,
opt1 = @opt1,
stat = @stat,
e_tit = @e_tit,
e_date = @e_date
WHERE e_id = @e_id
END
ELSE
BEGIN
INSERT INTO [dbo].[sampleemployee]( dp, dv, e_num, mail, emerg, opt1, stat, e_id, e_tit, e_date)
VALUES ( @dp, @dv, @e_num, @mail, @emerg, @opt1, @stat, @e_id, @e_tit, @e_date );
END
END;
But the issue here is it just insert only one row and update that row only, even if there are some no.of rows need to be inserted . Not sure whyHi Sid_siv,
To pass a table value to stored procedure, you can refer to the sample query below.
create type FileDetailsType as table
FileName varchar(50),
CreatedDate varchar(50),
Size decimal(18,0)
create procedure InsertFileDetails
@FileDetails FileDetailsType readonly
as
insert into
FileDetails (FileName, CreatedDate, Size)
select FileName, CreatedDate, Size
from
@FileDetails;
Reference
http://www.codeproject.com/Articles/22392/SQL-Server-Table-Valued-Parameters
http://forum.codecall.net/topic/75547-sql-server-2008-passing-table-parameter-to-stored-procedure/
Regards,
Charlie Liao
TechNet Community Support -
How to change stored procedure with Table Valued Parameter
I am not sure how to change the normal stored procedure with Table Value Parameter.Do I have to create a separate Table or do I have to create a datatype. Can you please help me with this
ALTER PROCEDURE [dbo].[uspInsertorUpdateINF]
@dp_id char(32),
@dv_id char(32),
@em_number char(12),
@email varchar(50),
@emergency_relation char(32),
@option1 char(16),
@status char(20),
@em_id char(35),
@em_title varchar(64),
@date_hired datetime
AS
BEGIN
SET NOCOUNT ON;
MERGE [dbo].[em] AS [Targ]
USING (VALUES (@dp_id, @dv_id , @em_number, @email, @emergency_relation, @option1, @status, @em_id, @em_title, @date_hired))
AS [Sourc] (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired)
ON [Targ].em_id = [Sourc].em_id
WHEN MATCHED THEN
UPDATE
SET dp_id = [Sourc].dp_id,
dv_id = [Sourc].dv_id,
em_number = [Sourc].em_number,
email = [Sourc].email,
emergency_relation = [Sourc].emergency_relation,
option1 = [Sourc].option1,
status = [Sourc].status,
em_title = [Sourc].em_title,
date_hired = [Sourc].date_hired
WHEN NOT MATCHED BY TARGET THEN
INSERT (dp_id, dv_id, em_number, email, emergency_relation, option1, status, em_id, em_title,date_hired)
VALUES ([Sourc].dp_id, [Sourc].dv_id, [Sourc].em_number, [Sourc].email, [Sourc].emergency_relation, [Sourc].option1, [Sourc].status, [Sourc].em_id, [Sourc].em_title, [Sourc].date_hired);
END;It's not clear how you would change the procedure. But assuming that you want to replace the existing scalar parameters with tabular input, this is how you would do it. You first create a table type:
CREATE TYPE Insertor_type AS TABLE
(dp_id char(32),
dv_id char(32),
em_number char(12),
email varchar(50),
emergency_relation char(32),
option1 char(16),
status char(20),
em_id char(35),
em_title varchar(64),
date_hired datetime)
Then you change the procedure header:
ALTER PROCEDURE [dbo].[uspInsertorUpdateINF] @tvp Insertor_type READONLY AS
And finally you change the USING clause:
USING (SELECT dp_id, dv_id , em_number, email, emergency_relation, option1, status, em_id, em_title, date_hired
FROM @tvp) AS [Sourc] ON [Targ].em_id = [Sourc].em_id
The rest is fine as it is.
Erland Sommarskog, SQL Server MVP, [email protected] -
I have the follwing table is called master table contain the follwing fields,
So here i need to create three Stored procedures
1.Insert operations(1 o/p paramter,and 14 input paramters) - uspInsert
2.Update operations(1 o/p paramter,and 14 input paramters) - uspUpdate
3.Delete Operations(1 o/p paramter,and 14 input paramters)
- uspdelte
The following is the table ,so using this to make the three sp's ,Here we will use Exception machanism also.
Location
Client Name
Owner
ConfigItemID
ConfigItemName
DeploymentID
IncidentID
Package Name
Scope
Stage
Type
Start Date
End Date
Accountable
Comments
So can u pls help me out for this ,bcz i knew to stored procedure's creation.I have the follwing table is called master table contain the follwing fields,
So here i need to create three Stored procedures
1.Insert operations(1 o/p paramter,and 14 input paramters) - uspInsert
2.Update operations(1 o/p paramter,and 14 input paramters) - uspUpdate
3.Delete Operations(1 o/p paramter,and 14 input paramters) - uspdelte
The following is the table ,so using this to make the three sp's ,Here we will use Exception machanism also.
Location
Client Name
Owner
ConfigItemID
ConfigItemName
DeploymentID
IncidentID
Package Name
Scope
Stage
Type
Start Date
End Date
Accountable
Comments
So can u pls help me out for this ,bcz i knew to stored procedure's creation.
Why you have to pass 14 parameters for DELETE and UPDATE? Do you have any Primary Key? If you do NOT have primary key in your table then in case you have duplicate information, SQL will update both or delete them together. You need to provide DDL of
you table. What are the data types of fields?
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
How in ColdFusion with in variables get a Oracle stored procedure to return values?
How in ColdFusion with in variables get a Oracle stored procedure to return values?
We have tried several things, we can get a stored procedure to return a result set if we are not passing in variables but we cannot get them when we are passing in variables.
We know how to do it calling MS SQL.
Thanks for any help,
Nathan Sr
P.S. we have heard this may not be possible with the current Oracle Driver is there a different Oracle driver?I can only barely understand what you're asking here (not from a technical perspective, but from understanding your written English), but I suspect you're wanting to know how to pass back values other than recordsets from Oracle?
You should be able to pass them back via a type=out proc param, shouldn't you?
If you could reword your post so it's a bit more coherent, and possibly post some code, that might help.
Adam -
Report with stored proc running multiple stored procedures with insert statement
Hi,
I wonder if this is possible in SSRS ... I use the 2012 version (Data Tools).
I have a report that triggers a stored procedure. See below.
Within this SP there are 2 insert statements getting data from 2 other SP's.
When I make a dataset referring to the main SP below, SSRS does not show me any fields at all.
Is this because it's a SP with insert statements and nested SP's?
At the end of the SP I make a select so it should see all the fields.
The parameters @month and @costcenter are multivalue params. I use a special function to convert the multivalues, selected in the report, into a string to pass it correctly to the query (comma separated).
USE [TestDB]
GO
/****** Object: StoredProcedure [dbo].[_Pink_SP_StandingsRegisterDataset] Script Date: 15-4-2014 13:31:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[_Pink_SP_StandingsRegisterDataset]
@year INT,
@month NVARCHAR(50),
@costcenter NVARCHAR(500),
@GLaccount NVARCHAR(9)
AS
BEGIN
/* Remove existing content*/
DELETE FROM _Pink_TB_StandingsRegister
/* Add records part 1 */
INSERT INTO _Pink_TB_StandingsRegister
EXEC _Pink_SP_StandingsRegister @year, @month, @costcenter, @GLaccount
/* Add records part 2 */
INSERT INTO _Pink_TB_StandingsRegister
Type,
Row,
Year,
Month,
YearDatetable,
MonthDatetable
EXEC _Pink_SP_StandingsRegisterDatetable @year
/* Select all records */
SELECT *
FROM _Pink_TB_StandingsRegister
END
GOHi bijntjede2e,
After testing a similar scenario in my own environment, it works well in Reporting Services. In my test, the stored procedure returns all the fields from _Pink_TB_StandingsRegister table in the dataset. Then I select some values from year, month, costcenter
and Glaccount parameters, it inserts some values in the _Pink_TB_StandingsRegister table. So we can use this stored procedure as the dataset in the report.
In order to solve the problem more efficiently, I need to clarify some information.
Are you pass multiple values parameter to one stored procedure correctly? We can refer to the following thread:
http://social.technet.microsoft.com/Forums/en-US/dbdfa101-cccc-4e9f-aa50-566dc5ebcc27/ssrs-2008-r2-report-dataset-call-a-stored-procedure?forum=sqlrep
What results are you get when executing the stored procedure in SQL Server Management Studio? Is it works well? We should double those stored procedures.
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
when debugging SSIS, the "Execute SQL Task" runs a stored procedure and returns the expected value. When running the package a second time, the task returns an unexpected value. When running in VS2012 SQL editor, everything operates as expected.
Please help me debug how to get the stored proc to return the same value every time the SSIS Package is run. thanks!
Here is the sequence of events and what happens....
Look for a Positor that matches the Application, Host, and User
No matching PositorId is found, Creates new Positor row, returns that new PositorId
Use PositorId to upload some data (Every thing works)
re-run/debug the ssis pacakge
Look for a Positor that matches the Application, Host, and User
<No clue what is happening>
Returns -1 (SHOULD BE the same PositorId value returned in #2)
"Execute SQL Task" Setup: No edits to Result Set nor Expressions
"Execute SQL Task" Setup: GENERAL
"Execute SQL Task" Setup: PARAMETER MAPPING
SP called by "Execute SQL Task"
CREATE PROCEDURE [posit].[Return_PositorId]
AS
BEGIN
DECLARE @PositorId INT = [posit].[Get_PositorId]();
IF (@PositorId IS NULL)
BEGIN
DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
DECLARE @PositorNote NVARCHAR(348) = N'Automatically created by: ' + @ProcedureDesc;
EXECUTE @PositorId = [posit].[Insert_Positor] @PositorNote;
END;
RETURN @PositorId;
END;
Supporting SQL Objects:
CREATE FUNCTION [posit].[Get_PositorId]
RETURNS INT
AS
BEGIN
DECLARE @PositorId INT = NULL;
SELECT TOP 1
@PositorId = [p].[PO_PositorId]
FROM [posit].[PO_Positor] [p]
WHERE [p].[PO_PositorApp] = APP_NAME()
AND [p].[PO_PositorHost] = HOST_NAME()
AND [p].[PO_PositorUID] = SUSER_ID();
RETURN @PositorId;
END;
GO
CREATE PROCEDURE [posit].[Insert_Positor]
@PositorNote NVARCHAR(348) = NULL
AS
BEGIN
DECLARE @ProcedureDesc NVARCHAR(257) = OBJECT_SCHEMA_NAME(@@PROCID) + N'.' + OBJECT_NAME(@@PROCID);
SET @PositorNote = COALESCE(@PositorNote, N'Automatically created by: ' + @ProcedureDesc);
DECLARE @Id TABLE
[Id] INT NOT NULL
INSERT INTO [posit].[PO_Positor]([PO_PositorNote])
OUTPUT [INSERTED].[PO_PositorId]
INTO @Id([Id])
VALUES(@PositorNote);
RETURN (SELECT TOP 1 [Id] FROM @Id);
END;
GO
CREATE TABLE [posit].[PO_Positor]
[PO_PositorId] INT NOT NULL IDENTITY(0, 1),
[PO_PositorApp] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorApp] DEFAULT(APP_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorApp] CHECK([PO_PositorApp] <> ''),
[PO_PositorName] NVARCHAR(256) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorName] DEFAULT(SUSER_SNAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorName] CHECK([PO_PositorName] <> ''),
[PO_PositorHost] NVARCHAR(128) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorHost] DEFAULT(HOST_NAME()),
CONSTRAINT [CL__PO_Positor_PO_PositorHost] CHECK([PO_PositorHost] <> ''),
[PO_PositorSID] VARBINARY(85) NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorSID] DEFAULT(SUSER_SID()),
[PO_PositorUID] INT NOT NULL CONSTRAINT [DF__PO_Positor_PO_PositorUID] DEFAULT(SUSER_ID()),
[PO_PositorNote] VARCHAR(348) NULL CONSTRAINT [CL__PO_Positor_PO_PositorNote] CHECK([PO_PositorNote] <> ''),
[PO_tsInserted] DATETIMEOFFSET(7) NOT NULL CONSTRAINT [DF__PO_Positor_PO_tsInserted] DEFAULT(SYSDATETIMEOFFSET()),
[PO_RowGuid] UNIQUEIDENTIFIER NOT NULL CONSTRAINT [DF__PO_Positor_PO_RowGuid] DEFAULT(NEWSEQUENTIALID()) ROWGUIDCOL,
CONSTRAINT [UX__PO_Positor_PO_RowGuid] UNIQUE NONCLUSTERED([PO_RowGuid]),
CONSTRAINT [UK__Positor] UNIQUE CLUSTERED ([PO_PositorApp] ASC, [PO_PositorHost] ASC, [PO_PositorUID] ASC),
CONSTRAINT [PK__Positor] PRIMARY KEY ([PO_PositorId] ASC)
GO
ssdThe error is in item 7: Returns -1 (SHOULD BE the same PositorId value returned in #2); but no error message is returned or thrown from SSIS.
The error message indicated referential integrity is not upheld when inserting records. This error message occurs AFTER the Execute SQL Task successfully completes; the E.SQL Task returns -1. The executed SQL code will not allow values less than 0
([PO_PositorId] INT NOT NULL IDENTITY(0, 1),)
[Platts Valid [41]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E2F.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E2F Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E2F Description:
"The INSERT statement conflicted with the FOREIGN KEY constraint "FK__PricingPlatts_Posit_PositorId". The conflict occurred in database "Pricing", table "posit.PO_Positor", column 'PO_PositorId'.".
The aforementioned FOREIGN KEY constraint is due to the value being returned by the Execute SQL Task.; therefore, the error lies in the value returned by the Execute SQL Task. -
Stored Procedure for insert in a table
Hi everybody
I have to insert a line into a table to initialize the supply of a datawarehouse.
The table contains:
Id_chargement Oracle sequence
date_chargement sysdate
status 'EN COURS'
I read some message in this forum but I don't find the solution.
Can I call a procedure in the workflow ? Or must be use the preprocessing of the first map to call this stored procedure ?
But for the second solution, if I had a map before, I must change this call.So, it's not very interesting.
Have you a idea
Thank you for your help
Frederic from FranceHi Mahesh,
I created a procedure as
begin
insert into <table name> values( <timestamp value>);
end;
i added this procedure in the process flow, and as you said i added 1- Success, 2 - warning, 3 - error.
I am able to deploye the procedure and process flow,
after that when execute the process flow, that just says completed with errors,
no other information and oracle error messages are abilable in the
result panel
Job Final Status : Completed with errors
Job Processed Count : 1
Job Error Count : 0
Job Warning Count : 0
can you say , what could be the problem??
Thanks & regards
raja -
Hi,
cftransaction is working perfectly when all the insert
updates are called by cfqquery.
But when there is a mysql stored procedure call with in
cftrnsaction and that mysql stored procedure is having many inserts
and updates, cftransaction is not able to roll back insert/updates
happened in stored procedure.
I am using InnoDB tables/database of mysql.
Did anybody faced a similar problem and is it a coldfusion
bug or mysql bug.
We checked with Java and java is able to roll back the
transaction, but coldfusion cftransaction is failing.
Please help.
Regards,
SaikumarMark,
I believe the syntax of your formatted search is not right. I guess you are trying to get the U_Width from Item Master and the other values from the current form.
SELECT @Width = T0.U_WTH FROM [dbo].[OITM] T0.WHERE T0.ItemCode = $[$38.1.0]
EXEC TBC_CHOP @Width, $[$38.U_LINETYPE.0], $[$38.U_LI.0], $[$38.U_LN.0],
$[$38.U_LD.0], $[$38.U_HI.0], $[$38.U_HN.0], $[$38.U_HD.0], $[$38.U_QTYORD.Number]
If you see I have added a third parameter which is the Type to the formatted seach field selection $[$Item.Column.Type]
I have made then all 0 but you may change it as per the col type. This Type should be 0 for Char type columns, Number for numeric columns and Date for Date type cols
Suda -
Stored procedure to insert/update data ?
Hi,
i have a stored procedure which checks for a specified user and a specified timespan (from - to) its allocations on tasks. The timespan is cut into 30-minute fragments by the SP.
Very abstract model
TASK (zero to many) REQUIRED_RESOURCE (zero to many) ALLOCATED_USERThe stored procedure returns a ref cursor with the following columns. The TASK_ID can be null which means there is no allocation between that START_TIME and STOP_TIME. Otherwise the user is allocated on that specific task. Because the data is cut into 30-minute fragments, STOP_TIME is always 30 minutes after START_TIME.
START_TIME, STOP_TIME, USER_ID, TASK_IDAll good so far.
I would like to store the data returned by the SP in a table. This allows me for more flexible use of the data. I'm thinking of storing the data as follows (STOP_TIME isn't really needed for storing...):
START_TIME (pk)
USER_ID (pk)
TASK_ID (null)**How can I somehow 'process' the ref-cursor returned by the SP, so that data in my new table is inserted if the START_TIME + USER_ID combination doesn't exist yet or updated if it already exists?**
Thanks for thinking along!
This is the SP for reference (TRUNC30 is a function that Truncates a DateTime value to the nearest 30-minute part):
create or replace
PROCEDURE REPORT_PLAN_AV_USER
from_dt IN date,
to_dt IN date,
sysur_key IN number,
v_reservations OUT INTRANET_PKG.CURSOR_TYPE
IS
BEGIN
OPEN v_reservations FOR
with
MONTHS as (select FROM_DT + ((ROWNUM-1) / (24*2)) as DT from DUAL connect by ROWNUM <= ((TO_DT - FROM_DT) * 24*2) + 1),
TIMES as (select DT as START_TIME,(DT + 1/48) as STOP_TIME from MONTHS where TO_NUMBER(TO_CHAR(DT,'HH24')) between 8 and 15 and TO_NUMBER(TO_CHAR(DT,'D')) not in (1,7))
select
TIMES.START_TIME,
TIMES.STOP_TIME,
T.TASK_ID,
sysur_key USER_ID,
from
TIMES
left outer join (ALLOCATED_USER u INNER JOIN REQUIRED_RESOURCE r ON u.AU_ID = r.RR_ID INNER JOIN TASK t ON r.TASK_ID = t.TASK_ID)
ON u.USER_ID = sysur_key AND t.PLAN_TYPE = 3 AND TIMES.start_time >= TRUNC30(t.START_DATE) AND TIMES.start_time < TRUNC30(t.FINISH_DATE)
where u.USER_ID is null OR u.USER_ID = sysur_key
order by START_TIME ASC;
END;Hi,
user574699 wrote:
So I should MERGE ON (start_time AND user_id) if i'm correct?Right: the ON condition will be a compound condition; both the time and the user_id have to be the same if the rows match.
Oh, and is is possible to 'encapsulate' the MERGE statement in the SP? Or should I write another SP that selects from the output cursor as input for the MERGE statement?There's no need for a cursor or a second procedure.
If the query you posted is producing what you want, just put it in the USING clause as it is, except that you won't need an ORDER BY clause. -
Stored procedure returning some value
Hi All Experts,
I have written one stored procedure which is returning different
integer values according to condition.I am calling this
stored procedure through prepareCall() method then executeUpdate() method ,but it is always returning 1,not my desired value.
Pl help by writing some sample code.
Thanx in Advance.
Pradipto....haven't u study the sql api for java?
"either the row count for INSERT, UPDATE or DELETE statements; or 0 for SQL statements that return nothing"
return 1 means that u update 1 row count.
So, if u want to return the data(int) from the database, u should use query to achieve it. -
Tsql stored procedure bulk insert
Hi,
The following code works perfectly:
cfquery datasource="#SESSION.DSN#">
BULK INSERT dbo.Syndicated
FROM '#selectedfile#'
WITH
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW = 2
</cfquery>
I created this stored procedure:
CREATE
PROCEDURE dbo.uspInsertSyndicatedRecords@selectedfile
varchar(2000)
AS
BEGIN
BULK INSERT Syndicated
FROM '@selectedfile'
WITH
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW = 2
END
I'm getting an error: The file "@selectedfile" does not exist.
Anyone know if there are issues with the file path in a stored procedure. #selectedfile# = C:\ColdFusion8\wwwroot\cfdocs\mis35\luxury.csv
Thanks!
cfwildUnfortunately, dynamic queries don't work within TSQL - meaning you can't substibute table and column names with variables. You can only use variables for the comparison values or select values.
However, you can create a variable, build the SQL statement in that variable and execute it:
DECLARE @SQLString VARCHAR(max)
SET @SQLString = 'SQL Start ....' + @MyVar + ' .... SQLEnd'
EXEC(@SQLString)
Now, if the variable being concatinated is not a string, you will need to cast/convert it to string, which just adds tons of fun to the equation.
Hope this helps! -
Stored procedure OUTPUT VARCHAR2 value truncated using 12c client on Server 2012
Questions:
1) Is there a version of Oracle Client 11g which runs on Server 2012? My 11.2.0.0, when the installer begins, says my Server 2012 (8GB mem, 80 GB drive) does not meet the minimum requirements and I should not install it. This same installer worked on Server 2008.
2) Have you seen the following behavior from Oracle client 12c? Are there any patches?
When I was unable to find a version of Oracle 11g client for Windows Server 2012, I downloaded Oracle 12c. We have a few stored procedures, when invoked from a Windows Server 2008 with an 11g client work. However, when running that some code on a Windows Server 2012 machine does not work. I have certain stored procedures with an OUTPUT parameter when executed on 2012 has the values truncated.
For instance:
Output parameter is set to return "SUCCESS", but was is received is "SUC"
Ouput parameter is set to return "AllSet", but it returns "All"
Output parameter is set to cast a NUMBER to a VARCHAR2 and the value is a 5 digit number, but only the first two digits are returned. Ex: "83976", but only "83" appears.
The above takes place when run from Server 2012, but works fine from Server 2008 and Win 7.Questions:
1) Is there a version of Oracle Client 11g which runs on Server 2012? My 11.2.0.0, when the installer begins, says my Server 2012 (8GB mem, 80 GB drive) does not meet the minimum requirements and I should not install it. This same installer worked on Server 2008.
2) Have you seen the following behavior from Oracle client 12c? Are there any patches?
When I was unable to find a version of Oracle 11g client for Windows Server 2012, I downloaded Oracle 12c. We have a few stored procedures, when invoked from a Windows Server 2008 with an 11g client work. However, when running that some code on a Windows Server 2012 machine does not work. I have certain stored procedures with an OUTPUT parameter when executed on 2012 has the values truncated.
For instance:
Output parameter is set to return "SUCCESS", but was is received is "SUC"
Ouput parameter is set to return "AllSet", but it returns "All"
Output parameter is set to cast a NUMBER to a VARCHAR2 and the value is a 5 digit number, but only the first two digits are returned. Ex: "83976", but only "83" appears.
The above takes place when run from Server 2012, but works fine from Server 2008 and Win 7. -
A temp table in a stored procedure , set a value to varchar(MAX)
Hi ,,
In stored procedure there is a temp table and set a value to varchar(MAX) . What exactly is the different between setting it to varchar (MAX) instead of varchar(n)
Thank You
Jeevan VinayVinay,
Spend some time online to read and search about your problem before blindly posting it on forum, if you would have done that you could have found out eaisly below two links which will explain you in deep
http://stackoverflow.com/questions/3682821/difference-between-varchar500-vs-varcharmax-in-sql-server
http://sqlhints.com/2013/03/10/difference-between-sql-server-varchar-and-varcharmax-data-type/
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Wiki Article
MVP
Maybe you are looking for
-
I have two email accounts and would like to link face Time to both of them.. I tried to "add aanother email" but got an error message on verification saying the email is already in use. It is.. by me! Is there any way I can add the second email acc
-
How much electricity does an Airport Express use (approximately)?
How much electricity does an Airport Express 802.11n use (approximately)? Is turning it off at night to save money a good idea or a bad idea?
-
Hi , I having problem in VAT round off during MIRO. We have created PO +VAT. VAT amount has been rounded off. After GRN, we are trying to post the Invoice in MIRO, the VAT amount shows with Decimal We are using ZTAXIN , in the tax pricing proceedure
-
Hi all! I'm very new to Oracle BI EE. My need is to create my first report in BI. I've opened Oracle BI Administration Tool, created new repository, added physical tables, created new item named "reports" in "Business Model and Mapping" section, made
-
Installing Rar: Rar can't find files to archive
I'm trying to install rar from rarlabs.com on my macbook. I have it installed, but when I try to archive a file, I get a : Cannot open {path} No such file or directory Warning: No Files error message. Googling has given me little help. I found this b