PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → How to find and replace in SQL code
How to find and replace in SQL code
Débuté par What if x>y, 04 aoû. 2017 13:40 - 8 réponses
Posté le 04 août 2017 - 13:40
UPDATE Test sSQ1L IS string sSQL2 IS string sSQ1L = EDT_NoName1 //Replace string sSQL2 = EDT_NoName2 // Find string SET mame= sSQL1 WHERE Test.mame = sSQL2 How can i link the edit fields or a local variable to the query?
Posté le 04 août 2017 - 16:02
Hi,

make it :

UPDATE
Test
sSQ1L IS string
sSQL2 IS string
sSQ1L = %1 //Replace string
sSQL2 = %2 // Find string
SET
mame= sSQL1
WHERE
Test.mame = sSQL2


and then:
MySqlString = Stringbuild(MySqlString,EDT_NoName1,EDT_NoName2)
Posté le 04 août 2017 - 16:49
no result with that code either;
No replace took place and
when trying to run the query directly i receive a initialisation error

i used call code
HExecuteQuery(QRY_NoName3,hQueryDefault+hModifyFile)

what %1 and %2 stand for?
Posté le 04 août 2017 - 18:06
hi whoever you are,

use query Generator
choose update query
select your file
you get a list of items: click in the condition column and choose condition
click in the value column and choose conditon

and so on.

If ready, when the graphic of the query is displaying, you may Show the resulting SQL Syntax (right click -> the relevant menu)

g

Erik
Posté le 04 août 2017 - 18:54
theres only value and parameter in the options not variable;
Posté le 05 août 2017 - 10:08
The variables are in your program - send it to the query as parameters
Posté le 05 août 2017 - 11:31
can you give a example on how i can do this?
in training wd queries i found this ;
ofc this only goes so far since they are incluudit in the querie itself i want to know how i can pass a outside variable (Local procedure editfield,....) or parameter to a querie .Like i said above i am trying a simple find and replace bye editfield or parameter;

Also are there better sources ;better practical examples incluudit in windev other then wd queries cuz again its lacking depth and its not practical since passig a parameter from outside a query seems to be basic yet i cant seem to find it.

SELECT
CUSTOMER.CustomerName AS CustomerName,
CUSTOMER.Company AS Company,
CUSTOMER.ZipCode AS ZipCode,
CUSTOMER.CITY AS CITY,
CUSTOMER.Country AS Country
FROM
CUSTOMER
WHERE
CUSTOMER.CustomerName LIKE {pCustomerName}%
AND CUSTOMER.Company LIKE {pCompany}%
AND CUSTOMER.CITY LIKE {pCity}%
AND CUSTOMER.Country LIKE {pCountry}%
ORDER BY
CustomerName ASC
Posté le 05 août 2017 - 12:48
Quote
What if x>y

SELECT
CUSTOMER.CustomerName AS CustomerName,
CUSTOMER.Company AS Company,
CUSTOMER.ZipCode AS ZipCode,
CUSTOMER.CITY AS CITY,
CUSTOMER.Country AS Country
FROM
CUSTOMER
WHERE
CUSTOMER.CustomerName LIKE {pCustomerName}%
AND CUSTOMER.Company LIKE {pCompany}%
AND CUSTOMER.CITY LIKE {pCity}%
AND CUSTOMER.Country LIKE {pCountry}%
ORDER BY
CustomerName ASC

When you were trading on here as 'newbie2' I did tell you to concentrate more on the tutorials - this still holds true and despite what you say most of what you need is there.
I also note that the query above does not match that of your original in this post - not sure quite what it is your trying to achieve with your posts.
There are no shortcuts to learning WD or any other programming tool for that matter.

For this particular query.....s_CustomerName,s_Company,s_City,s_Country is ANSI String //These will be declared in your window //How you decide to populate them with valid values is up to you // 2 choices when setting the params and executing the query..... MyQuery.pCustomerName = s_CustomerName MyQuery.pCompany = s_Company MyQuery.pCity = s_City MyQuery.pCountry = s_Country HExecuteQuery(MyQuery,hQueryDefault) //Or send the params when executing the query HExecuteQuery(MyQuery,hQueryDefault,pCustomerName,pCompanypCity,pCountry)
There you go - its 'over and out' from me, good luck
Posté le 07 août 2017 - 11:03
Choose Parameter and when writing your query you will be automatically asked for the Parameter and there you can Input for example a value, a variable or an edit field.

Erik