Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
11
Erster Beitrag:
vor 11 Monaten, 4 Wochen
Letzter Beitrag:
vor 11 Monaten, 3 Wochen
Beteiligte Autoren:
Sivaprakash, Alexandre Leclerc, Peter Holemans, Yogi Yang, Peter Muckle, Fabrice Harari

[WD20] [HFSQL20] Passing parameter

Startbeitrag von Sivaprakash am 27.08.2016 10:39

Hello,

How to pass a set of parameter to query which is filtered with 'in..'

Select *
From [TableName]
Where [ColumnName] in [(param1)]

I need to pass value to this param1 from windev.
Usually I assign values like this

query.param1 = 'A'

Couldn't find out how to pass array of values.

Happiness Always
BKR Sivaprakash

Antworten:

Hi

from the top of my head, it's something like:
Query.paramIN = "A;B;C"

Best regards

von Fabrice Harari - am 27.08.2016 11:22
Hello,

Trying to display the query result in a table. Query is

Select *
From [TableName]
Where [ColumnName] in [(param1)]

// Query usage
table1.browsedfile = ""
qry.param1 = "A;B;C"
HExecuteQuery(qry, hquerydefault)
table1.browsedfile = qry

I get the error:
Error at line xxx of click btn_x process,
the file or view or query, 'qry' is unknown.

If I remove the param1 assignment, the query executes perfectly, but I get all the values from the file. Tried all known ways (to me), get qry is unknown error only.

Any suggestions ?

Happiness Always
BKR Sivaprakash

von Sivaprakash - am 29.08.2016 13:56
Have you tried

table1.browsedfile = "qry"

with quotes around?

von Peter Muckle - am 29.08.2016 14:00
Sorry, I missed to quote here. But in my code, it's there.

von Sivaprakash - am 29.08.2016 14:03
Hi Sivaprakash,

What is the name of your actual query? Is it a query you made with the query editor or is it a query you made in a string?

This will totally change how you must pass the parameters. If you made it in the query editor, use the same name. I'm quite sure it is not "qry".

Show us your full source code if needed so that we can help you better.

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 29.08.2016 14:14
Hello,

I believe you will have to build the query parameter list by separating each value by comma (,) and not semi colons.

Try to build the list of IDs that you want like this:
1,2,4,5,7,89,909,...

Now assign this string to the Parameter and it should work!

HTH

Yogi Yang

von Yogi Yang - am 29.08.2016 14:18
Hi Yogi,

In fact it depends of the type and how you pass the parameters. Except I'm mistaken, it goes as follow:

If this is a string query, you must use comas as in your example:
- IN (1,2,3)
- IN ('a','b','c')

If this is a query from the editor, you use semi-colons:
- qry.Param1 = "1;2;3"
- qry.Param1 = "'a';'b';'c'"

Best regards,
Alexandre Leclerc

von Alexandre Leclerc - am 29.08.2016 14:29
Thanks Alexandre Leclerc, Yogi Yang.

Now this works fine. It's my mistake, in assigning the values. The way mentioned by Fabrice Harari is working fine.

Thanks again.

Happiness Always
BKR Sivaprakash

von Sivaprakash - am 30.08.2016 06:48
Haven't read the thread completely, but this should do the trick:

MyQuery.MyInListParameter = Arraystostring(YourStringArrayVariable,";")

Cheers,

Peter Holemans

von Peter Holemans - am 30.08.2016 09:50
Thanks Peter Holemans, it's working now.

von Sivaprakash - am 30.08.2016 10:28
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.