I have a stream with multiple attributes. Lets assume name of the stream is "MyStream" and it is imported to the execution plan as "my". Names of attributes are "A" and "B". "B" attribute can have NULL values. I want to select Both "A" and "B" where "B" is NULL. I try Bellow code.
FROM my[B is null]
SELECT A as A,B as B
INSERT INTO out;
But the "out" stream is always empty. "B"s data type is FLOAT. What is the problem in my code?
I try bellow code and it worked for me.
FROM my
SELECT A as A,
ifThenElse(B is null,convert(0.1,'FOLAT'),B) as B
INSERT INTO out;
Related
I have this sparql query that I need to modify. I have the example instance, which has the exampleID 12345. For this case, if the :hasRelatedExample connection exists, the ?test variable will become 2. If the :hasRelatedExample connection doesn't exist from the example instance, the ?test variable doesn't get assigned the 1 value as it should. How could I fix this query to reflect the needed behavior?
PREFIX : <http://www.example.com#>
Select distinct ?test
where
{
?ex a :Example ;
:exampleID "12345" ;
:hasRelatedExample ?relatedExample .
BIND (IF(BOUND(?relatedExample),2,1) as ?test)
}
I am trying to display the content of a file, split by a delimiter character.
More exactly, starting from this topic, I am trying to display the result as:
bbb
aaa
qqq
ccc
but the data source to be taken from a file.
Until now, I tried:
DECLARE
l_bfile bfile;
BEGIN
l_bfile := bfilename(my_dir, my_file);
dbms_lob.fileopen(l_bfile);
FOR i IN
(SELECT TRIM(regexp_substr(TO_CHAR(l_bfile),'[^;]+',1,level) ) AS q
FROM dual
CONNECT BY regexp_substr(TO_CHAR(l_bfile),'[^;]+',1,level) IS NOT NULL
ORDER BY level
)
LOOP
dbms_output.put_line(i.q);
END LOOP;
EXCEPTION
WHEN No_Data_Found THEN
NULL;
END;
As result, I got
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got FILE
Can anyone give me a hint, please?
Have to write this as a new answer since this is too big for a comment to #SmartDumb:
Be advised the regex of the form '[^;]+' (commonly used for parsing delimited lists) fails when NULL elements are found in the list. Please see this post for more information: https://stackoverflow.com/a/31464699/2543416
Instead please use this form of the call to regexp_substr (note I removed the second element):
SELECT TRIM(regexp_substr('bbb;;qqq;ccc','(.*?)(;|$)',1,level, null, 1) ) AS q
FROM dual
CONNECT BY regexp_substr('bbb;;qqq;ccc','(.*?)(;|$)',1,level) IS NOT NULL
ORDER BY level
It may or may not be important in this example, it depends on if the order of the element in the string has importance to you or if you need to preserve the NULL. i.e. if you need to know the second element is NULL then this will work.
P.S. Do a search for external tables and see if that is a solution you could use. That would let you query a file as if it were a table.
You could possible try this if your file contains single line (hence the question about file structure):
DECLARE
utlFileHandle UTL_FILE.FILE_TYPE;
vLine varchar2(100);
BEGIN
utlFileHande := UTL_FILE.FOPEN(my_dir, my_file, 'r');
utl_file.get_line(utlFileHande, vLine);
FOR i IN
(SELECT TRIM(regexp_substr(vLine,'[^;]+',1,level) ) AS q
FROM dual
CONNECT BY regexp_substr(vLine,'[^;]+',1,level) IS NOT NULL
ORDER BY level
)
LOOP
dbms_output.put_line(i.q);
END LOOP;
utl_file.fclose(utlFileHande);
EXCEPTION
WHEN No_Data_Found THEN
utl_file.fclose(utlFileHande);
null;
END;
added a suspension list to a powerapps projects, trying to add items editing "Items" property with: ["12","24","36"] but receiving a error: expecting "bracketclose" found "error" and the first item, "12" is in a different color
Please check your locale. In an English locale your expression should work, but for example in a Latin locale then you should change , into ; so using this
["12";"24";"36"]
PS Also in Latin locales ; should be changed into ;;
I have a Pig script which returns output as tuples as shown below:
(1,2,3)
(a,b,c)
I am storing this output into a file and it gets stored with the parenthesis ( and ) as above. I would like to stored the records as below in the file:
1,2,3
a,b,c
How can I get rid of the parenthesis before using 'STORE INTO' in Pig?
DUMP will display the records in a tuple that's the reason why you are seeing 1,2,3 enclosed in parenthesis.()
Ref : http://chimera.labs.oreilly.com/books/1234000001811/ch05.html#pl_dump
Using STORE on the alias will save the values alone.
Ref : http://chimera.labs.oreilly.com/books/1234000001811/ch05.html#pl_store
Okay, so I just recently got into lua and find myself stuck with the following:
I have the function peripheral.getNames() (which is a custom function)
it will return a table with the structure key,value, whereas key is always a number and starts from 1 and value will be what the function finds (it searches for devices connected to it)
In my example it creates a table which looks like this
1 herp
2 derp
3 monitor_1
4 morederp
I can print the values with the following
local pgn = peripherals.getNames()
for key,value in pairs(pgn) do
setCursorPos(1,key)
write(value)
end
end
this will output the corresponding value of the table at key on my display like this
herp
derp
monitor_1
morederp
now, I try to filter my results so it only prints something if value contains 'monitor'
I tried to achive this with
for key,value in pairs(pgn) do
if string.match(value, monitor) then
#dostuff
end
end
but it always returns 'bad argument: string expected, got nil'
so obviously string.match either does not accept 'value' or, value is not a string
so i tried converting value first
for key,value in pairs(pgn) do
value = tostring(value)
if ....
#dostuff
end
end
but it still throws the same error
Do any of you have an idea how i might either get string.match to accept 'value' or if there is another method to check the contents of 'value' for a pattern while in this for loop?
The error message is talking about the variable monitor, which is not defined and so has a nil value.
Try string.match(value, "monitor").