Slider

Q:
In a custom section, I would like to show the tick marks.
Slider1.??
A:
Lianja 3.1Beta7 I have exposed these:
tickInterval: number
tickPosition: string // None, Above, Below, Left, Right, BothSides


Advertisements

String

Q:
can I use more than one “like” clause in filter?
this, not work..
set filter to des_banca like “*UNI*” and PROVFINAN like ‘MO’
A:
You can use == as an alternative to LIKE.
A2:
The == operator in Lianja works the same as exactly equal to when it does not contain patter matching characters.
If it does contain pattern matching characters then a pattern match is performed.
The patterns can be %*?[a-z][~a-z]



String

Q:
Displayed as XX | XXXXXXXXXXX.
Is there a way to only get a value from a specific column?
For example, how do I get the value from column 2?
A:
Extract the part of the value you need, e.g. from after the ‘|’ to the end of the string:
strextract(this.text,’|’)


I have also extended the database engine with SET STRCOMPARE ON.
This causes strings to be compared case insensitive and EXACT comparisons. The strings are padded with spaces up to the maximum length of either string. This resolves the issue of SQL returning multiple rows when looking up a substring of a column value. This behavior is like MSSQL now. You should only set it on when you want this behavior as it affects all string comparisons so:
“hello” = “HELLO”
will be true if STRCOMPARE is ON
.

Index key comparisons are case insensitive too now so the optimizer will handle mixed case comparisons.

One thing worth mentioning also is that in Lianja the
== operator behaves like EXACT only when the left hand side operand and the right hand side operand of the same length
otherwise == is a “pattern matching” operator. e.g.
select * from customers where customerid==”A*”
Will return all customers that start with “A”.

The pattern matching
operators _ * ? % [chars] and ^[chars] can be specified in the pattern.

Also remember that you can also
SET SOFTSEEK ON to progressively lookup a key by chopping characters off the end until a match is found.


In Lianja scripting, Javascript, PHP, Python, C, C++, Java, etc comparing strings is case sensitive.
If you are storing data then that’s up to your App to make sure it goes in in the correct case particularly when indexes are being updated or populated.

“hello” != “HELLO”

So fix up your data and use input masks to guarantee what is typed in by a user is correctly transformed before it is stored in a database.



 

Stored procedure

You can pass parameters to your stored procedure, e.g. nret = sqlexec(nhand,”call sp_demo(‘MA’)”,”mycursor”)


Currently, the ‘.prg’ needs to be present for stored procedures. This will be resolved in a future release, so that only the ‘.dbo


Lianja SQL Server lets you call stored procedures (or in fact just procedures) that use SEEK/SCAN/etc NoSQL commands inside them.

Server-side pages (
.rsp pages written in VFP compatible scripting) provide the same level of functionality in the cloud.
Best of both worlds NoSQL and SQL.


Q:
I created a stored procedure in “southwind” database through Lianja App builder. I named is as
sp_GetOrderDetails.prg
=======================
select * from order_details into cursor cc

I can run this in console and can browse cc cursor.
How can I call this or any other stored procedure from “Lianja Sql Server” to VFP ?
A:
call sp_name()
to to get multiple result sets issue two sqlexec() calls.


Q:
In VFP, a Databsae file (.DBC), saved all sotred procedures in field named as ‘code‘.
We can
edit any procedure with ‘modify procedure.
Can we have multiple stored procedures in a single sp_library.prg file ?
A:
You edit stored procedures in the “Data” workspace for the database table.

No. Lianja will look for the stored procedure by filename in the database container directory.



SQLlookup

Q:
I am currently working on a web app where I need to perform some server side data retrieval.

While referencing SQLLOOKUP, when the virtual table is used, the return value is the customer id.

Is it possible to have multiple returned values?
For example, can the return value be customerid and employeeid.

If it is not possible, other than calling SQLLOOKUP() several times, what would be the best way to use the same functionality with virtual tables?
I am trying to make a call to a virtual table that returns two columns from a table.
I would then taken the values, place them in a JSON string format and return the encoded object to the client.

I am currently using two sqllookup calls and I’m trying to make it easier with one single call.

Code:
m_defbranch = sqllookup("vtsecure","where loginname = '" + m_username + "'", "","defbranch","'Not found'")

m_colcode = sqllookup("vtsecure","where loginname = '" + m_username + "'", "","collcode","'Not found'")

I am storing each of the values in the caption of a label in a canvas section for other uses (which will not be visible to the user).
A:
The easiest nocode way I can think of: put a canvas section on the page that is invisible.
Put
two textboxes on the section set to the two fields you want to use.
Set the
datasource to be a VT which will give you the values you want.

When you need to requery() (here’s another place where having all the details would make a difference), set the WHERE attribute of the section..
I’m not sure if it will
requery itself, or where you will then have to requery the section. One way or the other, your two values will be available for you to use as you need.



SQLlookup

Q:
Why is a wrong field shown in column “groep”.
choices: SELECT omschrijving FROM groep WHERE bedrijf = 234 AND periode = 2015
Get data mapping : sqllookup(“groep”,”where bedrijf = 234 AND periode = 2015 AND groep = ‘{}'”, “”,”omschrijving”,”0″)
Swt data mapping : sqllookup(“groep”,”where bedrijf = 234 AND periode = 2015 AND omschrijving = ‘{}'”, “”,”groep”,”0″)
A:
What are the datatypes of groep and omschrijving?
If they are character, the final parameter (notfound) in SQLLOOKUP() should be in quotes within quotes “‘0′”



 

ShowDocument

Incredibly powerful, but possibly less well know, is the showdocument() function and the corresponding Lianja.showDocument() method.
Here are some of the operations you can do with showdocument() and Lianja.showDocument():

  • Switch to another App
  • Switch to another Page
  • Navigate records: First, Previous, Next, Last, move relative, goto record number
  • Initiate data operations: Add, Edit, Delete
  • Search and filter data
  • Refresh ‘Visible when’ and ‘Readonly when’ Rules at Section or Page level
  • Change or reset UI States
  • Navigate to the previous or next Page
  • Hide or show the left and right Sidebars
  • Hide or show the Navigation Panel
  • Expand and collapse Sections
  • Select a particular Section in an accordion Page
  • Select a particular Tab in a TabView Section
  • Dynamically change Virtual Table queries

 


Q:
Is there an advantage to using Lianja.showDocument() method other than the ability to chain commands in a single call (which is very nice)? IOW, can all the same actions/settings be accessed using Lianja.get()? I ask because I seem to remember at one point that some things could only be done using showDocument.
A:
There are certainly some that are showdocument only – the hide/show of the navigation panel and sidebars and the UI States spring to mind.
Others are standard
section or pagemethods and will be calling the same code behind the scenes.


there should be only one colon, if used, following the first name: that tells the Get method of Lianja which part of the hierarchy to start searching.

So if section1 is on pgCreateTasks, your parameter to showDocument would be as below. Note that if you are starting at page level, the page: isn’t needed.

Code:
Lianja.showDocument("page: pgCreateTasks.section1?action=add");

 


Unlike Lianja.getElementByID(), Lianja.showDocument() needs to have a prefix of “section:” so that the specified action is performed against the section.


Q:
When using showdocument in a web browser, I can do a search on a section as follows.

Code:
Lianja.showDocument("page: page1.section3?action=search&text=King");

This will search on my search field (which is lastname) for King.
If I wanted to filter a section, what is the correct syntax?
This is clearly not correct.

Code:
Lianja.showDocument("page: page1.section3?action=filter&text=lastname = 'King'");

A:
From the new treeview app .js file:

Code:
function page1_section1_dblclick(title, key)
{
    Lianja.showDocument("page: page1.section4?action=search&text="+key);    
};
Code:
Lianja.getElementByID("page1.section4").refresh();

here is the OData syntax.

Code:
Lianja.showDocument("section:section2?action=filte r&text=contactname eq 'Jean Fresniere'"); 
Lianja.showDocument("section:section2?action=filte r&text=contactname eq ''");