Subject Re: [firebird-support] Copy row to row in stored procedure
Author Martijn Tonies
> The only way? Isn't it possible to select the name of fields of the table
> from system tables and then build a statement that you can execute in a
> stored procedure?
>

Yes, that would be possible, but only directly with a INSERT INTO ... SELECT
statement as you cannot have a dynamic number of variables.

With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com


> Set
>
> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com] On Behalf Of Martijn Tonies
> Sent: 23. mars 2009 14:11
> To: firebird-support@yahoogroups.com
> Subject: Re: [firebird-support] Copy row to row in stored procedure
>
> Hi,
>
>>But it is not EASY way:
>>1) There may be many columns in a table.
>>2) Columns may be added or deleted in the future.
>>So maintenance cost of such solution is high,
>>and code readability is low.
>
> It is, however, the -only- way... Firebird PSQL does not (yet) have
> a "rowtype" variable.
>
> With regards,
>
> Martijn Tonies
> Upscene Productions
> http://www.upscene.com
>
> Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
> Anywhere, MySQL, InterBase, NexusDB and Firebird!
>
> Database questions? Check the forum:
> http://www.databasedevelopmentforum.com
>
>
>
> 2009/3/23, Nick Upson <nick.upson@...>:
>> insert into tablea (col1, col2, ...) select col1, col2, ... from tablea
>> where
>>
>> 2009/3/23 Valeri Mytinski <valeri.mytinski@...>:
>>> I have to copy one (existing) row to another (new) row in the same
>>> table within stored procedure.
>>> 3 steps needed as I see:
>>>
>>> 1. Fetch whole row into "record-like" variable or something else.
>>> 2. Change PK in "variable".
>>> 3. Insert new row with values from "variable".
>>>
>>> Do you know easy way(s) for this? Or may be special tools for this
>>> exists
>>> in FB?
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>