Monday, July 30, 2012

Peoplecode: Writing to file using Write Rowset


Local File &myFile;
Local Rowset &fileRowset1, &fileRowset;
Local Row &fileRow;

&myFile = GetFile("c:\temp\test.txt", "W", %FilePath_Absolute);

If &myFile.SetFileLayout(FileLayout.TEST_FILE_LAYOUT) Then
   &fileRowset = &myFile.CreateRowset();
   &fileRowset = GetLevel0();
   &fileRow = &fileRowset.GetRow(1);
   &fileRowset1 = &fileRow.GetRowset(Scroll.TEST_BU_REC);
   &myFile.WriteRowset(&fileRowset1);
End-If;

******* Comment ********

The code should be written on the key fields
For accessing further levels we have to give full scroll path

****************** to access next levels ********************
Local File &myFile;
Local Rowset &fileRowset1, &fileRowset;
Local Row &fileRow;

&myFile = GetFile("c:\temp\myfiledept.txt", "W", %FilePath_Absolute);

If &myFile.SetFileLayout(FileLayout.TEST_FILE_LAYOUT) Then
   &fileRowset = &myFile.CreateRowset();
   &fileRowset = GetLevel0();
   &fileRow = &fileRowset.GetRow(1);
   &fileRowset1 = &fileRow.GetRowset(Scroll.TEST_BU_REC).GetRow(1).GetRowset(Scroll.TEST_DEPT_REC);
   &myFile.WriteRowset(&fileRowset1);
End-If;

********************** end ************************************

Peoplecode: Writing to file using Write Record


Local Record &RecLine;
Local File &MYFILE;
Local SQL &SQL2;

&MYFILE = GetFile("c:\temp\test.txt", "W", %FilePath_Absolute);


If &MYFILE.SetFileLayout(FileLayout.TEST_FILE_LAYOUT) Then
   &RecLine = CreateRecord(Record.TEST_EMP_REC);
   &SQL2 = CreateSQL("%Selectall(:1)", &RecLine);
   While &SQL2.Fetch(&RecLine)
      &MYFILE.WriteRecord(&RecLine);
   End-While;
End-If;

&MYFILE.Close();

SQLExec : Return: 8015 - Bind value is too long


You get this error in an online page or while running a Application engine program. This error happens when you try to insert more than 254 characters in a long field using sqlexec and do not use %TextIn meta sql.
Resolution
Use %TextIn meta-sql for the bind variable that is used for inserting into a long field. For e.g. %TextIn(:1)
%TextIn is documented in peoplebooks and is mandatory for all insertions/update of LongChar fields using sqlexec for all database platforms.
Here are some resolutions that discusses this issue in Metalink – Oracle support site.
E-AE Application Engine PeopleCode Step with SQLExec Receives Error; return code 8015 "Bind value is too long" [ID 889806.1]
E-PC:"Bind value is too long" Error When Using SQLExec to Insert into Long Char Field [ID 620874.1]

How to use CTRL+J in Google Chrome


Here is the solution, both works for me.
1. First press and hold J then press CTRL and release J.
2. Press CTRL+SHIFT+J Twice
3. Click on the page tab and hold your click, then press CTRL+J

Thanks
Sharath