How to get char element LIKE Array in sql? - macros

i need your help how to getting char element LIKE Array in SQL.
This is my program :
Char code[5]
ex. code = "LA 12"
result = RecipeQuery("SELECT * FROM Recipe WHERE Name_Recipe LIKE '%(code)%';", n_records)
And it doesnt work.
value of result is nothing.
Any idea?
Thank guys.

I don't know what language you use, but I think you need to get a form like this:
SELECT * FROM Recipe WHERE Name_Recipe ARRAY[Name_Recipe] <# ARRAY["L","A"," ","1","2"]
You can see this link : https://www.postgresql.org/docs/current/functions-array.html

Related

Can eval function be used in concatenating a string and an integer?

I need to know if i am providing a=3 and b=kite then the output should 3kite but it is showing an error, plz help me through this...
a=eval(input("enter a number:"))
b=eval(input("enter second data:"))
c=(a+b)
print("the result is:",c)

reading cell array using jmatio

I am attempting to read from a matlab cell array of strings using the java library jmatio
This is my code
MatFileReader matreader=new MatFileReader ("filepath");
MLarray array= matreader.getMLArray ("cellData").contentToString ());
If I print out array I get an out put that shows me an array with the correct dimensions but in place of the cell elements it tells me the size of the character array in the cell. For example if the first cell contained a string of 5 characters it would show the following
[1×5 char array]
The information is correct but I would like to access the actual information of the cell.
When I used MLCell as in the following I only get the dimensions of the array itself .
Int [] dims = matreader.getMLArray.getDimensions ();
MLCell cellarr=new MLCell("celldata", dims);
Does anyone know the correct usage.
Thank you in advance.
You have to use the get-Function to get an element from the MLCell.

Progress OpenEdge - TempTable to file - an easy way?

I would like an really easy way to see the content in any temptable in Progress?
You could also for instance produce XML
tthTmp:WRITE-XML("FILE","c:\temp\tt.xml", TRUE).
or (maybe not quite as easy) output as a semi colon delimited file
OUTPUT TO c:\temp\file.txt.
FOR EACH ttTmp:
EXPORT DELIMITER ";" ttTmp.
END.
OUTPUT CLOSE.
I just found out an easy way to dump a temp-table to file using Json (from 10.2B).
WRITE-JSON is the trick!!
DEFINE TEMP-TABLE ttTmp
FIELD FieldA AS CHAR
FIELD FieldB AS CHAR.
CREATE ttTmp.
ASSIGN ttTmp.FieldA = "A"
ttTmp.FieldB = "B".
DEFINE VARIABLE tthTmp AS HANDLE NO-UNDO. /* Handle to temptable */
DEFINE VARIABLE lReturnValue AS LOGICAL NO-UNDO.
tthTmp = TEMP-TABLE ttTmp:HANDLE.
lReturnValue = tthTmp:WRITE-JSON("FILE", "c:\temp\tthTmp.txt", TRUE, ?).
/* Output File tthTmp.txt
{"ttTmp": [
{
"FieldA": "A",
"FieldB": "B"
}
]}
Output File tthTmp.txt */

Powershell - Capture text in a var from a specific character

I want to grab the first char of a var string and the first char of the following caracter
Example:
$var1 = "Jean-Martin"
I want a way to grab the first letter "J" then I want to take the first char following the "-" (dash) which is "M".
Something like this?
$initial1 = $var1[0]
$initial2 = $var1.Split('-')[1][0]
Strings in Powershell use the System.String class from the .Net framework. As such, they are indexable to retrieve individual characters and have many methods available such as the Split method used above.
See the documentation here.
$var1 = "Jean-Martin"
To get the first character:
$var1[0]
To get the first character after the dash:
$characterToSeek = '-'
$var1[$var1.IndexOf($characterToSeek)+1]
Another option using regex:
PS> $var1 -replace '^(.)[^-]+-(.).+$','$1$2'
JM

Regex to grab a number from within a string

I would like to grab a number from a string.
The string is: "responseID: 1 is the return value";
Sometimes the number could be 1, or 3, 300, 3000...
I am trying to do this in objective C for the iphone.
I've tried NSPredicate and NSRegularExpression, but I can not seem to get the right regex to start with.
I tried "*[0-9]+*";
Does this return the "1" , "300" or whatever number to me when I call the regex?
Thank you!
\d+ should match 1 or more digits.
Sorry, I was able to search again and found exactly what I was looking for: see this:
Objective C: How to grab a number after a sub string from string