public static function getOracleClobValue($tableName, $fieldName, $primaryKey, $pk) { $sql = 'SELECT LENGTH('.$fieldName.') AS NUM FROM '.$tableName.' WHERE '.$primaryKey.'=:PK'; $cmd = Yii::app()->db->createCommand($sql); $cmd->bindParam(':PK', $pk); $row = $cmd->queryRow(); $num = $row['NUM']; $content=''; $start = 1; $len = 2500; // fetch length per time while($start <= $num) { $ret=''; $sql = "BEGIN GET_CLOB(:TABLE_NAME, :FIELD_NAME, :PRIMARY_KEY, :PRIMARY_KEY_VALUE, :START_POS, :FETCH_LENGTH, :RETURN_VALUE); END;"; $cmd = Yii::app()->db->createCommand($sql); $cmd->bindParam(':TABLE_NAME', $tableName); $cmd->bindParam(':FIELD_NAME', $fieldName); $cmd->bindParam(':PRIMARY_KEY', $primaryKey); $cmd->bindParam(':PRIMARY_KEY_VALUE', $pk); $cmd->bindParam(':START_POS', $start); $cmd->bindParam(':FETCH_LENGTH', $len); $cmd->bindParam(':RETURN_VALUE', $ret, PDO::PARAM_STR, 5000); $cmd->execute(); $content .= $ret; $start=$start+$len; } return $content;}
CREATE OR REPLACE PROCEDURE GET_CLOB(TABLE_NAME IN VARCHAR2, FIELD_NAME IN VARCHAR, PRIMARY_KEY IN VARCHAR, PRIMARY_KEY_VALUE IN INTEGER, START_POS IN INTEGER, FETCH_LENGTH IN BINARY_INTEGER, RETURN_VALUE OUT VARCHAR2) IS RULE_XML CLOB; FETCH_BUFFER VARCHAR2(3999); FETCH_LENGTH_ BINARY_INTEGER; BEGIN EXECUTE IMMEDIATE 'SELECT ' ||FIELD_NAME|| ' FROM ' ||TABLE_NAME|| ' WHERE ' ||PRIMARY_KEY|| '=:1' INTO RULE_XML USING PRIMARY_KEY_VALUE; FETCH_LENGTH_:=FETCH_LENGTH; DBMS_LOB.READ(RULE_XML, FETCH_LENGTH_, START_POS, FETCH_BUFFER); RETURN_VALUE := FETCH_BUFFER; END GET_CLOB;
PHP getOracleClobValue
最新推荐文章于 2023-09-08 15:50:54 发布