2845 QVERIFY_SQL(q, exec("{CALL "+procName+"}")); |
2861 QVERIFY_SQL(q, exec("{CALL "+procName+"}")); |
2846 |
2862 |
2847 QVERIFY_SQL(q, next()); |
2863 QVERIFY_SQL(q, next()); |
2848 } |
2864 } |
2849 |
2865 |
|
2866 void tst_QSqlQuery::QTBUG_551() |
|
2867 { |
|
2868 QFETCH( QString, dbName ); |
|
2869 QSqlDatabase db = QSqlDatabase::database( dbName ); |
|
2870 CHECK_DATABASE( db ); |
|
2871 QSqlQuery q(db); |
|
2872 QString pkgname=qTableName("pkg"); |
|
2873 QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\ |
|
2874 \n\ |
|
2875 TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\ |
|
2876 TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\ |
|
2877 PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\ |
|
2878 END "+pkgname+";")); |
|
2879 |
|
2880 QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\ |
|
2881 PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\ |
|
2882 IS\n\ |
|
2883 BEGIN\n\ |
|
2884 Outp(1) := '1. Value is ' ||TO_CHAR(Inp(1));\n\ |
|
2885 Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\ |
|
2886 Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\ |
|
2887 END p;\n\ |
|
2888 END "+pkgname+";")); |
|
2889 |
|
2890 QVariantList inLst, outLst, res_outLst; |
|
2891 |
|
2892 q.prepare("begin "+pkgname+".p(:inp, :outp); end;"); |
|
2893 |
|
2894 QString StVal; |
|
2895 StVal.reserve(60); |
|
2896 |
|
2897 // loading arrays |
|
2898 for (int Cnt=0; Cnt < 3; Cnt++) { |
|
2899 inLst << Cnt; |
|
2900 outLst << StVal; |
|
2901 } |
|
2902 |
|
2903 q.bindValue(":inp", inLst); |
|
2904 q.bindValue(":outp", outLst, QSql::Out); |
|
2905 |
|
2906 QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) ); |
|
2907 res_outLst = qVariantValue<QVariantList>(q.boundValues()[":outp"]); |
|
2908 QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0")); |
|
2909 QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1")); |
|
2910 QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2")); |
|
2911 } |
|
2912 |
|
2913 void tst_QSqlQuery::QTBUG_5251() |
|
2914 { |
|
2915 QFETCH( QString, dbName ); |
|
2916 QSqlDatabase db = QSqlDatabase::database( dbName ); |
|
2917 CHECK_DATABASE( db ); |
|
2918 |
|
2919 if (!db.driverName().startsWith( "QPSQL" )) return; |
|
2920 |
|
2921 QSqlQuery q(db); |
|
2922 q.exec("DROP TABLE " + qTableName("timetest")); |
|
2923 QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("timetest") + " (t TIME)")); |
|
2924 QVERIFY_SQL(q, exec("INSERT INTO " + qTableName("timetest") + " VALUES ('1:2:3.666')")); |
|
2925 |
|
2926 QSqlTableModel timetestModel(0,db); |
|
2927 timetestModel.setEditStrategy(QSqlTableModel::OnManualSubmit); |
|
2928 timetestModel.setTable(qTableName("timetest")); |
|
2929 QVERIFY_SQL(timetestModel, select()); |
|
2930 |
|
2931 QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("01:02:03.666")); |
|
2932 QVERIFY_SQL(timetestModel,setData(timetestModel.index(0, 0), QTime(0,12,34,500))); |
|
2933 QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); |
|
2934 QVERIFY_SQL(timetestModel, submitAll()); |
|
2935 QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:12:34.500")); |
|
2936 |
|
2937 QVERIFY_SQL(q, exec("UPDATE " + qTableName("timetest") + " SET t = '0:11:22.33'")); |
|
2938 QVERIFY_SQL(timetestModel, select()); |
|
2939 QCOMPARE(timetestModel.record(0).field(0).value().toTime().toString("HH:mm:ss.zzz"), QString("00:11:22.330")); |
|
2940 |
|
2941 } |
|
2942 |
|
2943 void tst_QSqlQuery::QTBUG_6421() |
|
2944 { |
|
2945 QFETCH( QString, dbName ); |
|
2946 QSqlDatabase db = QSqlDatabase::database( dbName ); |
|
2947 CHECK_DATABASE( db ); |
|
2948 |
|
2949 QSqlQuery q(db); |
|
2950 QString tableName=qTableName(QLatin1String("bug6421")).toUpper(); |
|
2951 |
|
2952 QVERIFY_SQL(q, exec("create table "+tableName+"(COL1 char(10), COL2 char(10), COL3 char(10))")); |
|
2953 QVERIFY_SQL(q, exec("create index INDEX1 on "+tableName+" (COL1 desc)")); |
|
2954 QVERIFY_SQL(q, exec("create index INDEX2 on "+tableName+" (COL2 desc)")); |
|
2955 QVERIFY_SQL(q, exec("create index INDEX3 on "+tableName+" (COL3 desc)")); |
|
2956 q.setForwardOnly(true); |
|
2957 QVERIFY_SQL(q, exec("select COLUMN_EXPRESSION from ALL_IND_EXPRESSIONS where TABLE_NAME='"+tableName+"'")); |
|
2958 QVERIFY_SQL(q, next()); |
|
2959 QCOMPARE(q.value(0).toString(), QLatin1String("\"COL1\"")); |
|
2960 QVERIFY_SQL(q, next()); |
|
2961 QCOMPARE(q.value(0).toString(), QLatin1String("\"COL2\"")); |
|
2962 QVERIFY_SQL(q, next()); |
|
2963 QCOMPARE(q.value(0).toString(), QLatin1String("\"COL3\"")); |
|
2964 } |
|
2965 |
|
2966 void tst_QSqlQuery::QTBUG_6618() |
|
2967 { |
|
2968 QFETCH( QString, dbName ); |
|
2969 QSqlDatabase db = QSqlDatabase::database( dbName ); |
|
2970 CHECK_DATABASE( db ); |
|
2971 if (!tst_Databases::isSqlServer( db )) |
|
2972 QSKIP("SQL Server specific test", SkipSingle); |
|
2973 |
|
2974 QSqlQuery q(db); |
|
2975 q.exec( "drop procedure " + qTableName( "tst_raiseError" ) ); //non-fatal |
|
2976 QString errorString; |
|
2977 for (int i=0;i<110;i++) |
|
2978 errorString+="reallylong"; |
|
2979 errorString+=" error"; |
|
2980 QVERIFY_SQL( q, exec("create procedure " + qTableName( "tst_raiseError" ) + " as\n" |
|
2981 "begin\n" |
|
2982 " raiserror('" + errorString + "', 16, 1)\n" |
|
2983 "end\n" )); |
|
2984 q.exec( "{call " + qTableName( "tst_raiseError" ) + "}" ); |
|
2985 QVERIFY(q.lastError().text().contains(errorString)); |
|
2986 } |
|
2987 |
2850 QTEST_MAIN( tst_QSqlQuery ) |
2988 QTEST_MAIN( tst_QSqlQuery ) |
2851 #include "tst_qsqlquery.moc" |
2989 #include "tst_qsqlquery.moc" |