1

Topic: Select Replace

SELECT REPLACE (' Zamenit1, Zamenit2, Zamenit3 ', t., t.)
FROM t

Result in t-sql: ' Zamenili1, Zamenili2, Zamenili3'
How such becomes in firebird? All rummaged

2

Re: Select Replace

RedGate wrote:

as such becomes in firebird?

And becomes. doc/README.builtin_functions.txt

3

Re: Select Replace

SELECT @StrParam=REPLACE (@StrParam, t., t.)
FROM t

Well and as then here it to translate on firebird

4

Re: Select Replace

RedGate wrote:

SELECT @StrParam=REPLACE (@StrParam, t., t.)
FROM t

Well and as then here it to translate on firebird

FOR
SELECT REPLACE (:StrParam, t., t.)
FROM t
INTO: StrParam
DO
BEGIN
.
.
.
END

5

Re: Select Replace

Yes I saw this construction but I and did not understand as with it to work.
Result for select will be n  into:StrParam equal to a record count in the table t and how in construction DO it is all to connect in a unique line to the substituted values??

6

Re: Select Replace

RedGate, here the programmer is necessary...
Describe parameter StrParam in resultant rowset EXECUTE BLOCK', replace BEGIN... END in FOR on SUSPEND, think as to initialize starting value StrParam and you will receive too most that does your request on MySQL. What's the problem?
FirebirdSQL Reference Manuals

7

Re: Select Replace

RedGate;

CREATE FUNCTION REPLACE_BY_TABLE (StrParam VARCHAR (4000)) RETURNS VARCHAR (4000)
AS
BEGIN
FOR
SELECT t., t.
FROM T
AS CURSOR C DO
BEGIN
StrParam=REPLACE (StrParam, C., C.);
END
RETURN StrParam;
END

8

Re: Select Replace

Simonov Denis, and if at it v2.5? smile

9

Re: Select Replace

rdb_dev;
Alters on procedure, and instead of the link to the cursor variables involves.
.. t-sql it MS SQL, instead of MySQL

10

Re: Select Replace

Simonov Denis, I also forgot that he wrote about Transact-SQL...

11

Re: Select Replace

Simonov Denis, at me FB3
Though in function though in a script

FOR
SELECT t., t.
FROM T
AS CURSOR C DO
BEGIN
StrParam=REPLACE (StrParam, C., C.);
END

Swears on a body begin/end

12

Re: Select Replace

RedGate wrote:

and as then here it to translate on firebird

And what this strange expression generally does? Simply throw out "@StrParam =" and the task is reduced to
The previous.

13

Re: Select Replace

RedGate;
Yet really? The error text you suggest  to guess?
At you truth weeding here so "ChtoZamenit", "Changeover" are called?

14

Re: Select Replace

The essence simple is a line "' Zamenit1, Zamenit2, Zamenit3 '" it is necessary to replace these values with substitution from the table
In t-sql becomes single line

SELECT @StrParam=REPLACE (@StrParam, t., t.)
FROM t

As a result should Zamenili1, Zamenili2, Zamenili3 "turns out StrParam ="
I already why such construction does not work. What dances with a tambourine still should be danced?

SELECT REPLACE (:StrParam, t., t.)
FROM t
INTO:StrParam

15

Re: Select Replace

Fields wrote as an example, on  are called, an error here

BEGIN
StrParam=REPLACE (StrParam, C., C.);
END

16

Re: Select Replace

RedGate wrote:

why such construction does not work. What dances with a tambourine still should be danced?

To read Language Reference. Then to remove INTO.

17

Re: Select Replace

Dimitry Sibiryakov;
Personally to me it is not clear that this construction returns in t-sql if in t is more than one record

18

Re: Select Replace

Simonov Denis, in t-sql this construction returns StrParam with the substituted values an amount replac to equally amount of lines in samplings to the given table

19

Re: Select Replace

RedGate;
At you an input and an output one and as a variable. Whether the changed value after the first record on an input of function for the second record is substituted? If there is no that enough

SELECT REPLACE (CAST (:StrParam AS VARCHAR (4000)), t., t.) AS StrParam
FROM t

20

Re: Select Replace

RedGate;
The exact text of an error where?

21

Re: Select Replace

RedGate, questions we will answer?

Denis wrote:

RedGate;
Yet really? The error text you suggest  to guess?
At you truth weeding here so "ChtoZamenit", "Changeover" are called?

22

Re: Select Replace

RedGate wrote:

Zamuchalsja I already why such construction does not work. What dances with a tambourine still should be danced?

it is not necessary any dances with tambourines! It is necessary to read, only, Firebird 3.0 Language Reference from cover to cover or to call the programmer who is able to read.

23

Re: Select Replace

You of that philosophize?
I speak that such construction in t-sql, in one line without creations of functions and procedures

SELECT @StrParam=REPLACE (@StrParam, t., t.)
FROM t

Produces variable StrParam with the replaced values which are taken from the table t.
The question was, how such to make in Firebird? A type construction:

SELECT REPLACE (:StrParam, t., t.)
FROM t
INTO: StrParam

Does not work.
Also tell to me manual page where such situation is described. Construction FOR SELECT demands for my task of 2 more variables in which will be is brought values after each iteration that is not comprehensible.
If it is impossible to write a simple construction and tell, that fingers that to bend?

24

Re: Select Replace

RedGate;
I one request showed to you, only value should be derived not from a variable and from field StrParam
But if you do not need to solve the task, to consider that it it can is impossible

25

Re: Select Replace

RedGate;
Here so try:

execute block
returns (teststring varchar (100))
as
begin
teststring = ' 700 600 500 400 300 200 100 ';
for select replace (:teststring, ' 400 ', a.s_name)
from sprav a
where a.priz_spr=7 and a.s_name containing ' 841'
into:teststring
do
begin
end
suspend;
end