I'm using Scriptella for database migration.
What would be the best approach to copy a longblob field from table A to table B ?
When I do this job like this:
<query ...
SELECT FL_DATA as data FROM A where FL_DATA IS NOT NULL
<script ...>
INSERT B (FL_DATA) VALUES ('$data');
</script>
</query>
then it will just write 'BLOB: java.io.IOException: Content too long to fit in memory' into the destination field (btw: the size of the longblob is just a few kBytes).
When $variable syntax is used, a text value of the variable is simply inserted into statement's text. A recommended approach would be to use prepared statements syntax. In this case values will be transferred separately from the SQL statement. Please try the following:
<query ...
SELECT FL_DATA as data FROM A where FL_DATA IS NOT NULL
<script ...>
INSERT B (FL_DATA) VALUES (?data);
</script>
</query>
Sorry, this is not a answer, but I don't how to comment ejboy's answer.
Ejboy, it doesn't work for me. I've tried prepared statement with (in my case) ?description and ?2. The same error I get when I try to show the content on the console:
<query connection-id="database">
SELECT id, description FROM table;
<script connection-id="copy_database">
INSERT INTO table VALUES (?1, ?2);
</script>
<script connection-id="text">
$id, $description
</script>
</query>
I get the same error for both, for showing and inserting (here example for showing):
BRA0735401, CLOB: java.io.IOException: Content too long to fit in memory
My main task to make a copy from one database to another. Like in Jan's case the blob/clob content is about 40 kB (a list of key/value, each in the separate line, from database point of view this is MySQL MEDIUMTEXT).I know, that is possible to insert a blob/clob from a file (scriptella example with mp3 files), and it's possible to write content of a blob to a file (scriptella example with odbc and pictures with janino), so I will to try to use a solution with a temporary file, but it's not a beautiful solution. Am I right?
Is there any simpler solution?
Regards,
Jacek
Related
I have a requirement in which the input XML that is received has different error description for the same error code. I need to compare whether a part of the text is contained within the error description in order to do some filtering. Below is the snippet of what I am trying to do.
Created a variable to store a list of all the partial text to be checked within the error description.
<xsl:variable name="partialTextList">
<errorDesc value="insufficient funds" />
<errorDesc value="amount cannot exceed" />
</xsl:variable>
Created a key to access the variable
<xsl:key name="kErrorDesc" match="errorDesc" use="#value" />
The input XML to this XSL will have something like
<Error>
<Code>123</Code>
<Desc>Transaction cannot be processed as account has insufficient funds.</Desc>
</Error>
OR
<Error>
<Code>123</Code>
<Desc>The withdrawal amount cannot exceed account balance.</Desc>
</Error>
Is it possible to use contains function to check whether <Desc> has one of the values from partialTextList?
I tried to look up a solution for this comparison but was not able to find one. Most of the solutions are to check whether <Desc> value is present in the list but not vice-versa.
Any help is appreciated.
In the context of e.g. xsl:template match="Error" you can certainly check $partialTextList/errorDesc/#value[contains(current()/Desc, .)] or move it to the pattern xsl:template match="Error[$partialTextList/errorDesc/#value[contains(current()/Desc, .)]]" if you like.
I tried to parse SEC company filings from sec.gov. Starting from fb 10-Q index.htm let's look at a complete text submission filing like complete submission text filing. It has a structure like:
<SEC-DOCUMENT>
<SEC-HEADER>
<ACCEPTANCE-DATETIME>"some content" This tag is not closed.
"some lines resembling yaml markup"
These are indented lines with a
"key": "value" structure.
</SEC-HEADER>
<DOCUMENT>
.
.
some content
.
.
</DOCUMENT>
"several DOCUMENT tags" ...
</SEC-DOCUMENT>
I tried to figure out the structure of the <SEC-HEADER> tag and found some information under Public Dissemination
Service (PDS) Technical
Specification (pdf) and concluded that the content of the header should be SGML.
Nevertheless, I am clueless about the formatting, since there are no angle brackets, and the keys - value paires are separated by colons like key: value instead of <key>value</key>. In the pdf link I could not find anything about colons.
Question: Is the <SEC-HEADER> tag valid SGML? If it is, how to parse it?
I'd be glad at any help.
The short answer is no. The <SEC-HEADER> tag in the raw filing is not a valid SGML.
However, it is my understanding that this section in the raw filing is parsed automatically from the header file <accession_num>.hdr.sgml, which does follow SGML. This header file can be found in the same directory as the raw filing (i.e., the <accession_num>.txt file).
I use a REGEX of the form: ^<(.+?)>(.+?)$ (with re.MULTILINE option) to capture each (tag, value) tuple and get the results directly in a dict().
I believe the only tag in that file that has a closing tag is the </FILER> tag, where there could be multiple filers in each filing. You can first extract those using a REGEX of the form: <FILER>(.+?)</FILER> and then employ the same REGEX as above to get the inner tags for each filer.
Note that other than 'FILER', there could be other tags, representing different relations of the entities to the filing. Those are 'ISSUER', 'SUBJECT COMPANY', 'FILED BY', 'FILED FOR', 'SERIAL COMPANY', 'REPORTING OWNER'.
I uploaded .doc to smashworld, and got the warning while validating the .epub
ERROR toc.ncx 15 43 Error while parsing file 'different playOrder values for navPoint/navTarget/pageTarget that refer to same target'.
ERROR toc.ncx 15 265 Error while parsing file 'different playOrder values for navPoint/navTarget/pageTarget that refer to same target'.
And here is part of the codes.
Shan Hai Legend Vol.1, [Part 1of2]Midpoint
I have no idea..how it can be fixed. Can anybody help me out?
As you probably know a ePub file is like an archive of files. It contains the textual files (usually .xhtml, .html), the stylesheet files (usually .css), the images used in the book and the configuration files. Your toc.ncx (The file that contains the index order and structure) has 2 or more items with the same playOrder or is corrupted.
The playOrder property specifies the actual position of the Chapter in the index.
If you use playOrder="1" with chapter 1 and playOrder="1" with chapter 2, the ePub reader doesn't know what to put first.
I suggest you to download Calibre, import your ePub, check for errors, and open the toc.ncx to see its structure.
You will get something like that:
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="it">
<head>
<meta content="...." name="...."/>
</head>
<docTitle>
<text>Book Title</text>
</docTitle>
<navMap>
<navPoint id="num_1" playOrder="1">
<navLabel>
<text>Chapter 1: some title</text>
</navLabel>
<content src="chapter-01.html"/>
</navPoint>
<navPoint id="num_2" playOrder="2">
<navLabel>
<text>Chapter 2: some title</text>
</navLabel>
<content src="chapter-02.html"/>
</navPoint>
</navMap>
</ncx>
Just check if every playOrder is incremented by 1 for each navpoint.
If you find the error, manually insert the correct values, save and export the eBook.
If you don't know how to fix it, post here the toc file and we will try to understand the mistake :)
I am using D10 Pro. I added a datamodule to the object repository by right clicking it and selecting "Add to Repository" on the popup menu.
The datamodule shows up in the New>Other dialog and I am able to click the icon for it. When I do, I get the following exception: "Unable to find both a form () and source file (). The same exception occurs with forms I place there. The object that came with Delphi load without any problem. How do I fix this?
When adding items to the repository, you should avoid using dotnet style names for your files. For example, I originally named the file "MyLib.Datamodule.TextImporter.pas" and I received the error in my question. I experienced the same problem with a form using the same dotnet style naming. After changing the file name to "TextImporterDatamodule.pas" and adding it to the repository, I was able to use it to create new datamodules without a problem. This is something Embarcadero needs to address.
I can't answer your q, but maybe this will help you track down your problem.
Contrary to what the DocWiki says for Seattle, the repository .Xml file is actually named "Repository.Xml" and in my case is located here:
C:\Users\MA\AppData\Roaming\Embarcadero\BDS\17.0\Repository.Xml
I added a data module to it, resulting in the entry shown below being added.
Notice that for a datamodule, the path to it is stored in its IDString
attribute along with the filename, unlike a form, where the path+name is stored
in the the Value attribute of the FormName node.
With that entry in place, unlike you I can then include a copy of it in a project
by going to File | New | Other in the IDE. However, if I then change the
on-disk name of the folder where the item is located, and try to use it, I get the error
message you quoted. Of course, that doesn't mean that's why you're getting
it, but I thought it might help to see the repository entry for something that's known to work.
<Item IDString="D:\Delphi\Code\SO\Devex\DM1" CreatorIDString="BorlandDelphiRepositoryCreator">
<Name Value="AAADataModule"/>
<Icon Value=""/>
<Description Value="MA datamodule"/>
<Author Value="MA"/>
<Personality Value="Delphi.Personality"/>
<Platforms Value=""/>
<Frameworks Value=""/>
<Identities Value="RADSTUDIO"/>
<Categories>
<Category Value="InternalRepositoryCategory.MyCategory" Parent="Borland.Delphi.NewFiles">MyCategory</Category>
<Category Value="Borland.Delphi.NewFiles" Parent="Borland.Delphi.New">Delphi Files</Category>
<Category Value="Borland.Delphi.New" Parent="Borland.Root">Delphi Projects</Category>
</Categories>
<Type Value="FormTemplate"/>
<Ancestor Value=""/>
<FormName Value=""/>
<Designer Value="Any"/>
</Item>
If this doesn't help, best I can suggest is to post your q in the IDE section
of EMBA's newsgroups here:
https://forums.embarcadero.com/forum.jspa?forumID=62
I don't think that should provoke cross-posting complaints, seeing as your q has been up here for a while without getting a definitive answer.
I'm making a reusable package and in order to get the client side to work both with straight javascript and module loaders I have a code paths that requires me to document.write out script tags.
In my razor view I have something like this:
<script>
...
document.write([
'<script type="text/javascript" src="~/Oaf/SlimHeader/Media/Scripts/jquery-1.9.1.min.js"></script>',
'<script type="text/javascript" src="~/Oaf/SlimHeader/Media/Scripts/jquery-migrate-1.2.1.min.js"></script>',
].join('\n'))
...
</script>
Which Razor refuses to interpret in html mode:
Parser Error Message: Unterminated string literal. Strings that start
with a quotation mark (") must be terminated before the end of the
line. However, strings that start with # and a quotation mark (#")
can span multiple lines.
indicating the error is in the first script tag. This is javascript, I don't want Razor involved at all! (Ok, it would be nice if it parsed the ~ but honestly I can take care of that myself).
I've tried prefixing every line with #: and surrounding the whole thing in #" ... "# but neither seems to work.
This is not a razor issue, this code is invalid even in a simple HTML file, and will cause problems in the browser.
The solution is to:
var a = '<script><' +' /script>';
The bug has been closed as by design.
Thanks to Aron who got me to pare this down thereby prompting me to discover the answer.
Pared down the broken code looked like this (I hadn't included the if in the question):
#if (true) {
<script type="text/javascript">
var a = '<script></script>';
</script>
}
something in the interplay between the #if and the <script> tag in a sting just does not sit well. If I force text mode on each line inside the if by prefixing with #: then it works.
In the original question the solution it to prefix every line inside the Razor block with #:. Surrounding in a <text> block will not work. If you don't prefix every line with #: then you will get a parsing error very possibly for a line that was prefixed.
Seems like a bug with Razor. Will report it.