PowerBuilder Find function throws an error "expression is not valid" - sql-server-2008

What is wrong with this code. I am checking whether there is an available record in the database before inserting a new serial number. When I enter any record whether available or not, it throws an error message:
"Expression is not valid". (PowerBuilder Classic 12.5 and SQL Server
2008)
If This.GetColumnName() = "serial_No" Then
long ll_serial
ll_serial=dw_newrecord.find(data, 1, dw_newrecord.rowcount())
if ll_serial>0 then
messagebox("validation error", "The record already exists")
return 1
end if
End If

It is likely that your data expression has a syntax error. It can be some misformed code -like missing quotes- or maybe that the column name is incorrect.
To help for tuning a filter or find expression, you can test it in the datawindow design screen via the Rows / filter menu.
A better solution for long-term coding design would be to integrate the Datawindow Debug Machine (made by a colleague of mine) to your project. It is a precious tool to prototype datawindow expressions for finding, filtering but also for dynamic objects creation / modification in a datawindow. And while correctly interfaced with a datawindow ancestor of your project, it can help with filters and find expression errors like here.
EDIT: As RealHowTo noticed, the tool has been updated. Here is the current latest version (but there is no updated demo screencast though).

Related

RTweet new lookup_users continued excess error

I was using R's RTweet lookup_users to successfully pull data on 6 IDs
test<-c("ID1","ID2","ID3","ID4","ID5","ID6")
detail_followers <- lookup_users(users=test,
parse=TRUE,
token=[bearer_token here],
retryonratelimit=TRUE,
verbose=TRUE)
Update: I created a loop so I could get more visibility on the run, which made it profoundly slow. This would be tolerable, except for two new problems. First, some lookup_user are missing the "profile_banner_url" variable. I built a function to check for this problem and insert a NULL value for those users missing it, further slowing the run.
Finally, many users in this set appear to be bots, as they are deleted within 24 hours of my having just pulled them from the API. The error provided from lookup_users is "Error: $ operator is invalid for atomic vectors". is.atomic eval is not useful, because the fault occurs when lookup_user is called. There are far too many of these fake/suspended/deleted users for manual prompts.
These may be issues with the new RTweet from GitHub.

There was an error compiling this function. Access 2013 Calculated field issue

I have a table with a field which is of a calculated type and contains the following expression:
IIf(IsNull([OrderValue]),[TotalPhaseLabourCost]-[DefaultOrderValue],[TotalPhaseLabourCost]-[OrderValue])
For some reason when I go to open the table in any view it throws the error:
"There was an error compiling this function.
The Visual Basic module contains a syntax error.
Check the code, and then recompile it."
However, I have this database currently open on two laptops, one works fine and the other has this issue. I have checked both db's refs and they also match up.
That's a bit vague, so I can only make guesses.
Try to compile the code as the error message says.
check if you have any function with the same name as your field
Try replacing IIf(IsNull([OrderValue]), by IIf([OrderValue] is Null,
You probably miss the leading equal sign:
=IIf(IsNull([OrderValue]),[TotalPhaseLabourCost]-[DefaultOrderValue],[TotalPhaseLabourCost]-[OrderValue])
Or you could use:
=[TotalPhaseLabourCost]-Nz([OrderValue],[DefaultOrderValue])
For me there was some problem with some fields (it showed an error message #NAME? in some of the fields (date, number) in the 'new' record).
For me it worked to close the table, right-click it and open in design view.
For each of the fields with problems, I choose the data type (that was already shown) again from the drop down menu (so, same data type!).
Save.
Then it didn't give the error messages anymore.

SSIS Errors for simple CSV Data Flow

Sorry to darken your day with my troubles, but SSIS has broken me! I am new to SSIS and I just seem to be misunderstanding it.
For background: I have a few versions of a basic package that includes a Foreach Loop container and a Data Flow with a few Derived Columns that imports CSV files into a SQL Server Staging table. It is very straightforward and does include an Execute SQL task and a File Move but those work fine. The issues are with the Foreach loop and the Data Flow.
I have one version of this package (let’s call it “A”) that seemed to be working fine. It would process multiple files in a folder, insert records into the staging table, properly execute the SQL Statements, and move the files to Archive. Everything seemed fine until I carefully QA’d the process. Turns out it was duplicating the data from one file, and never importing the data from a second Source File! Yet, the second/dupe round of data included the Source Filename (via a derived column) of the second file (but the data from the first). So it looked like I had successfully processed BOTH files until I looked at the actual data and saw that none of the values from the second source file were ever written to the Staging table.
Once I discovered this, I figured that the problem was in the Foreach loop and how I setup the different file path & name variables. So, I decided to try to make a new version of the package. I started by copying package A and created package B. In B, I deleted the Source Connection manager and created a new Connection Manager along with all new file & path variables. I then tried to cleanup/fix/replace various elements in my Data Flow and Foreach loop. In the process, I discovered that the Advanced Mappings from A – which DID work – were virtually all setup as String (even the Currency and Date columns). That did not seem right, so I modified each source money column by changing to data type Currency, and changed each date-related column to data type Date.
What followed has been dozens and dozens of Errors and I cannot get Package B to run. I have even changed all of the B data types back to String (mirroring the setup in Package A which DID work). But, still no joy.
This leads me to ask a few questions to those of you smarter than I:
1) Why can’t SSIS interpret Source CSV data using the proper data type? I.e. why do I need to set every Input column as a STRING when some columns are clearly & completely Numeric, Currency or Dates? (Yes, the Source CSV files are VERY clean – most don’t even have NULLS)
a. When I do change the Advanced mapping for a date-related Source column to Date, I get the ever present error message: [Flat File Source [30]] Error: Data conversion failed. The data conversion for column "Settle Date" returned status value 2 and status text "The value could not be converted because of a potential loss of data.".
2) When I reset the data types back to String in package B, I still get errors – usually Truncation errors (and Yes – I have adjusted the length to 250 in one of these columns).
a. Error Message: "The value could not be converted because of a potential loss of data.".
b. When I reset the Mappings to ignore the column (as a test), it throws a similar error at the next column.
3) Any ideas why Package A would dupe a file’s data and not process the second file, yet throw no errors and move both to Archive?
4) Why does the Data Viewer appear to have parsing errors (it shows data in the wrong columns) but when you use the Copy data feature in the data viewer and paste it into Excel, all of the data lines up perfectly?
5) Are there any tips & tricks that a rookie SSIS user needs to understand and which might not be apparent through the documentation and searching web articles as well as this site?
I can provide further details if they will help, but these packages are really very simple and should not be causing me this much frustration.
THANKS for any insights.
DGP
Wow seems like you have a lot of ssis issues... I think the reason for the same file being extracted is because of the the way your 'variable mappings' is defined.
Have you had a look and followed this guide:
https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/
Hope this helps.
Shaheen
Thanks Tab & Shaheen,
To all SSIS rookies - please learn from my mistakes!
It appears that my issue was actually in how I identified the TEXT QUALIFIER in the Connection Manager. I had entered "" and that was causing problems with how my columns were being parsed. The parsing issues caused unexpected values to appear in some of the columns and that was causing the errors in the package.
When I tried changing the the Text Qualifier to only ONE double quote - " - the whole thing worked!
As I mentioned - and as Shaheen suspected - my initial issues with the duplicate processing was probably due to how I setup the foreach loop. I had already fixed that, bit was still getting errors until I fixed the Text Qualifier.
I have only tested it a few times but it looks like that was the issue.
Thanks for the contributions.
DGP

What are the non-obvious causes of a data type mismatch while loading data in an SSIS package?

I'm very new to SSIS, so please bear with me. A developer gave me a SSIS package and asked me to create a scheduled job on our database server to run it. He says it runs on his development box but I'm seeing the job fail with the following data type mismatch error:
0xC020837F The data type of column "output column 'col1' does not match the data type "System.Byte[]" of the source column 'col1'"
I opened the package in Visual Studio, and in the Input and Output Properties of the item, it shows both the External Column and Output Column as being of data type database timestamp [DT_DBTIMESTAMP]. I checked the source column on the server and verified that it is a datetime column. Are there any other reasons this error could be thrown?
This looks like your source table definition is not the same on development and production environment. Since You didn't provide enough details about what kind of source component and what connection manager You use and what is your source query (maybe You CAST or CONVERT some data), we have to make some assumptions.
As stated in SSIS Error and Message Reference, error code 0xC020837F (-1071611009) has name DTS_E_ADOSRCDATATYPEMISMATCH and description:
The data type of "" does not match the data type "" of the source
column "__".
From error name (DTS_E_ADOSRCDATATYPEMISMATCH) and error message part "System.Byte[]" I conclude that You are probably using ADO NET Source source component.
For a start check following: open properties of source component, uncheck particular column and check it again - this forces source component to refresh external and output - this trick works for oledb source it might help You also
If that doesn't help, check following links to see if some of your source data types map to System.Byte:
Integration Services Data Types
SQL Server Data Types Mappings (ADO.NET)
Working with Data Types in the Data Flow
Probably, on either development or production environment, column is of timestamp, image, varbinary or some other type that maps to managed System.Byte[] but on the other it is not. Please recheck source tables definitions.
If this answer doesn't help You, please post create statements for your source tables as well as source query itself.

Linq 2 SQL on shared host

I recently ran into an issue with linq on a shared host.
The host is Shared Intellect and they support v3.5 of the framework. However, I am uncertain to whether they have SP1 installed. My suspicion is that they do not.
I have a simple News table that has the following structure:
NewsID uniqueidentifier
Title nvarchar(250)
Introduction nvarchar(1000)
Article ntext
DateEntered datetime (default getdate())
IsPublic bit (default true)
My goal is to display the 3 most recent records from this table. I initially went the D&D method (I know, I know) and created a linq data-source and was unable to find a way to limit the results the way I desired, so I removed that and wrote the following:
var dc = new NewsDataContext();
var news = from a in dc.News
where a.IsPublic == true
orderby a.DateEntered descending
select new { a.NewsID, a.Introduction };
lstNews.DataSource = news.Take(3);
lstNews.DataBind();
This worked perfectly on my local machine.
However, when I uploaded everything to the shared host, I recieved the following error:
.Read_<>f__AnonymousType0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1<System.Data.SqlClient.SqlDataReader>)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MethodAccessException:
.Read_<>f__AnonymousType0`2
(System.Data.Linq.SqlClient.Implementation.ObjectMaterializer`1<System.Data.SqlClient.SqlDataReader>)
I tried to search the error on Google, but met with no success. I then tried to modify my query in every way I could imagine, removing various combinations of the where/orderby parameters as well as limiting my query to a single column and even removing the Take command.
My Question therefore comes in 3 parts:
Has anyone else encountered this and if so, is there a "quick" fix?
Is there a way to use the datasource to limit the rows?
Is there some way to determine what version of the framework the shared host is running short of emailing them directly (which I have done and am awaiting an answer)
System.MethodAccessException is thrown by the framework when it is missing an assembly, or one of the references are of the wrong version.
The first thing I would do is try uploading and referencing your code to the LINQ assemblies in your BIN, instead of the shared hosting providers GAC.