0

我正在使用 oracle forms 6i,并且我使用 EXEC_SQL 创建了一个动态 sql。我正在使用单个块记录,但是当我说 next_record 我不移动时,我无法在记录之间导航。没有错误只是记录不会进入下一个记录;

每次用户单击工具栏上的“第一个”、“上一个”、“下一个”和“最后一个”按钮时,都会触发此代码。查询正在返回记录,我只是在通过单个记录块中的导航按钮访问它时遇到问题。

代码

BEGIN   
    cursor_number := Exec_SQL.Open_cursor;  
    recordcount_cursor_number := Exec_SQL.Open_cursor;

  --build SQL
  Sql_Stmt := 'SELECT .......   FROM table WHERE 1 = 1 '||where_clause ||' order by surname';--dynamic where

    --cannot use the dynamic where since this changes based on rowid                                
    Sql_CountStmt := 'SELECT COUNT(DISTINCT(ins_reg_no))FROM table WHERE 1 = 1 '||:global.ins_last_where_clause;--dynamic where

--  Show_Message(where_clause);                                                         
    --Parse SQL statement
    EXEC_SQL.PARSE(cursor_number, Sql_Stmt);
    EXEC_SQL.PARSE(recordcount_cursor_number, Sql_CountStmt);

    --Define the cloums for the data to be returned
    EXEC_SQL.DEFINE_COLUMN(cursor_number,1, ins_reg_no);
    ......
    ......
    ......

    EXEC_SQL.DEFINE_COLUMN(recordcount_cursor_number,1,totalRecords);

    --Execute the cursor
    Count := EXEC_SQL.EXECUTE(cursor_number);

    CountRec := EXEC_SQL.EXECUTE(recordcount_cursor_number);    

        WHILE EXEC_SQL.FETCH_ROWS(recordcount_cursor_number)> 0 LOOP    
            --SET_ITEM_PROPERTY(CURSOR_STYLE,'BUSY');               
                EXEC_SQL.COLUMN_VALUE(recordcount_cursor_number,1,totalRecords);            
                :global.ins_last_record_click := totalRecords;
        END LOOP;

    EXEC_SQL.CLOSE_CURSOR(recordcount_cursor_number);--very important to close cursor since system can freeze when navigating records

    IF(to_number(:global.ins_last_record_click) != 0)THEN
        :global.ins_last_record_click := totalRecords;

    WHILE EXEC_SQL.FETCH_ROWS(cursor_number)> 0 LOOP


            EXEC_SQL.COLUMN_VALUE(cursor_number,1,ins_reg_no);
            .......
            .......
            ........

            --For each operation here that request data to get to the record

                IF(request = 'GET_ALL')THEN
                    --LAST_RECORD;  
                    FIRST_RECORD;       
                    --EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';                                           
                ELSIF(request = 'NEXT') THEN
                    --LAST_RECORD;
                    NEXT_RECORD;                
                ELSIF(request = 'PREVIOUS')THEN
                --LAST_RECORD;
                PREVIOUS_RECORD;
                ELSIF(request = 'FIRST')THEN
                    FIRST_RECORD;               
                END IF;

            END LOOP;       


            EXEC_SQL.CLOSE_CURSOR(cursor_number);--very important to close cursor since system can freeze when navigating records   
            --set form fields qual to the cursor data
            :ins_reg_no             := ins_reg_no;
            :ins_mar_stat           := ins_mar_stat;
            :ins_oth_name           := ins_oth_name ;
            :ins_sex                := ins_sex;
            :ins_dob                := ins_dob;
            :ins_pob                := ins_pob;
            ...............
            ...............

      GO_BLOCK('TOOLBAR-BLK');  
    ELSE
        Message('Query Caused No Records To Be Retrived',NO_ACKNOWLEDGE);
    END IF;

END;
4

1 回答 1

1

我建议您将块(表单)中的查询数据源名称属性修改为您的查询,在括号中,即(选择...从...哪里...)并将查询数据源类型属性更改为“从子句” .

您还可以使用 set_block_property 内置包更改代码中的查询文本。

这比将表单放在一个包中要容易得多。

看看这个:https ://sites.google.com/site/craigsoraclestuff/oracle-forms---how-to-s/forms-how-to---base-a-block-on-a-from-子句查询

至于“单记录块”,我建议您尝试使用多记录块,但将显示的记录数属性设置为 1。

希望能帮助到你。

于 2013-08-13T04:34:30.887 回答