<proc_name> specifies the name of the proc. (standard) is a keyword which indicates to JPortal2 that the fields returned by the query, will include all the
fields of the table. The (standard) clause is mostly used with some older built-in generators for typed languages like
C#, Java or C++. Its use is largely supersedes in most of the newer generators and the template generators, since
one can get exactly the same functionality by using SelectBy and not specifying
OUTPUT clause.
<comment> is a comment that will get added to the generated code. Not all generators support comments. <option_string> is a list of string options that can be passed to the generators. The options are generator
specified. If you want to use the a specific generator's options, the generator's instructions will tell you what
to pass into <option_string>.
The INPUT section defines the input fields into the proc.
The INOUT section defines fields that are input and output fields into the proc. You can also put the fieldname
into both the INPUT and OUTPUT section for the same effect.
The OUTPUT section defines the output fields into the proc.
The SQLCODE and ENDCODE keywords specify the beginning and end of your custom SQL.
packagecom.example.db;importbbd.jportal2.util.*;importjava.sql.*;importjava.util.*;importjava.math.*;/** * This proc selects books and their authors for titles like :TitleLike. * You can pass in a wildcard into TitleLike eg TitleLike = 'ABC%' */publicclassBooksSelectBookAndAuthorDetailsextendsBooksSelectBookAndAuthorDetailsStruct{privatestaticfinallongserialVersionUID=1L;Connectorconnector;Connectionconnection;publicBooksSelectBookAndAuthorDetails(){super();}publicvoidsetConnector(Connectorconn){this.connector=conn;connection=connector.connection;}publicBooksSelectBookAndAuthorDetails(Connectorconnector){super();this.connector=connector;connection=connector.connection;}/** * This proc selects books and their authors for titles like :TitleLike. * You can pass in a wildcard into TitleLike eg TitleLike = 'ABC%' * Returns any number of records. * @return result set of records found * @exception SQLException is passed through */publicQueryselectBookAndAuthorDetails()throwsSQLException{Stringstatement="/* PROC BooksAndAuthors.Books.SelectBookAndAuthorDetails */"+"SELECT "+"a.Bio, "+"b.Title, "+"b.PublishDate, "+"b.LastUpdated "+"FROM "+"Authors a "+"INNER JOIN "+"Books b "+"ON a.ID = b.AuthorID "+"WHERE "+"b.Title LIKE ? ";PreparedStatementprep=connector.prepareStatement(statement);prep.setString(1,titleLike);ResultSetresult=prep.executeQuery();Queryquery=newQuery(prep,result);returnquery;}/** * Returns the next record in a result set. * @param query The result set for the query. * @return true while records are found. * @exception SQLException is passed through */publicbooleanselectBookAndAuthorDetails(Queryquery)throwsSQLException{if(!query.result.next()){query.close();returnfalse;}ResultSetresult=query.result;bio=result.getString(1);title=result.getString(2);publishDate=result.getDate(3);lastUpdated=result.getTimestamp(4);returntrue;}/** * Returns all the records in a result set as array of BooksSelectBookAndAuthorDetails. * @return array of BooksSelectBookAndAuthorDetails. * @exception SQLException is passed through */publicBooksSelectBookAndAuthorDetails[]selectBookAndAuthorDetailsLoad()throwsSQLException{Vector<BooksSelectBookAndAuthorDetails>recs=newVector<>();Queryquery=selectBookAndAuthorDetails();while(selectBookAndAuthorDetails(query)==true){BooksSelectBookAndAuthorDetailsrec=newBooksSelectBookAndAuthorDetails();rec.bio=bio;rec.title=title;rec.publishDate=publishDate;rec.lastUpdated=lastUpdated;recs.addElement(rec);}BooksSelectBookAndAuthorDetails[]result=newBooksSelectBookAndAuthorDetails[recs.size()];for(inti=0;i<recs.size();i++)result[i]=recs.elementAt(i);returnresult;}/** * Returns any number of records. * @return result set of records found * @param titleLike input. * @exception SQLException is passed through */publicQueryselectBookAndAuthorDetails(StringtitleLike)throwsSQLException{this.titleLike=titleLike;returnselectBookAndAuthorDetails();}}