📄 javaqry.ssc
字号:
<!--SCRIPT PSOBJMOD
import( site.GetRootDocument().location + "/ObjMod80.ssc" );
session.active = true;
InitObjects(session);
-->
<!--SCRIPT // {{ SCRIPT()
// This class takes as a parameter a Tabular ResultSet object.
// The JavaQuery class implements the same methods as a Dynamo
// query object, so that you can work with the Tabular ResultSet
// as if it were a Dynamo query object. Some behaviour may
// differ slightly since the Tabular ResultSet object does not
// support some functionality provided by the Dynamo query
// object. The Dynamo query object can sometimes support
// movement backwards through the result set. Backward movement
// is not supported by the Tabular Result Set object.
class JavaQuery( rs ) {
this.position = 0;
// Cast the Tabular Results Set to a java.sql.ResultSet
this.rs = java.CallStaticMethod( "com.sybase.CORBA.jdbc11.SQL","getResultSet", rs );
this.metadata = this.rs.getMetaData();
function Execute() {
// There is no Java equivalent, so always return true.
return true;
}
this.Execute = Execute;
function GetColumnCount() {
return this.metadata.getColumnCount();
}
this.GetColumnCount = GetColumnCount;
function GetColumnIndex( name ) {
var index = this.rs.findColumn( name );
if( index == 0 ) return -1;
return index;
}
this.GetColumnIndex = GetColumnIndex;
function GetColumnLabel( index ) {
if( index < 1 || index > this.metadata.getColumnCount() ) {
return "";
}
return this.metadata.getColumnLabel( index );
}
this.GetColumnLabel = GetColumnLabel;
function GetEmpty() {
// There is no Java equivalent, so always return false.
return false;
}
this.GetEmpty = GetEmpty;
function GetErrorCode() {
// There is no Java equivalent, so always return 0.
return 0;
}
this.GetErrorCode = GetErrorCode;
function GetErrorInfo() {
// There is no Java equivalent, so always return "".
return "";
}
this.GetErrorInfo = GetErrorInfo;
function GetRowCount() {
// There is no Java equivalent, so always return -1
return -1;
}
this.GetRowCount = GetRowCount;
function GetState() {
// This is no Java equivalent, so always return "".
return "";
}
this.GetState = GetState;
function MoveFirst() {
// There is no Java equivalent, so always return false
return false;
}
this.MoveFirst = MoveFirst;
function Move( index ) {
// There is no Java equivalent, so always return false
return false;
}
this.Move = Move;
function MoveNext() {
if( this.rs.next() ) {
this.position++;
return true;
}
return false;
}
this.MoveNext = MoveNext;
function MoveLast() {
// There is no Java equivalent, so always return false
return false;
}
this.MoveLast = MoveLast;
function MovePrevious() {
// There is no Java equivalent, so always return false
return false;
}
this.MovePrevious = MovePrevious;
function MoveRelative( index ) {
// There is no Java equivalent, so always return false
return false;
}
this.MoveRelative = MoveRelative;
function Opened() {
// There is no Java equivalent, so always return true.
return( true );
}
this.Opened = Opened;
function Close() {
// There is no Java equivalent, so always return true.
return( true );
}
this.Close = Close;
function Refresh() {
// There is no Java equivalent, so always return false.
return false;
}
this.Refresh = Refresh;
function SetSQL( sql ) {
// There is no Java equivalent, so always return false.
return false;
}
this.SetSQL = SetSQL;
function GetValue( index ) {
if( index < 1 || index > this.metadata.getColumnCount() ) return "";
type = this.metadata.getColumnType( index );
switch( type ) {
case 1: //CHAR
return this.rs.getString( index );
case 2: //NUMERIC
case 3: //DECIMAL
return this.rs.getBigDecimal( index, this.metadata.getScale(index) ).floatValue();
case 4: //INTEGER
return this.rs.getInt( index );
case 5: //SMALLINT
return this.rs.getShort( index );
case 6: //FLOAT
case 7: //REAL
return this.rs.getFloat( index );
case 8: //DOUBLE
return this.rs.getDouble( index );
case 12: //VARCHAR
return this.rs.getString( index );
case 0: //NULL
return null
case 1111: //OTHER
return this.rs.getObject( index );
case 91: //DATE
return this.rs.getDate( index );
case 92: //TIME
return this.rs.getTime( index );
case 93: //TIMESTAMP
return this.rs.getTimestamp( index );
default:
if( type < 0 ) {
if( type == -1 ) { //LONGVARCHAR
return this.rs.getString( index );
} else if( type == -2 ) { //BINARY
return this.rs.getBytes( index );
} else if( type == -3 ) { //VARBINARY
return this.rs.getBytes( index );
} else if( type == -4 ) { //LONGVARBINARY
return this.rs.getBytes( index );
} else if( type == -5 ) { //BIGINT
return this.rs.getLong( index );
} else if( type == -6 ) { //TINYINT
return this.rs.getShort( index );
} else if( type == -7 ) { //BIT
return this.rs.getBytes( index );
}
} else {
return this.rs.getBytes( index );
}
}
}
this.GetValue = GetValue;
function ResultsToXMLString() {
// There is no Java equivalent, so always return null.
return null;
}
this.ResultsToXMLString = ResultsToXMLString;
}
// }}
-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -