i have nou 2 query´s TADOQuery and TADOQuery1 and i wouth like to update TADOQuery record´s from TADOQuery1 via code is it possible ??
they have the same field´s
Thank´s
Ml
You can use the Clone method like this:
ADOQuery1.Clone(ADOQuery2);
I hope this will help.
Related
I have been using ZeosLib Components with Delphi and Lazarus for the past 10 years or so. I'm mostly using it to access MySQL Databases.
Now I have run into a strange Problem with TZReadOnlyQuery.
In my MariaDB database I have a pretty complex stored procedure that takes some input parameters, one inout param and one out param. Because of the error I get, when I try to call it with TZReadOnlyQuery, I have made a very simple procedure to test it.
This is my test procedure:
CREATE PROCEDURE MyProc(INOUT a VARCHAR(255), OUT r VARCHAR(255))
BEGIN
set a = 'inparam changed';
set r = 'outparam set';
END
I tried to call this procedure from different MySQL query/managment tools with this statement:
set #x = 'inputparam';
call MyProc(#x, #y);
select #x, #y;
I get the expected answer: a dataset with one record and two fields like this:
But when I add the same query statement to a TZReadOnlyQuery and try to open it I get an error message:
Any ideas why this happens and how to work around it?
Thanks!
At the point of posting a record to a database table I get the following error:
Could not parse sql timestamp string.
At the click of a button my code does the following:
qry1.Open;
qry1.Insert;
qry1.FieldByName('files_uploaded').asdatetime := qry2.FieldByName('files_uploaded').asdatetime;
qry1.Post;
qry1.Close;
The datatype for the field in the database table is timestamp.
Example of the data in the field : 2014-04-23T14:48:40.816+01:00.
I'm not entirely sure what I'm doing wrong or unless its something to do with the field data.
Any help would be appreciated.
Please try this code:
qry1.Open;
qry1.Insert;
qry1.FieldByName('files_uploaded').AsSQLTimeStamp :=qry2.FieldByName('files_uploaded').AsSQLTimeStamp;
qry1.Post;
qry1.Close;
Try setting ".Value" instead of defining the Data Type. When you use .Value the dataset will convert everything that is necessary.
qry1.Open;
qry1.Insert;
qry1.FieldByName('files_uploaded').Value :=qry2.FieldByName('files_uploaded').Value;
qry1.Post;
qry1.Close;
IIF(Col1=1, DAT1, IIF(Col2=1, DAT2, IIF(col3=1, DAT3, IIF(Col4=1, DAT4))))
The above is the informatica piece of code
How do i convert this in oracle
case when col1=1 then data1
else
case when col2=1 then data2)
I have tried something like this.But i am not sure .Please suggest me on how to convert
You don't need multiple, nested CASE statements, one is enough:
CASE
WHEN Col1=1 THEN DAT1
WHEN Col2=1 THEN DAT2
WHEN Col3=1 THEN DAT3
WHEN Col4=1 THEN DAT4
END
Hey guys this is a stored procedure that updates the PrevLoc field..but I want my proc to insert the upadate in to different field I do not want this to modify the original field as I still want to keep it as it is.Could you guys help on this?I greatly appreciate it.Thanks all
ALTER PROC [dbo].[updateloc]
AS
UPDATE Stage.Loc
SET PrevLoc=RTRIM(PrevLoc)
UPDATE Stage.Loc
SET PrevLoc = REPLACE(PrevLoc, substring(PrevLoc, LEN(PrevLoc) -
(CHARINDEX(' ', REVERSE(PrevLoc)))+ 1, LEN(PrevLoc)), dbo.parsLocat(PrevLoc))-- --this is a function that I use
SET changedLoc=PrevLoc---this doesnt work
GO
is changeLoc a column in the table?
You would just need to set that property instead.
These changes would leave PrevLoc with no changes at all, and process that value into changeLoc
ALTER PROC [dbo].[updateloc]
AS
UPDATE Stage.Loc
SET changeLoc=RTRIM(PrevLoc)
UPDATE Stage.Loc
SET changeLoc = REPLACE(changeLoc, substring(changeLoc, LEN(changeLoc) -
(CHARINDEX(' ', REVERSE(changeLoc)))+ 1, LEN(changeLoc)), dbo.parsLocat(changeLoc))-- --this is a function that I use
GO
Simple question, as the title suggests:
What is the syntax to drop a Stored Procedure (SP) in SQL Server 2000, by first checking that the SP exists?
Please provide the full code.
Microsoft recommended using the object_id() function, like so:
IF EXISTS (select * from dbo.sysobjects where id = object_id(N'[dbo].[YourProcedure]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[YourProcedure]
GO
.
object_id() helps resolve owner conflicts. If you do
SELECT name FROM sysobjects WHERE name = 'my_procedure'
, you may see many different procedures with the same name -- all for different owners.
But, SELECT * FROM sysobjects WHERE id = object_id(N'[my_procedure]') will only show you the one for the current owner/user, if more than one procedure by that name exists.
Still, always specify the object owner (default is dbo). Not only does this avoid nasty side-effects, it's a little faster too.
Not for SQL Server 2000, but starting with SQL Server 2016, you can use the IF EXISTS syntax:
DROP PROCEDURE IF EXISTS [sp_ProcName]
A slightly simpler method without going to system tables:
IF OBJECT_ID('my_procedure') IS NOT NULL DROP PROCEDURE my_procedure
GO
Like this:
IF EXISTS (SELECT name FROM sysobjects WHERE name = 'my_procedure' AND type = 'P')
DROP PROCEDURE my_procedure GO
Hope that helps!
You can do the following if you want to remove multiple Procedures.
NB: This syntax works on SQL Server 2016 and later
USE [Database_name]
GO
BEGIN
DROP PROCEDURE IF EXISTS 'my_procedure1',
'my_procedure2',
'my_procedure3',
'my_procedure4',
'my_procedure5',
END
In SQL SERVER 2008, if you want to drop a stored procedure just write the below command....
DROP PROC Procedure_name
DROP PROC dbo.spInsertUser
Hope it helps..