Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

data Type "boolean "

Hello,

 

How to convert data type String with "true" to data type boolean with "1".

 

Thank you 

 

Best regards

Labels (3)
18 Replies
JR1
Creator III
Creator III

The error "cannot convert Boolean to String does not suggest that the input is of type Boolean. This error simply occurs because you passed a boolean value into the String method "equals" when you do the following

row2.licence_info_mutation_gratuite_confirmee.equals(true) ? "1" : "0" 

Please try the following (exactly as it is shown here):

row2.licence_info_mutation_gratuite_confirmee == null ? null : (row2.licence_info_mutation_gratuite_confirmee.equals("true") ? 1 : 0)

I am not sure what you mean with the target type is "boolean with bit(1)". If it is an Integer, the above should work. If it is a Boolean, the following should work:

row2.licence_info_mutation_gratuite_confirmee == null ? null : row2.licence_info_mutation_gratuite_confirmee.equals("true")
Anonymous
Not applicable
Author

Hello,

 

my target is boolean and source is String.

when i use this method :

row2.licence_info_mutation_gratuite_confirmee == null ? null : (row2.licence_info_mutation_gratuite_confirmee.equals(true) ? true : false)  

 

i have this error:

User variable name 'tDBOutputBulkExec_1_tMBE_licence_info_mutation_gratuite_confirmee' is illegal

Thanks

JR1
Creator III
Creator III

Hi

If you input is a string and the target is boolean, the expression has to be 

row2.licence_info_mutation_gratuite_confirmee == null ? null : row2.licence_info_mutation_gratuite_confirmee.equals("true")

Please note the double quotes around "true". Please replace "row2" with the name of your input flow.

As for your error: I do not know how your job (schemas and connections) is set up. In principle, I do not use underscores in column names (use camel case instead) and I try to avoid such long names for columns but I do not think this is the issue here. Nevertheless, I believe this has nothing to do with your original problem.

Anonymous
Not applicable
Author

Hi, 

I just tried your expression, still not working.

JR1
Creator III
Creator III

Sorry, but if you do not provide more details about your job, no one will be able help you with this.

Anonymous
Not applicable
Author

Hello,

 

my job is: 

0683p000009M6zL.png

 

My tconvertType 2:

0683p000009M6zQ.png:

 

mon tmap is:

0683p000009M6zV.png

My error is:

Exception in component tDBOutputBulkExec_1_tMBE (ODS_Collecte_Preparation_licence_info_1)
java.sql.SQLSyntaxErrorException: User variable name 'tDBOutputBulkExec_1_tMBE_licence_info_mutation_gratuite_confirmee' is illegal
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:781)
	at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:666)
	at ffh.ods_collecte_preparation_licence_info_1_0_1.ODS_Collecte_Preparation_licence_info_1.tDBInput_1Process(ODS_Collecte_Preparation_licence_info_1.java:6664)
	at ffh.ods_collecte_preparation_licence_info_1_0_1.ODS_Collecte_Preparation_licence_info_1.runJobInTOS(ODS_Collecte_Preparation_licence_info_1.java:9494)
	at ffh.ods_collecte_preparation_licence_info_1_0_1.ODS_Collecte_Preparation_licence_info_1.main(ODS_Collecte_Preparation_licence_info_1.java:9169)

thanks for your reply

 

JR1
Creator III
Creator III

OK, so you are already converting your input string to a Boolean in the tConvertType component. Why are you bothering with further conversion in the tMap? You already have a boolean value in the input of the tMap and simply need to pass it along to the output:

row2.licence_info_mutation_gratuite_confirmee

Please try this again with this expression. I still believe, the error has nothing to do with your original problem and originates from the DB output component.

Anonymous
Not applicable
Author

i have the same error:

 

Exception in component tDBOutputBulkExec_1_tMBE (ODS_Collecte_Preparation_licence_info_1)
java.sql.SQLSyntaxErrorException: User variable name 'tDBOutputBulkExec_1_tMBE_licence_info_mutation_gratuite_confirmee' is illegal
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:781)
	at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:666)
	at ffh.ods_collecte_preparation_licence_info_1_0_1.ODS_Collecte_Preparation_licence_info_1.tDBInput_1Process(ODS_Collecte_Preparation_licence_info_1.java:6659)
	at ffh.ods_collecte_preparation_licence_info_1_0_1.ODS_Collecte_Preparation_licence_info_1.runJobInTOS(ODS_Collecte_Preparation_licence_info_1.java:9489)
	at ffh.ods_collecte_preparation_licence_info_1_0_1.ODS_Collecte_Preparation_licence_info_1.main(ODS_Collecte_Preparation_licence_info_1.java:9164)
Mon Aug 19 10:24:58 CEST 2019 WARN:

thanks

JR1
Creator III
Creator III

Again, this is most likely unrelated to your original problem and lies in your output component. From the little I can see, the component cannot create a SQL statement for MySQL. Maybe the column name is too long for MySQL - I am not a MySQL expert.