Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 2 Monaten, 2 Wochen
Letzter Beitrag:
vor 2 Monaten, 2 Wochen
Beteiligte Autoren:
What if x>y, Erik Schwarz, DerekT, Stefan Bentvelsen

How to find and replace in SQL code

Startbeitrag von What if x>y am 04.08.2017 11: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?

Antworten:

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)

von Stefan Bentvelsen - am 04.08.2017 14:02
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?

von What if x>y - am 04.08.2017 14:49
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

von Erik Schwarz - am 04.08.2017 16:06
theres only value and parameter in the options not variable;

von What if x>y - am 04.08.2017 16:54
The variables are in your program - send it to the query as parameters

von DerekT - am 05.08.2017 08:08
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

von What if x>y - am 05.08.2017 09:31
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

von DerekT - am 05.08.2017 10:48
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

von Erik Schwarz - am 07.08.2017 09:03
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.