Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
procedure PrintPostponeReminder(const JurorsData : TDataSet);
begin
While not JurorsData.eof do
begin
//process each record of the passed in dataset
end;
end;
procedure ProcessPostPoneReminder(ADate : string);
begin
With dmJMS.qryProcessPPReminders do
begin
SQL.Clear;
SQL.Add('SELECT * FROM JMPMAIN WHERE TERMDATE = ' + QuotedStr(ADate) + ' AND STATUSCD = ''PP''');
Active := True;
//check if the query returned any records and if so, print letters
If not isempty then
[COLOR=red]PrintPostponeReminder(dmJMS.qryProcessPPReminders);[/color]
end;
end;
i want to duplicate a record in a query ... without passing thru field by field
I have 300 tables and what i want to do is putting a table by a parameter to select the same code to any table i want.thanks a lot.
procedure Something (ATableName : string);
begin
with qrySomething do
begin
SQL.Add('INSERT INTO ' + ATableName + ' REST OF QUERY');
ExecSQL;
end;
end;
CREATE PROCEDURE q_CopyRecord
(@TableName varchar(32),
@KeyField varchar(32),
@ExistingValue varchar(32),
@NewValue varchar(32))
AS
/* This procedure copys records in a table to new records in that table with a new, specified, key.
The parameters are:
@TableName - obvious
@KeyField - obvious
@ExistingValue - The key value of the record to be copied.
@NewValue - The Key value for the new record.
If the Key Values are strings then they must be enclosed with inverted commas.
e.g. to copy a scheme
EXECUTE q_CopyRecord Schemes, SchemeCode, 'VSI200','VS200'
*/
/* Create a list of field names for this table */
DECLARE ColumnList INSENSITIVE CURSOR FOR
SELECT
c.name
FROM
sysobjects o
JOIN syscolumns c ON c.id=o.id
WHERE
o.name=@TableName
DECLARE
@COLUMN_NAME varchar(32),
@tt1 varchar(255),
@tt2 varchar(255),
@tt3 varchar(255),
@tt4 varchar(255),
@tt5 varchar(255),
@tt6 varchar(255),
@tt7 varchar(255),
@tt8 varchar(255),
@tt9 varchar(255),
@tt10 varchar(255),
@tt11 varchar(255),
@tt12 varchar(255),
@ttt varchar(255),
@nn int
SELECT
@tt1="",
@tt2="",
@tt3="",
@tt4="",
@tt5="",
@tt6="",
@tt7="",
@tt8="",
@tt9="",
@tt10="",
@tt11="",
@tt12="",
@nn=1
/* Cycle through the fields creatng a list of them
The list is kept in multiple local variables because
255 chars would not be enough. The system is very rough.
It can be improvedor dispensed with for SQL Server 7+
because longer variables are allowed */
OPEN ColumnList
WHILE 1=1 BEGIN
FETCH ColumnList INTO
@COLUMN_NAME
IF (@@FETCH_STATUS<>0) BREAK
IF(@COLUMN_NAME<>@KeyField) BEGIN
IF @nn<=5
SELECT @tt1=@tt1+','+@COLUMN_NAME
ELSE IF @nn<=10
SELECT @tt2=@tt2+','+@COLUMN_NAME
ELSE IF @nn<=15
SELECT @tt3=@tt3+','+@COLUMN_NAME
ELSE IF @nn<=20
SELECT @tt4=@tt4+','+@COLUMN_NAME
ELSE IF @nn<=25
SELECT @tt5=@tt5+','+@COLUMN_NAME
ELSE IF @nn<=30
SELECT @tt6=@tt6+','+@COLUMN_NAME
ELSE IF @nn<=35
SELECT @tt7=@tt7+','+@COLUMN_NAME
ELSE IF @nn<=40
SELECT @tt8=@tt8+','+@COLUMN_NAME
ELSE IF @nn<=45
SELECT @tt9=@tt9+','+@COLUMN_NAME
ELSE IF @nn<=50
SELECT @tt10=@tt10+','+@COLUMN_NAME
ELSE IF @nn<=55
SELECT @tt11=@tt11+','+@COLUMN_NAME
ELSE SELECT @tt12=@tt12+','+@COLUMN_NAME
SELECT @nn=@nn+1
END
END
CLOSE ColumnList
DEALLOCATE ColumnList
/* Run the statement that will add our new record(s) */
EXECUTE(
"INSERT INTO "+@TableName+
"("+@KeyField+@tt1+@tt2+@tt3+@tt4+@tt5+@tt6+@tt7+@tt8+@tt9+@tt10+@tt11+@tt12+")"+
"SELECT "+
@NewValue+@tt1+@tt2+@tt3+@tt4+@tt5+@tt6+@tt7+@tt8+@tt9+@tt10+@tt11+@tt12+"FROM "+@TableName+" WHERE "+@KeyField+"="+@ExistingValue
)