Subscribe Bookmark RSS Feed

modify SQL by list selection

mkennke

Community Trekker

Joined:

Mar 18, 2016

Hi,

how can I change a SQL by a selection of a list?

In my Example I select in a Combo Box the Line ({"AL1", "AL2", "AL3", "FTA", "FTB", "FTC"}) and then I like to change my SQL with my selction. Currently I have "WHERE   (t1.tag LIKE  '%AL2%' ) ". And that works. But I like to substitute "AL2" regarding my selection.

Can anybody help me?

 

a = {"AL1", "AL2", "AL3", "FTA", "FTB", "FTC"};
New Window( "Line",
    <<Modal,
    H List Box(
        Panel Box( "Select a Line:",
            cb1 = Combo Box(
				a,
                <<SetFunction(
                    Function( {this},
                        selection = this << Get Selected();
            )
        ),
    )

)));

show (selection);


New SQL Query(
	Version( 130 ),
	Connection(
		"ODBC:DRIVER"
	),
	QueryName( "pisnapshot" ),
	CustomSQL(
		"SELECT t1.tag 
FROM   pisnapshot  t1 
WHERE  (  (  (  (t1.tag LIKE  '%AL2%' )  )  )  )"
	),
	PostQueryScript(
		"dt = Current Data table ();

TagList = Column (dt, 1) << Get Values"
	)
) << run foreground;
1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

Try 'Help > Scripting INdex' then search for 'Eval Insert'.

2 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

Solution

Try 'Help > Scripting INdex' then search for 'Eval Insert'.

mkennke

Community Trekker

Joined:

Mar 18, 2016

here the code I used

	CustomSQL(Eval Insert(
		"SELECT t1.tag 
FROM   pisnapshot  t1 
WHERE  (  (  (  (t1.tag LIKE  '%^selection^%' )  )  )  )"
	)),